Class: Redmine::Generators::PluginGenerator

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

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ PluginGenerator

Returns a new instance of PluginGenerator.



51
52
53
54
55
56
57
58
# File 'lib/redmine/generators/plugin_generator.rb', line 51

def initialize(args = [], options = {}, config = {})
  args[0] = ideal_plugin_name(args[0]) if config[:behavior] == :invoke
  super args, options, config
  if ideal_plugin_path.exist? && behavior == :invoke
    raise "Plugin #{name} already exists." 
  end
  self.destination_root = ideal_plugin_path
end

Instance Method Details

#app_foldersObject



39
40
41
42
43
44
45
# File 'lib/redmine/generators/plugin_generator.rb', line 39

def app_folders
  empty_directory "app"
  empty_directory_with_gitkeep "app/models"
  empty_directory_with_gitkeep "app/controllers"
  empty_directory_with_gitkeep "app/helpers"
  empty_directory_with_gitkeep "app/views"
end

#configObject



16
17
18
# File 'lib/redmine/generators/plugin_generator.rb', line 16

def config
  empty_directory "config"
end

#create_rootObject



8
9
10
# File 'lib/redmine/generators/plugin_generator.rb', line 8

def create_root
  empty_directory '.'
end

#gemfileObject



47
48
49
# File 'lib/redmine/generators/plugin_generator.rb', line 47

def gemfile
  template "Gemfile"
end

#init_rbObject



12
13
14
# File 'lib/redmine/generators/plugin_generator.rb', line 12

def init_rb
  template "init.rb"
end

#localesObject



24
25
26
# File 'lib/redmine/generators/plugin_generator.rb', line 24

def locales
  empty_directory "config/locales"
end

#plugin_libObject



32
33
34
35
36
37
# File 'lib/redmine/generators/plugin_generator.rb', line 32

def plugin_lib
  empty_directory "lib"
  empty_directory "lib/#{name}"
  template "plugin.rb", "lib/#{name}.rb"
  template "version.rb", "lib/#{name}/version.rb"
end

#routesObject



20
21
22
# File 'lib/redmine/generators/plugin_generator.rb', line 20

def routes
  template "routes.rb", "config/routes.rb"
end

#translationsObject



28
29
30
# File 'lib/redmine/generators/plugin_generator.rb', line 28

def translations
  template "en.yml", "config/locales/en.yml"
end