diff --git a/hooks/lib/generators/redmine_plugin/redmine_plugin_generator.rb b/hooks/lib/generators/redmine_plugin/redmine_plugin_generator.rb index 67f1f0933..2a7319f7b 100644 --- a/hooks/lib/generators/redmine_plugin/redmine_plugin_generator.rb +++ b/hooks/lib/generators/redmine_plugin/redmine_plugin_generator.rb @@ -1,20 +1,3 @@ -# redMine - project management software -# Copyright (C) 2006-2008 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - class RedminePluginGenerator < Rails::Generator::NamedBase attr_reader :plugin_path, :plugin_name, :plugin_pretty_name diff --git a/hooks/lib/generators/redmine_plugin_controller/USAGE b/hooks/lib/generators/redmine_plugin_controller/USAGE new file mode 100644 index 000000000..8336e7117 --- /dev/null +++ b/hooks/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/hooks/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb b/hooks/lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb new file mode 100644 index 000000000..533d65ce8 --- /dev/null +++ b/hooks/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/hooks/lib/generators/redmine_plugin_controller/templates/controller.rb b/hooks/lib/generators/redmine_plugin_controller/templates/controller.rb new file mode 100644 index 000000000..615986d9e --- /dev/null +++ b/hooks/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/hooks/lib/generators/redmine_plugin_controller/templates/functional_test.rb b/hooks/lib/generators/redmine_plugin_controller/templates/functional_test.rb new file mode 100644 index 000000000..38e0ae712 --- /dev/null +++ b/hooks/lib/generators/redmine_plugin_controller/templates/functional_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class <%= class_name %>ControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/hooks/lib/generators/redmine_plugin_controller/templates/helper.rb b/hooks/lib/generators/redmine_plugin_controller/templates/helper.rb new file mode 100644 index 000000000..3fe2ecdc7 --- /dev/null +++ b/hooks/lib/generators/redmine_plugin_controller/templates/helper.rb @@ -0,0 +1,2 @@ +module <%= class_name %>Helper +end diff --git a/hooks/lib/generators/redmine_plugin_controller/templates/view.html.erb b/hooks/lib/generators/redmine_plugin_controller/templates/view.html.erb new file mode 100644 index 000000000..c24afaa6e --- /dev/null +++ b/hooks/lib/generators/redmine_plugin_controller/templates/view.html.erb @@ -0,0 +1 @@ +