Class: Hat::Recipes
- Inherits:
-
Object
- Object
- Hat::Recipes
- Defined in:
- lib/hat/recipes.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #dir ⇒ Object
- #download ⇒ Object
- #gemfile ⇒ Object
-
#initialize(options) ⇒ Recipes
constructor
A new instance of Recipes.
Constructor Details
#initialize(options) ⇒ Recipes
8 9 10 11 |
# File 'lib/hat/recipes.rb', line 8 def initialize self.url = ['url'] self.list = ['use'] || [] end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
6 7 8 |
# File 'lib/hat/recipes.rb', line 6 def list @list end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/hat/recipes.rb', line 6 def url @url end |
Instance Method Details
#dir ⇒ Object
26 27 28 |
# File 'lib/hat/recipes.rb', line 26 def dir @dir ||= File.join(Dir.tmpdir, repo_name) end |
#download ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hat/recipes.rb', line 13 def download if File.directory?(url) FileUtils.rm_rf(dir) if File.directory?(dir) FileUtils.cp_r(url, Dir.tmpdir) else if File.directory?(dir) Git.open(dir).pull else Git.clone(url, repo_name, path: Dir.tmpdir) end end end |
#gemfile ⇒ Object
30 31 32 |
# File 'lib/hat/recipes.rb', line 30 def gemfile File.join(dir, 'Gemfile') end |