Class: FWToolkit::CLI

Inherits:
Thor
  • Object
show all
Includes:
Rake::DSL, Thor::Actions
Defined in:
lib/fwtoolkit/cli.rb

Instance Method Summary collapse

Instance Method Details

#model(core_data_model_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fwtoolkit/cli.rb', line 13

def model(core_data_model_path)
  # validation step - core_data_model should be of type .xcdatamodel
  output_dir = File.join('Frank', 'features', 'support', 'models')
  FWToolkit::CLI.source_root(FWToolkit.root)
  
  @no_prefix = options.no_prefix
  
  model = CoreData::DataModel.new(File.join(core_data_model_path, 'contents'))
  @models = model.entities
  
  @models.each do |entity|
    @model = entity
    factory_template =  File.join 'templates', 'models', 'model.rb.erb'        
    template(factory_template, File.join(output_dir, "#{class_name(@model).ruby_format}.rb"))
  end
  
  factory_template =  File.join 'templates', 'models', 'factories.rb.erb'
  template(factory_template, File.join(output_dir, 'factories.rb'))
end