Method: Columns::Application#initialize

Defined in:
lib/columns.rb

#initialize(schema_dir, models_dir) ⇒ Application

Creates a new Application.

See Columns.execute for arguments.

Raises SystemExit if it can’t find the ‘schema.rb`.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/columns.rb', line 39

def initialize(schema_dir, models_dir)
  @models_dir = models_dir
  schema_path = File.expand_path(File.join(schema_dir,'schema.rb'))

  unless File.exists?(schema_path)
    puts "COLUMNS ERROR : #{schema_path} doesn't exist!"
    exit 1
  end
  table = Table.new(File.read(schema_path))

  raw_data_objects = []
  table.names.each do |name|
    raw_data_objects << RawData.new(name, table.content_for(name))
  end

  @model_data_objects = raw_data_objects.map do |object|
    ModelData.new(object)
  end
end