class Eatr::DotGenerator
Constants
- DEFAULT_TEMPLATE_PATH
Attributes
tables[R]
Public Class Methods
new(schema_paths, template_path: DEFAULT_TEMPLATE_PATH)
click to toggle source
# File lib/eatr/dot_generator.rb, line 7 def initialize(schema_paths, template_path: DEFAULT_TEMPLATE_PATH) @tables = Array[schema_paths].flatten.map { |s| Schema.new(YAML.load(File.read(s))) } @template_path = template_path end
Public Instance Methods
to_dot()
click to toggle source
# File lib/eatr/dot_generator.rb, line 12 def to_dot ERB.new(File.read(@template_path), nil, '-').result(binding) end
Private Instance Methods
arrow_target(belongs_to_str)
click to toggle source
# File lib/eatr/dot_generator.rb, line 23 def arrow_target(belongs_to_str) table_name, column = belongs_to_str.split('.') "\"#{table_name}\":\"#{column}\"" end
table_included?(belongs_to_str)
click to toggle source
# File lib/eatr/dot_generator.rb, line 18 def table_included?(belongs_to_str) table_name, _ = belongs_to_str.split('.') @tables.any? { |t| t.table_name == table_name } end