Sha256: aeffdee43fd4b995e5e68bec8418684325f70a715b7875b0a1f31225d4d6d10c

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

class HobofieldModelGenerator < Rails::Generator::NamedBase
  default_options :skip_timestamps => false, :skip_fixture => false

  def manifest
    record do |m|
      # Check for class naming collisions.
      m.class_collisions class_path, class_name, "#{class_name}Test"

      # Model, test, and fixture directories.
      m.directory File.join('app/models', class_path)
      m.directory File.join('test/unit', class_path)
      m.directory File.join('test/fixtures', class_path)

      # Create stubs
      m.template "model.rb.erb",  "app/models/#{file_name}.rb"
      m.template "test.rb.erb",   "test/unit/#{file_name}_test.rb"

      unless options[:skip_fixture]
       	m.template 'fixtures.yml.erb',  File.join('test/fixtures', "#{file_name.pluralize}.yml")
      end

    end
  end

  protected
    def banner
      "Usage: #{$0} #{spec.name} ModelName [field:type, field:type]"
    end

    def add_options!(opt)
      opt.separator ''
      opt.separator 'Options:'
      opt.on("--skip-timestamps",
             "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
      opt.on("--skip-fixture",
             "Don't generation a fixture file for this model") { |v| options[:skip_fixture] = v}
    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hobofields-0.8.10 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.9 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.8 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.1 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.3 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.2 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.6 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.5 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.4 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8.7 rails_generators/hobofield_model/hobofield_model_generator.rb
hobofields-0.8 rails_generators/hobofield_model/hobofield_model_generator.rb