module HeadChef

@TODO: establish head_chef exit codes Create custom errors

Constants

BERKSFILE_COOKBOOK_DIR
BERKSFILE_LOCATION
VERSION

Public Class Methods

berksfile() click to toggle source
# File lib/head_chef.rb, line 53
def berksfile
  @berksfile ||= Berkshelf::Berksfile.from_file(BERKSFILE_LOCATION)
end
chef_server() click to toggle source
# File lib/head_chef.rb, line 32
def chef_server
  @chef_server ||= Ridley.from_chef_config()
end
cleanup() click to toggle source
# File lib/head_chef.rb, line 57
def cleanup
  if Dir.exists?(BERKSFILE_COOKBOOK_DIR)
    FileUtils.rm_rf(BERKSFILE_COOKBOOK_DIR)
  end
end
current_branch() click to toggle source
# File lib/head_chef.rb, line 49
def current_branch
  master_cookbook.head.name
end
master_cookbook() click to toggle source

@TODO: refactor? Is grit necessary to get current branch, is shell command sufficient? This can look up dir's until it finds .git dir

# File lib/head_chef.rb, line 39
def master_cookbook
  begin
    @master_cookbook ||= Grit::Repo.new('.')
  rescue Grit::InvalidGitRepositoryError
    puts Dir.pwd
    HeadChef.ui.error 'head_chef must be run in root of git repo'
    Kernel.exit(1337)
  end
end
root() click to toggle source
# File lib/head_chef.rb, line 24
def root
  @root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
end
ui() click to toggle source
# File lib/head_chef.rb, line 28
def ui
  @ui ||= Thor::Base.shell.new
end