Class: RedminePluginControllerGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- RedminePluginControllerGenerator
- Defined in:
- lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb
Overview
Instance Attribute Summary collapse
-
#plugin_name ⇒ Object
readonly
Returns the value of attribute plugin_name.
-
#plugin_path ⇒ Object
readonly
Returns the value of attribute plugin_path.
-
#plugin_pretty_name ⇒ Object
readonly
Returns the value of attribute plugin_pretty_name.
Instance Method Summary collapse
- #copy_templates ⇒ Object
-
#initialize(*args) ⇒ RedminePluginControllerGenerator
constructor
A new instance of RedminePluginControllerGenerator.
Constructor Details
#initialize(*args) ⇒ RedminePluginControllerGenerator
Returns a new instance of RedminePluginControllerGenerator
8 9 10 11 12 13 14 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 8 def initialize(*args) super @plugin_name = file_name.underscore @plugin_pretty_name = plugin_name.titleize @plugin_path = "plugins/#{plugin_name}" @controller_class = controller.camelize end |
Instance Attribute Details
#plugin_name ⇒ Object (readonly)
Returns the value of attribute plugin_name
6 7 8 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 6 def plugin_name @plugin_name end |
#plugin_path ⇒ Object (readonly)
Returns the value of attribute plugin_path
6 7 8 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 6 def plugin_path @plugin_path end |
#plugin_pretty_name ⇒ Object (readonly)
Returns the value of attribute plugin_pretty_name
6 7 8 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 6 def plugin_pretty_name @plugin_pretty_name end |
Instance Method Details
#copy_templates ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 16 def copy_templates template 'controller.rb.erb', "#{plugin_path}/app/controllers/#{controller}_controller.rb" template 'helper.rb.erb', "#{plugin_path}/app/helpers/#{controller}_helper.rb" template 'functional_test.rb.erb', "#{plugin_path}/test/functional/#{controller}_controller_test.rb" # View template for each action. actions.each do |action| path = "#{plugin_path}/app/views/#{controller}/#{action}.html.erb" @action_name = action template 'view.html.erb', path end end |