class Erde::HashTransformer
Public Class Methods
new(hash)
click to toggle source
# File lib/erde/cli.rb, line 34 def initialize(hash) @hash = hash end
Public Instance Methods
to_dot()
click to toggle source
# File lib/erde/cli.rb, line 38 def to_dot template = File.read(File.expand_path("../template.dot.erb", __FILE__)) schema_string = "" schema_string << "digraph tables {" schema_string << "node [shape=plaintext rankdir=LR];" @hash.each_pair do |table_name, table_schema| renderer = ERB.new(template) schema_string << renderer.result(binding) table_schema['relations'].each_pair do |column, target| schema_string << "#{table_name}:#{column} -> #{target['table']}:#{target['column']};" end end schema_string << "}" schema_string end