Class: RedminePluginGenerator

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

Overview

Redmine - project management software Copyright © 2006-2022 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RedminePluginGenerator

Returns a new instance of RedminePluginGenerator.



25
26
27
28
29
30
# File 'lib/generators/redmine_plugin/redmine_plugin_generator.rb', line 25

def initialize(*args)
  super
  @plugin_name = file_name.underscore
  @plugin_pretty_name = plugin_name.titleize
  @plugin_path = File.join(Redmine::Plugin.directory, plugin_name)
end

Instance Attribute Details

#plugin_nameObject (readonly)

Returns the value of attribute plugin_name.



23
24
25
# File 'lib/generators/redmine_plugin/redmine_plugin_generator.rb', line 23

def plugin_name
  @plugin_name
end

#plugin_pathObject (readonly)

Returns the value of attribute plugin_path.



23
24
25
# File 'lib/generators/redmine_plugin/redmine_plugin_generator.rb', line 23

def plugin_path
  @plugin_path
end

#plugin_pretty_nameObject (readonly)

Returns the value of attribute plugin_pretty_name.



23
24
25
# File 'lib/generators/redmine_plugin/redmine_plugin_generator.rb', line 23

def plugin_pretty_name
  @plugin_pretty_name
end

Instance Method Details

#copy_templatesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/generators/redmine_plugin/redmine_plugin_generator.rb', line 32

def copy_templates
  empty_directory "#{plugin_path}/app"
  empty_directory "#{plugin_path}/app/controllers"
  empty_directory "#{plugin_path}/app/helpers"
  empty_directory "#{plugin_path}/app/models"
  empty_directory "#{plugin_path}/app/views"
  empty_directory "#{plugin_path}/db/migrate"
  empty_directory "#{plugin_path}/lib/tasks"
  empty_directory "#{plugin_path}/assets/images"
  empty_directory "#{plugin_path}/assets/javascripts"
  empty_directory "#{plugin_path}/assets/stylesheets"
  empty_directory "#{plugin_path}/config/locales"
  empty_directory "#{plugin_path}/test"
  empty_directory "#{plugin_path}/test/fixtures"
  empty_directory "#{plugin_path}/test/unit"
  empty_directory "#{plugin_path}/test/functional"
  empty_directory "#{plugin_path}/test/integration"
  empty_directory "#{plugin_path}/test/system"

  template 'README.rdoc',    "#{plugin_path}/README.rdoc"
  template 'init.rb.erb',   "#{plugin_path}/init.rb"
  template 'routes.rb',    "#{plugin_path}/config/routes.rb"
  template 'en_rails_i18n.yml',    "#{plugin_path}/config/locales/en.yml"
  template 'test_helper.rb.erb',    "#{plugin_path}/test/test_helper.rb"
end