aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails_generator/generators/components/model
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-07-01 22:19:54 +0200
committerJosé Valim <jose.valim@gmail.com>2009-07-02 10:27:40 +0200
commitea0b0c820de64fa3d67890071af8120dc503dcb7 (patch)
treef0b58ba1befcc866eec03fa92cc89576f8c84368 /railties/lib/rails_generator/generators/components/model
parentc972b25df56e12a995774aa0291b2d8c2f3eabb5 (diff)
downloadrails-ea0b0c820de64fa3d67890071af8120dc503dcb7.tar.gz
rails-ea0b0c820de64fa3d67890071af8120dc503dcb7.tar.bz2
rails-ea0b0c820de64fa3d67890071af8120dc503dcb7.zip
rm -rf rails_generator/generators
Diffstat (limited to 'railties/lib/rails_generator/generators/components/model')
-rw-r--r--railties/lib/rails_generator/generators/components/model/USAGE27
-rw-r--r--railties/lib/rails_generator/generators/components/model/model_generator.rb45
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/fixtures.yml19
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/migration.rb16
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/model.rb5
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/unit_test.rb8
6 files changed, 0 insertions, 120 deletions
diff --git a/railties/lib/rails_generator/generators/components/model/USAGE b/railties/lib/rails_generator/generators/components/model/USAGE
deleted file mode 100644
index 24b03b4d4a..0000000000
--- a/railties/lib/rails_generator/generators/components/model/USAGE
+++ /dev/null
@@ -1,27 +0,0 @@
-Description:
- Stubs out a new model. Pass the model name, either CamelCased or
- under_scored, and an optional list of attribute pairs as arguments.
-
- Attribute pairs are column_name:sql_type arguments specifying the
- model's attributes. Timestamps are added by default, so you don't have to
- specify them by hand as 'created_at:datetime updated_at:datetime'.
-
- You don't have to think up every attribute up front, but it helps to
- sketch out a few so you can start working with the model immediately.
-
- This generates a model class in app/models, a unit test in test/unit,
- a test fixture in test/fixtures/singular_name.yml, and a migration in
- db/migrate.
-
-Examples:
- `./script/generate model account`
-
- creates an Account model, test, fixture, and migration:
- Model: app/models/account.rb
- Test: test/unit/account_test.rb
- Fixtures: test/fixtures/accounts.yml
- Migration: db/migrate/XXX_add_accounts.rb
-
- `./script/generate model post title:string body:text published:boolean`
-
- creates a Post model with a string title, text body, and published flag.
diff --git a/railties/lib/rails_generator/generators/components/model/model_generator.rb b/railties/lib/rails_generator/generators/components/model/model_generator.rb
deleted file mode 100644
index 582a28922f..0000000000
--- a/railties/lib/rails_generator/generators/components/model/model_generator.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-class ModelGenerator < Rails::Generator::NamedBase
- default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false
-
- def manifest
- record do |m|
- # Check for class naming collisions.
- m.class_collisions 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)
-
- # Model class, unit test, and fixtures.
- m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
- m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
-
- unless options[:skip_fixture]
- m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
- end
-
- unless options[:skip_migration]
- m.migration_template 'migration.rb', 'db/migrate', :assigns => {
- :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
- }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
- 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-migration",
- "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
- opt.on("--skip-fixture",
- "Don't generation a fixture file for this model") { |v| options[:skip_fixture] = v}
- end
-end
diff --git a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml b/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
deleted file mode 100644
index c21035113e..0000000000
--- a/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-
-<% unless attributes.empty? -%>
-one:
-<% for attribute in attributes -%>
- <%= attribute.name %>: <%= attribute.default %>
-<% end -%>
-
-two:
-<% for attribute in attributes -%>
- <%= attribute.name %>: <%= attribute.default %>
-<% end -%>
-<% else -%>
-# one:
-# column: value
-#
-# two:
-# column: value
-<% end -%>
diff --git a/railties/lib/rails_generator/generators/components/model/templates/migration.rb b/railties/lib/rails_generator/generators/components/model/templates/migration.rb
deleted file mode 100644
index 382fd1156e..0000000000
--- a/railties/lib/rails_generator/generators/components/model/templates/migration.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-class <%= migration_name %> < ActiveRecord::Migration
- def self.up
- create_table :<%= table_name %> do |t|
-<% for attribute in attributes -%>
- t.<%= attribute.type %> :<%= attribute.name %>
-<% end -%>
-<% unless options[:skip_timestamps] %>
- t.timestamps
-<% end -%>
- end
- end
-
- def self.down
- drop_table :<%= table_name %>
- end
-end
diff --git a/railties/lib/rails_generator/generators/components/model/templates/model.rb b/railties/lib/rails_generator/generators/components/model/templates/model.rb
deleted file mode 100644
index 0656b06dfe..0000000000
--- a/railties/lib/rails_generator/generators/components/model/templates/model.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class <%= class_name %> < ActiveRecord::Base
-<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
- belongs_to :<%= attribute.name %>
-<% end -%>
-end
diff --git a/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
deleted file mode 100644
index 3e0bc29d3a..0000000000
--- a/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class <%= class_name %>Test < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end