Class: DiceBag::Command

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Method Details

#generate_all_templatesObject


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

def generate_all_templates
  AvailableTemplates.all.each do |template|
    generate_template(template)
  end
end

#generate_template(default_template) ⇒ Object


34
35
36
37
# File 'lib/dice_bag/command.rb', line 34

def generate_template(default_template)
  default_template.assert_existence
  default_template.create_file
end

#write(template_name) ⇒ Object


19
20
21
22
23
24
25
# File 'lib/dice_bag/command.rb', line 19

def write(template_name)
  template_file = TemplateFile.new(template_name)
  template_file.assert_existence
  config_file = ConfigFile.new(template_name)

  template_file.create_file(config_file)
end

#write_allObject


13
14
15
16
17
# File 'lib/dice_bag/command.rb', line 13

def write_all
  Project.templates_to_generate.each do |template|
    write(template)
  end
end