44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'src/ruby/schema_renderer.rb', line 44
def to_dot()
StringIO.open do |io|
io.puts "digraph {"
io.puts "graph [fontname = Arial, fontsize = 10, nodesep = 0.2, ranksep = 0.3];"
io.puts "node [fontname = Arial, fontsize = 10, shape = rect, margin = 0];"
io.puts "edge [fontname = Arial, fontsize = 10, arrowsize = 0.6, color = \"#000000\"];"
io.puts "splines=true;"
@nodes.each do |node|
io.puts "n_#{node.label} [label=\" #{node.label} \", style=\"filled\", fillcolor=\"#fce94f\"];"
end
@nodes.each do |node|
node.rels.each do |rel|
l = "r_#{node.label}_#{rel[:type]}_#{rel[:target]}"
io.puts "#{l} [label=\" #{rel[:type]} \"];"
if rel[:dir] == :out
io.puts "n_#{node.label} -> #{l};"
io.puts "#{l} -> n_#{rel[:target]};"
else
io.puts "n_#{rel[:target]} -> #{l};"
io.puts "#{l} -> n_#{node.label};"
end
end
end
io.puts "}"
io.string
end
end
|