class Hat::Recipes

Attributes

list[RW]
url[RW]

Public Class Methods

new(options) click to toggle source
# File lib/hat/recipes.rb, line 8
def initialize options
  self.url = options['url']
  self.list = options['use'] || []
end

Public Instance Methods

dir() click to toggle source
# File lib/hat/recipes.rb, line 26
def dir
  @dir ||= File.join(Dir.tmpdir, repo_name)
end
download() click to toggle source
# 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() click to toggle source
# File lib/hat/recipes.rb, line 30
def gemfile
  File.join(dir, 'Gemfile')
end

Private Instance Methods

repo_name() click to toggle source
# File lib/hat/recipes.rb, line 36
def repo_name
  @repo_name ||= File.basename(url, ".git")
end