Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 19th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'graph'
  2. module Orcl
  3.   class Element
  4.     def node(g)
  5.       g.rect + g.filled + graph(g) << g.node(name)
  6.       deps.each { |d| g.edge name, d.name }
  7.     end
  8.   end
  9.   class Table
  10.     def graph(g) g.c1 end
  11.   end
  12.   class View
  13.     def graph(g) g.c2 end
  14.   end
  15.   class MaterializedView
  16.     def graph(g) g.c3 end
  17.   end
  18.  
  19.   class Schema
  20.     def graph
  21.       s = self
  22.       digraph do
  23.         rotate
  24.         colorscheme :accent , 3
  25.         s.tabloid.each { |t|  t.node self  }
  26. #        graph_attribs << p("{ rank=same; #{s.table.map( &:name ).join(' ')}}")  
  27.         same_rank s.table.map( &:name )
  28.         save "schema/mxofm", "pdf"
  29.       end
  30.       :done
  31.     end
  32.   end
  33. end