Module: HeadChef

Defined in:
lib/head_chef.rb,
lib/head_chef/ui.rb,
lib/head_chef/cli.rb,
lib/head_chef/version.rb,
lib/head_chef/cookbook.rb,
lib/head_chef/tasks/env.rb,
lib/head_chef/tasks/diff.rb,
lib/head_chef/tasks/list.rb,
lib/head_chef/tasks/sync.rb,
lib/head_chef/cookbook_diff.rb

Overview

@TODO: establish head_chef exit codes Create custom errors

Defined Under Namespace

Modules: UI Classes: Cli, Cookbook, CookbookDiff, Diff, Env, List, Sync

Constant Summary collapse

BERKSFILE_LOCATION =
'Berksfile'.freeze
BERKSFILE_COOKBOOK_DIR =
'.head_chef'.freeze
VERSION =
'0.1.1'

Class Method Summary collapse

Class Method Details

.berksfileObject



53
54
55
# File 'lib/head_chef.rb', line 53

def berksfile
  @berksfile ||= Berkshelf::Berksfile.from_file(BERKSFILE_LOCATION)
end

.chef_serverObject



32
33
34
# File 'lib/head_chef.rb', line 32

def chef_server
  @chef_server ||= Ridley.from_chef_config()
end

.cleanupObject



57
58
59
60
61
# File 'lib/head_chef.rb', line 57

def cleanup
  if Dir.exists?(BERKSFILE_COOKBOOK_DIR)
    FileUtils.rm_rf(BERKSFILE_COOKBOOK_DIR)
  end
end

.current_branchObject



49
50
51
# File 'lib/head_chef.rb', line 49

def current_branch
  master_cookbook.head.name
end

.master_cookbookObject

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



39
40
41
42
43
44
45
46
47
# 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

.rootObject



24
25
26
# File 'lib/head_chef.rb', line 24

def root
  @root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
end

.uiObject



28
29
30
# File 'lib/head_chef.rb', line 28

def ui
  @ui ||= Thor::Base.shell.new
end