Sha256: 7cc6e828198c9991db47a6577c308744ca87c7dfb1e224bb9de78e1a3cfb6eee

Contents?: true

Size: 1.23 KB

Versions: 45

Compression:

Stored size: 1.23 KB

Contents

require 'fwtoolkit'
require 'frank-cucumber/cli'
require 'rake'

module FWToolkit
  class CLI < Thor
    
    include Rake::DSL
    include Thor::Actions
    
    desc "model CORE_DATA_MODEL", "create model files for cucumber"
    method_option :no_prefix, :aliases => "-np", :default => false, :type => :boolean
    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
    
    no_tasks do
      def class_name(entity)
        @no_prefix ? entity.name : entity.name[3..-1]
      end
    end
  end
  
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
fwtoolkit-0.6.2 lib/fwtoolkit/cli.rb
fwtoolkit-0.6.1 lib/fwtoolkit/cli.rb
fwtoolkit-0.6.0 lib/fwtoolkit/cli.rb
fwtoolkit-0.5.4 lib/fwtoolkit/cli.rb
fwtoolkit-0.5.3 lib/fwtoolkit/cli.rb
fwtoolkit-0.5.2 lib/fwtoolkit/cli.rb
fwtoolkit-0.5.1 lib/fwtoolkit/cli.rb
fwtoolkit-0.5.0 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.6 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.5 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.4 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.3 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.2 lib/fwtoolkit/cli.rb
fwtoolkit-0.3.4 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.1 lib/fwtoolkit/cli.rb
fwtoolkit-0.4.0 lib/fwtoolkit/cli.rb
fwtoolkit-0.3.3 lib/fwtoolkit/cli.rb
fwtoolkit-0.3.2 lib/fwtoolkit/cli.rb
fwtoolkit-0.3.1 lib/fwtoolkit/cli.rb
fwtoolkit-0.3.0 lib/fwtoolkit/cli.rb