annotate .svn/pristine/3e/3e339092f343524c6085cf1a81f2c664a0ae64ee.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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