Class: RedminePluginControllerGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = File.join(Redmine::Plugin.directory, plugin_name)
  @controller_class = controller.camelize
end

Instance Attribute Details

#plugin_nameObject (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_pathObject (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_nameObject (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_templatesObject



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