summaryrefslogtreecommitdiffstats
path: root/lib/generators/redmine_plugin_controller
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-09-05 10:31:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-09-05 10:31:06 +0000
commitf7acdd1afde3018a9f7c0a7dc3b6bd97a65670a2 (patch)
treeba4070526883885914942b3a0d253eb2a6e63bf8 /lib/generators/redmine_plugin_controller
parent4b9df2eac774aa045aa5207c8bc613ed6ca67d42 (diff)
downloadredmine-f7acdd1afde3018a9f7c0a7dc3b6bd97a65670a2.tar.gz
redmine-f7acdd1afde3018a9f7c0a7dc3b6bd97a65670a2.zip
Merged hooks branch @ r1785 into trunk.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1786 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/generators/redmine_plugin_controller')
-rw-r--r--lib/generators/redmine_plugin_controller/USAGE5
-rw-r--r--lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb18
-rw-r--r--lib/generators/redmine_plugin_controller/templates/controller.rb7
-rw-r--r--lib/generators/redmine_plugin_controller/templates/functional_test.rb8
-rw-r--r--lib/generators/redmine_plugin_controller/templates/helper.rb2
-rw-r--r--lib/generators/redmine_plugin_controller/templates/view.html.erb1
6 files changed, 41 insertions, 0 deletions
diff --git a/lib/generators/redmine_plugin_controller/USAGE b/lib/generators/redmine_plugin_controller/USAGE
new file mode 100644
index 000000000..8336e7117
--- /dev/null
+++ b/lib/generators/redmine_plugin_controller/USAGE
@@ -0,0 +1,5 @@
+Description:
+ Generates a plugin controller.
+
+Example:
+ ./script/generate redmine_plugin_controller MyPlugin Pools index show vote
diff --git a/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb b/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb
new file mode 100644
index 000000000..533d65ce8
--- /dev/null
+++ b/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb
@@ -0,0 +1,18 @@
+require 'rails_generator/base'
+require 'rails_generator/generators/components/controller/controller_generator'
+
+class RedminePluginControllerGenerator < ControllerGenerator
+ attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
+
+ def initialize(runtime_args, runtime_options = {})
+ runtime_args = runtime_args.dup
+ @plugin_name = "redmine_" + runtime_args.shift.underscore
+ @plugin_pretty_name = plugin_name.titleize
+ @plugin_path = "vendor/plugins/#{plugin_name}"
+ super(runtime_args, runtime_options)
+ end
+
+ def destination_root
+ File.join(RAILS_ROOT, plugin_path)
+ end
+end
diff --git a/lib/generators/redmine_plugin_controller/templates/controller.rb b/lib/generators/redmine_plugin_controller/templates/controller.rb
new file mode 100644
index 000000000..615986d9e
--- /dev/null
+++ b/lib/generators/redmine_plugin_controller/templates/controller.rb
@@ -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
new file mode 100644
index 000000000..876bd79e2
--- /dev/null
+++ b/lib/generators/redmine_plugin_controller/templates/functional_test.rb
@@ -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
new file mode 100644
index 000000000..3fe2ecdc7
--- /dev/null
+++ b/lib/generators/redmine_plugin_controller/templates/helper.rb
@@ -0,0 +1,2 @@
+module <%= class_name %>Helper
+end
diff --git a/lib/generators/redmine_plugin_controller/templates/view.html.erb b/lib/generators/redmine_plugin_controller/templates/view.html.erb
new file mode 100644
index 000000000..c24afaa6e
--- /dev/null
+++ b/lib/generators/redmine_plugin_controller/templates/view.html.erb
@@ -0,0 +1 @@
+<h2><%= class_name %>#<%= action %></h2>