Class: RedminePluginControllerGenerator
- Inherits:
-
ControllerGenerator
- Object
- ControllerGenerator
- RedminePluginControllerGenerator
- Defined in:
- lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb
Instance Attribute Summary
-
- (Object) plugin_name
readonly
Returns the value of attribute plugin_name.
-
- (Object) plugin_path
readonly
Returns the value of attribute plugin_path.
-
- (Object) plugin_pretty_name
readonly
Returns the value of attribute plugin_pretty_name.
Instance Method Summary
- - (Object) destination_root
-
- (RedminePluginControllerGenerator) initialize(runtime_args, runtime_options = {})
constructor
A new instance of RedminePluginControllerGenerator.
- - (Object) manifest
Constructor Details
- (RedminePluginControllerGenerator) initialize(runtime_args, runtime_options = {})
A new instance of RedminePluginControllerGenerator
7 8 9 10 11 12 13 14 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 7 def initialize(runtime_args, = {}) runtime_args = runtime_args.dup usage if runtime_args.empty? @plugin_name = "redmine_" + runtime_args.shift.underscore @plugin_pretty_name = plugin_name.titleize @plugin_path = "vendor/plugins/#{plugin_name}" super(runtime_args, ) end |
Instance Attribute Details
- (Object) plugin_name (readonly)
Returns the value of attribute plugin_name
5 6 7 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 5 def plugin_name @plugin_name end |
- (Object) plugin_path (readonly)
Returns the value of attribute plugin_path
5 6 7 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 5 def plugin_path @plugin_path end |
- (Object) plugin_pretty_name (readonly)
Returns the value of attribute plugin_pretty_name
5 6 7 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 5 def plugin_pretty_name @plugin_pretty_name end |
Instance Method Details
- (Object) destination_root
16 17 18 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 16 def destination_root File.join(RAILS_ROOT, plugin_path) end |
- (Object) manifest
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb', line 20 def manifest record do |m| # Check for class naming collisions. m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper" # Controller, helper, views, and test directories. m.directory File.join('app/controllers', class_path) m.directory File.join('app/helpers', class_path) m.directory File.join('app/views', class_path, file_name) m.directory File.join('test/functional', class_path) # Controller class, functional test, and helper class. m.template 'controller.rb.erb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") m.template 'functional_test.rb.erb', File.join('test/functional', class_path, "#{file_name}_controller_test.rb") m.template 'helper.rb.erb', File.join('app/helpers', class_path, "#{file_name}_helper.rb") # View template for each action. actions.each do |action| path = File.join('app/views', class_path, file_name, "#{action}.html.erb") m.template 'view.html.erb', path, :assigns => { :action => action, :path => path } end end end |