Class: Rys::Generators::Redmine::PluginGenerator

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

Instance Method Summary collapse

Instance Method Details

#generate_redmine_pluginObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/rys/redmine/plugin_generator.rb', line 14

def generate_redmine_plugin
  target_dir = Rails.root.join('plugins', name)

  if target_dir.directory? && !options[:force]
    error 'Plugin generating failed'
    error "Directory '#{target_dir}' exist"
    exit 1
  end

  gems_target_dir = target_dir.join('gems')
  local_target_dir = target_dir.join('local')

  empty_directory target_dir
  empty_directory gems_target_dir
  empty_directory local_target_dir

  create_file gems_target_dir.join('.keep')
  create_file local_target_dir.join('.keep')

  if gems_rb?
    template 'gems.rb', target_dir.join('gems.rb')
  else
    template 'gems.rb', target_dir.join('Gemfile')
  end

  template '.gitignore', target_dir.join('.gitignore')
  template 'rys.rb', target_dir.join('rys.rb')
end