Class: MoveToGo::Templating
- Inherits:
-
Object
- Object
- MoveToGo::Templating
- Defined in:
- lib/move-to-go/templating.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ Templating
constructor
A new instance of Templating.
- #list ⇒ Object
- #unpack(name, path) ⇒ Object
Constructor Details
#initialize(path) ⇒ Templating
Returns a new instance of Templating.
5 6 7 |
# File 'lib/move-to-go/templating.rb', line 5 def initialize(path) @path = path end |
Instance Method Details
#list ⇒ Object
9 10 11 |
# File 'lib/move-to-go/templating.rb', line 9 def list() Dir.entries(@path).select { |d| d != '.' && d != '..' } end |
#unpack(name, path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/move-to-go/templating.rb', line 13 def unpack(name, path) template = list.find { |t| t == name } if template unpackedname = name puts "Unpacking template #{name} to #{path}" FileUtils.cp_r File.(name, @path), path # Now make sure all gems in template are installed puts "Making sure all needed gems are present" Dir.chdir(File.(unpackedname, path)) do exec_but_dont_show_unless_error('bundle install --verbose') end true else puts "Unable to find template #{name}" false end end |