Class: RedmineExtensions::PluginGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- RedmineExtensions::PluginGenerator
- Defined in:
- lib/generators/redmine_extensions/plugin/plugin_generator.rb
Instance Attribute Summary collapse
-
#easy_plugin ⇒ Object
readonly
Returns the value of attribute easy_plugin.
-
#plugin_name_underscored ⇒ Object
readonly
Returns the value of attribute plugin_name_underscored.
-
#plugin_path ⇒ Object
readonly
Returns the value of attribute plugin_path.
-
#plugin_pretty_name ⇒ Object
readonly
Returns the value of attribute plugin_pretty_name.
-
#plugin_title ⇒ Object
readonly
Returns the value of attribute plugin_title.
Instance Method Summary collapse
- #check_existing_const ⇒ Object
- #copy_templates ⇒ Object
-
#initialize(*args) ⇒ PluginGenerator
constructor
A new instance of PluginGenerator.
Constructor Details
#initialize(*args) ⇒ PluginGenerator
Returns a new instance of PluginGenerator.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 10 def initialize(*args) super @easy_plugin = [:easy_plugin] @plugin_name_underscored = [:customer] ? "modification_#{file_name.underscore}" : file_name.underscore @plugin_pretty_name = plugin_name_underscored.titleize @plugin_path = (easy_plugin ? "plugins/easyproject/easy_plugins" : "plugins") + "/#{plugin_name_underscored}" @plugin_title = @plugin_name_underscored.camelize check_existing_const end |
Instance Attribute Details
#easy_plugin ⇒ Object (readonly)
Returns the value of attribute easy_plugin.
5 6 7 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 5 def easy_plugin @easy_plugin end |
#plugin_name_underscored ⇒ Object (readonly)
Returns the value of attribute plugin_name_underscored.
5 6 7 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 5 def plugin_name_underscored @plugin_name_underscored end |
#plugin_path ⇒ Object (readonly)
Returns the value of attribute plugin_path.
5 6 7 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 5 def plugin_path @plugin_path end |
#plugin_pretty_name ⇒ Object (readonly)
Returns the value of attribute plugin_pretty_name.
5 6 7 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 5 def plugin_pretty_name @plugin_pretty_name end |
#plugin_title ⇒ Object (readonly)
Returns the value of attribute plugin_title.
5 6 7 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 5 def plugin_title @plugin_title end |
Instance Method Details
#check_existing_const ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 21 def check_existing_const begin @plugin_title.constantize raise I18n.t(:error_plugin_name_is_used, plugin_name: @plugin_title) rescue LoadError, NameError # OK end end |
#copy_templates ⇒ Object
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 30 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}/db/data" 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}/lib/#{plugin_name_underscored}" empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/controllers" empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/helpers" empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/models" empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/others" template 'gitkeep.erb', "#{plugin_path}/app/controllers/.gitkeep" template 'gitkeep.erb', "#{plugin_path}/app/helpers/.gitkeep" template 'gitkeep.erb', "#{plugin_path}/app/models/.gitkeep" template 'gitkeep.erb', "#{plugin_path}/app/views/.gitkeep" template 'gitkeep.erb', "#{plugin_path}/db/migrate/.gitkeep" template 'gitkeep.erb', "#{plugin_path}/assets/images/.gitkeep" template 'gitkeep.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/others/.gitkeep" template 'after_init.rb.erb', "#{plugin_path}/after_init.rb" template 'Gemfile.erb', "#{plugin_path}/Gemfile" unless easy_plugin template 'init.rb.erb', "#{plugin_path}/init.rb" template 'javascript.js', "#{plugin_path}/assets/javascripts/#{plugin_name_underscored}.js" template 'stylesheet.css', "#{plugin_path}/assets/stylesheets/#{plugin_name_underscored}.css" template 'en.yml.erb', "#{plugin_path}/config/locales/en.yml" template 'routes.rb.erb', "#{plugin_path}/config/routes.rb" template 'hooks.rb.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/hooks.rb" template 'internals.rb.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/internals.rb" template 'issue_patch.example.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/models/issue_patch.example" template 'issues_controller_patch.example.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/controllers/issues_controller_patch.example" template 'issues_helper_patch.example.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/helpers/issues_helper_patch.example" end |