Class: Hat::Recipes

Inherits:
Object
  • Object
show all
Defined in:
lib/hat/recipes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Recipes



8
9
10
11
# File 'lib/hat/recipes.rb', line 8

def initialize options
  self.url = options['url']
  self.list = options['use'] || []
end

Instance Attribute Details

#listObject

Returns the value of attribute list.



6
7
8
# File 'lib/hat/recipes.rb', line 6

def list
  @list
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/hat/recipes.rb', line 6

def url
  @url
end

Instance Method Details

#dirObject



26
27
28
# File 'lib/hat/recipes.rb', line 26

def dir
  @dir ||= File.join(Dir.tmpdir, repo_name)
end

#downloadObject



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

#gemfileObject



30
31
32
# File 'lib/hat/recipes.rb', line 30

def gemfile
  File.join(dir, 'Gemfile')
end