aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails_generator/generators/components/resource
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails_generator/generators/components/resource')
-rw-r--r--railties/lib/rails_generator/generators/components/resource/USAGE23
-rw-r--r--railties/lib/rails_generator/generators/components/resource/resource_generator.rb76
-rw-r--r--railties/lib/rails_generator/generators/components/resource/templates/controller.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb8
-rw-r--r--railties/lib/rails_generator/generators/components/resource/templates/helper.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb4
6 files changed, 0 insertions, 115 deletions
diff --git a/railties/lib/rails_generator/generators/components/resource/USAGE b/railties/lib/rails_generator/generators/components/resource/USAGE
deleted file mode 100644
index e6043f1de1..0000000000
--- a/railties/lib/rails_generator/generators/components/resource/USAGE
+++ /dev/null
@@ -1,23 +0,0 @@
-Description:
- Stubs out a new resource including an empty model and controller suitable
- for a restful, resource-oriented application. Pass the singular model name,
- either CamelCased or under_scored, as the first argument, and an optional
- list of attribute pairs.
-
- 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 resource immediately.
-
- This creates a model, controller, helper, tests and fixtures for all of them,
- and the corresponding map.resources declaration in config/routes.rb
-
- Unlike the scaffold generator, the resource generator does not create
- views or add any methods to the generated controller.
-
-Examples:
- `./script/generate resource post` # no attributes
- `./script/generate resource post title:string body:text published:boolean`
- `./script/generate resource purchase order_id:integer amount:decimal`
diff --git a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb b/railties/lib/rails_generator/generators/components/resource/resource_generator.rb
deleted file mode 100644
index 4ee2fbff63..0000000000
--- a/railties/lib/rails_generator/generators/components/resource/resource_generator.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-class ResourceGenerator < Rails::Generator::NamedBase
- default_options :skip_timestamps => false, :skip_migration => false
-
- attr_reader :controller_name,
- :controller_class_path,
- :controller_file_path,
- :controller_class_nesting,
- :controller_class_nesting_depth,
- :controller_class_name,
- :controller_singular_name,
- :controller_plural_name
- alias_method :controller_file_name, :controller_singular_name
- alias_method :controller_table_name, :controller_plural_name
-
- def initialize(runtime_args, runtime_options = {})
- super
-
- @controller_name = @name.pluralize
-
- base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
- @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
-
- if @controller_class_nesting.empty?
- @controller_class_name = @controller_class_name_without_nesting
- else
- @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
- end
- end
-
- def manifest
- record do |m|
- # Check for class naming collisions.
- m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper")
- m.class_collisions(class_name)
-
- # Controller, helper, views, and test directories.
- m.directory(File.join('app/models', class_path))
- m.directory(File.join('app/controllers', controller_class_path))
- m.directory(File.join('app/helpers', controller_class_path))
- m.directory(File.join('app/views', controller_class_path, controller_file_name))
- m.directory(File.join('test/functional', controller_class_path))
- m.directory(File.join('test/unit', class_path))
- m.directory(File.join('test/unit/helpers', class_path))
-
- m.dependency 'model', [name] + @args, :collision => :skip
-
- m.template(
- 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
- )
-
- m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
- m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
- m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
-
- m.route_resources controller_file_name
- end
- end
-
- protected
- def banner
- "Usage: #{$0} resource 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 }
- end
-
- def model_name
- class_name.demodulize
- end
-end
diff --git a/railties/lib/rails_generator/generators/components/resource/templates/controller.rb b/railties/lib/rails_generator/generators/components/resource/templates/controller.rb
deleted file mode 100644
index 765a942694..0000000000
--- a/railties/lib/rails_generator/generators/components/resource/templates/controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class <%= controller_class_name %>Controller < ApplicationController
-end
diff --git a/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
deleted file mode 100644
index b1bb1dacbf..0000000000
--- a/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class <%= controller_class_name %>ControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/railties/lib/rails_generator/generators/components/resource/templates/helper.rb b/railties/lib/rails_generator/generators/components/resource/templates/helper.rb
deleted file mode 100644
index 9bd821b1b2..0000000000
--- a/railties/lib/rails_generator/generators/components/resource/templates/helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module <%= controller_class_name %>Helper
-end
diff --git a/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb b/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb
deleted file mode 100644
index 061f64a5e3..0000000000
--- a/railties/lib/rails_generator/generators/components/resource/templates/helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class <%= controller_class_name %>HelperTest < ActionView::TestCase
-end