Class: DiceBag::Command

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions, Thor::Base
Defined in:
lib/dice_bag/command.rb

Overview

This class seems a candidate to be converted to Thor, the problem is that we need to run in the same process than the rake task so all the gems are loaded before dice_bag is called and dice_bag can find what software is used in this project

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



18
19
20
# File 'lib/dice_bag/command.rb', line 18

def self.source_root
  Dir.pwd
end

Instance Method Details

#generate_all_templates(force = false) ⇒ Object



36
37
38
39
40
# File 'lib/dice_bag/command.rb', line 36

def generate_all_templates(force = false)
  AvailableTemplates.all.each do |template|
    generate_template(template, force)
  end
end

#generate_gems_templates(gem_names, force = false) ⇒ Object



46
47
48
49
50
# File 'lib/dice_bag/command.rb', line 46

def generate_gems_templates(gem_names, force = false)
  AvailableTemplates.all(gem_names).each do |template|
    generate_template(template, force)
  end
end

#generate_template(default_template, force = false) ⇒ Object



42
43
44
# File 'lib/dice_bag/command.rb', line 42

def generate_template(default_template, force = false)
  copy_file default_template.file, default_template.destination, force: force
end

#write(template_name, params = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/dice_bag/command.rb', line 28

def write(template_name, params = {})
  template_file = TemplateFile.new(template_name)
  template_file.assert_existence
  config_file = ConfigFile.new(template_name)

  template_file.create_file(config_file, params)
end

#write_all(params = {}) ⇒ Object



22
23
24
25
26
# File 'lib/dice_bag/command.rb', line 22

def write_all(params = {})
  Project.templates_to_generate.each do |template|
    write(template, params)
  end
end