annotate .svn/pristine/3e/3e339092f343524c6085cf1a81f2c664a0ae64ee.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
rev   line source
Chris@1295 1 class RedminePluginControllerGenerator < Rails::Generators::NamedBase
Chris@1295 2 source_root File.expand_path("../templates", __FILE__)
Chris@1295 3 argument :controller, :type => :string
Chris@1295 4 argument :actions, :type => :array, :default => [], :banner => "ACTION ACTION ..."
Chris@1295 5
Chris@1295 6 attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
Chris@1295 7
Chris@1295 8 def initialize(*args)
Chris@1295 9 super
Chris@1295 10 @plugin_name = file_name.underscore
Chris@1295 11 @plugin_pretty_name = plugin_name.titleize
Chris@1295 12 @plugin_path = "plugins/#{plugin_name}"
Chris@1295 13 @controller_class = controller.camelize
Chris@1295 14 end
Chris@1295 15
Chris@1295 16 def copy_templates
Chris@1295 17 template 'controller.rb.erb', "#{plugin_path}/app/controllers/#{controller}_controller.rb"
Chris@1295 18 template 'helper.rb.erb', "#{plugin_path}/app/helpers/#{controller}_helper.rb"
Chris@1295 19 template 'functional_test.rb.erb', "#{plugin_path}/test/functional/#{controller}_controller_test.rb"
Chris@1295 20 # View template for each action.
Chris@1295 21 actions.each do |action|
Chris@1295 22 path = "#{plugin_path}/app/views/#{controller}/#{action}.html.erb"
Chris@1295 23 @action_name = action
Chris@1295 24 template 'view.html.erb', path
Chris@1295 25 end
Chris@1295 26 end
Chris@1295 27 end