Class: RedmineExtensions::PluginGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/redmine_extensions/plugin/plugin_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PluginGenerator

Returns a new instance of PluginGenerator.



9
10
11
12
13
14
15
16
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 9

def initialize(*args)
  super

  @plugin_name_underscored = options[:customer] ? "modification_#{file_name.underscore}" : file_name.underscore
  @plugin_pretty_name = plugin_name_underscored.titleize
  @plugin_path = "plugins/#{plugin_name_underscored}"
  @plugin_title = @plugin_name_underscored.camelize
end

Instance Attribute Details

#plugin_name_underscoredObject (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_pathObject (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_nameObject (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_titleObject (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

#copy_templatesObject



18
19
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
55
# File 'lib/generators/redmine_extensions/plugin/plugin_generator.rb', line 18

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}/assets/javascripts/.gitkeep"
  template 'gitkeep.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/others/.gitkeep"

  template 'Gemfile.erb', "#{plugin_path}/Gemfile"
  template 'init.rb.erb', "#{plugin_path}/init.rb"
  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