From 738fc579f0dc95aad9ab0dedc65fbce7af0bb980 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 25 Oct 2008 09:35:51 +0000 Subject: Renames template ruby files to erb. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1951 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../redmine_plugin_controller_generator.rb | 36 ++++++++++++++++++++++ .../templates/controller.rb | 7 ----- .../templates/controller.rb.erb | 7 +++++ .../templates/functional_test.rb | 8 ----- .../templates/functional_test.rb.erb | 8 +++++ .../redmine_plugin_controller/templates/helper.rb | 2 -- .../templates/helper.rb.erb | 2 ++ 7 files changed, 53 insertions(+), 17 deletions(-) delete mode 100644 lib/generators/redmine_plugin_controller/templates/controller.rb create mode 100644 lib/generators/redmine_plugin_controller/templates/controller.rb.erb delete mode 100644 lib/generators/redmine_plugin_controller/templates/functional_test.rb create mode 100644 lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb delete mode 100644 lib/generators/redmine_plugin_controller/templates/helper.rb create mode 100644 lib/generators/redmine_plugin_controller/templates/helper.rb.erb (limited to 'lib/generators/redmine_plugin_controller') diff --git a/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb b/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb index 533d65ce8..efe28c5da 100644 --- a/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb +++ b/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb @@ -15,4 +15,40 @@ class RedminePluginControllerGenerator < ControllerGenerator def destination_root File.join(RAILS_ROOT, plugin_path) end + + def manifest + record do |m| + # Check for class naming collisions. + m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper" + + # 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) + + # Controller class, functional test, and helper class. + m.template 'controller.rb.erb', + File.join('app/controllers', + class_path, + "#{file_name}_controller.rb") + + m.template 'functional_test.rb.erb', + File.join('test/functional', + class_path, + "#{file_name}_controller_test.rb") + + m.template 'helper.rb.erb', + File.join('app/helpers', + class_path, + "#{file_name}_helper.rb") + + # View template for each action. + actions.each do |action| + path = File.join('app/views', class_path, file_name, "#{action}.html.erb") + m.template 'view.html.erb', path, + :assigns => { :action => action, :path => path } + end + end + end end diff --git a/lib/generators/redmine_plugin_controller/templates/controller.rb b/lib/generators/redmine_plugin_controller/templates/controller.rb deleted file mode 100644 index 615986d9e..000000000 --- a/lib/generators/redmine_plugin_controller/templates/controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class <%= class_name %>Controller < ApplicationController -<% actions.each do |action| -%> - - def <%= action %> - end -<% end -%> -end diff --git a/lib/generators/redmine_plugin_controller/templates/controller.rb.erb b/lib/generators/redmine_plugin_controller/templates/controller.rb.erb new file mode 100644 index 000000000..615986d9e --- /dev/null +++ b/lib/generators/redmine_plugin_controller/templates/controller.rb.erb @@ -0,0 +1,7 @@ +class <%= class_name %>Controller < ApplicationController +<% actions.each do |action| -%> + + def <%= action %> + end +<% end -%> +end diff --git a/lib/generators/redmine_plugin_controller/templates/functional_test.rb b/lib/generators/redmine_plugin_controller/templates/functional_test.rb deleted file mode 100644 index 876bd79e2..000000000 --- a/lib/generators/redmine_plugin_controller/templates/functional_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class <%= class_name %>ControllerTest < ActionController::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb b/lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb new file mode 100644 index 000000000..876bd79e2 --- /dev/null +++ b/lib/generators/redmine_plugin_controller/templates/functional_test.rb.erb @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class <%= class_name %>ControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/lib/generators/redmine_plugin_controller/templates/helper.rb b/lib/generators/redmine_plugin_controller/templates/helper.rb deleted file mode 100644 index 3fe2ecdc7..000000000 --- a/lib/generators/redmine_plugin_controller/templates/helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module <%= class_name %>Helper -end diff --git a/lib/generators/redmine_plugin_controller/templates/helper.rb.erb b/lib/generators/redmine_plugin_controller/templates/helper.rb.erb new file mode 100644 index 000000000..3fe2ecdc7 --- /dev/null +++ b/lib/generators/redmine_plugin_controller/templates/helper.rb.erb @@ -0,0 +1,2 @@ +module <%= class_name %>Helper +end -- cgit v1.2.3