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


16
17
18
# File 'lib/dice_bag/command.rb', line 16

def self.source_root
  Dir.pwd
end

Instance Method Details

#generate_all_templates(force = false) ⇒ Object


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

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


44
45
46
47
48
# File 'lib/dice_bag/command.rb', line 44

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


40
41
42
# File 'lib/dice_bag/command.rb', line 40

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

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


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

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


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

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