2007-01-22 14:43:50 +01:00
|
|
|
class ControllerGenerator < Rails::Generator::NamedBase
|
|
|
|
def manifest
|
|
|
|
record do |m|
|
|
|
|
# Check for class naming collisions.
|
2009-02-04 21:26:08 +01:00
|
|
|
m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper", "#{class_name}HelperTest"
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
# Controller, helper, views, and test directories.
|
|
|
|
m.directory File.join('app/controllers', class_path)
|
|
|
|
m.directory File.join('app/helpers', class_path)
|
|
|
|
m.directory File.join('app/views', class_path, file_name)
|
|
|
|
m.directory File.join('test/functional', class_path)
|
2009-02-04 21:26:08 +01:00
|
|
|
m.directory File.join('test/unit/helpers', class_path)
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
# Controller class, functional test, and helper class.
|
|
|
|
m.template 'controller.rb',
|
|
|
|
File.join('app/controllers',
|
|
|
|
class_path,
|
|
|
|
"#{file_name}_controller.rb")
|
|
|
|
|
|
|
|
m.template 'functional_test.rb',
|
|
|
|
File.join('test/functional',
|
|
|
|
class_path,
|
|
|
|
"#{file_name}_controller_test.rb")
|
|
|
|
|
|
|
|
m.template 'helper.rb',
|
|
|
|
File.join('app/helpers',
|
|
|
|
class_path,
|
|
|
|
"#{file_name}_helper.rb")
|
|
|
|
|
2009-02-04 21:26:08 +01:00
|
|
|
m.template 'helper_test.rb',
|
|
|
|
File.join('test/unit/helpers',
|
|
|
|
class_path,
|
|
|
|
"#{file_name}_helper_test.rb")
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
# View template for each action.
|
|
|
|
actions.each do |action|
|
2007-12-21 08:48:59 +01:00
|
|
|
path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
|
|
|
|
m.template 'view.html.erb', path,
|
2007-01-22 14:43:50 +01:00
|
|
|
:assigns => { :action => action, :path => path }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|