Module: ChefDK::Helpers

Instance Method Summary collapse

Instance Method Details

#chefdk_homeObject



78
79
80
81
82
83
84
85
86
87
# File 'lib/chef-dk/helpers.rb', line 78

def chefdk_home
  @chefdk_home ||= begin
                     chefdk_home_set = !([nil, ''].include? ENV['CHEFDK_HOME'])
                     if chefdk_home_set
                       ENV['CHEFDK_HOME']
                     else
                       default_chefdk_home
                     end
                   end
end

#err(message) ⇒ Object



34
35
36
# File 'lib/chef-dk/helpers.rb', line 34

def err(message)
  stderr.print("#{message}\n")
end

#msg(message) ⇒ Object



38
39
40
# File 'lib/chef-dk/helpers.rb', line 38

def msg(message)
  stdout.print("#{message}\n")
end

#omnibus_apps_dirObject



62
63
64
# File 'lib/chef-dk/helpers.rb', line 62

def omnibus_apps_dir
  @ominbus_apps_dir ||= omnibus_expand_path(omnibus_root, "embedded", "apps")
end

#omnibus_bin_dirObject



66
67
68
# File 'lib/chef-dk/helpers.rb', line 66

def omnibus_bin_dir
  @omnibus_bin_dir ||= omnibus_expand_path(omnibus_root, "bin")
end

#omnibus_chefdk_locationObject



74
75
76
# File 'lib/chef-dk/helpers.rb', line 74

def omnibus_chefdk_location
  @omnibus_chefdk_location ||= File.expand_path('embedded/apps/chef-dk', expected_omnibus_root)
end

#omnibus_embedded_bin_dirObject



70
71
72
# File 'lib/chef-dk/helpers.rb', line 70

def omnibus_embedded_bin_dir
  @omnibus_embedded_bin_dir ||= omnibus_expand_path(omnibus_root, "embedded", "bin")
end

#omnibus_install?Boolean

Locates the omnibus directories

Returns:

  • (Boolean)


54
55
56
# File 'lib/chef-dk/helpers.rb', line 54

def omnibus_install?
  File.exist?(omnibus_chefdk_location)
end

#omnibus_rootObject



58
59
60
# File 'lib/chef-dk/helpers.rb', line 58

def omnibus_root
  @omnibus_root ||= omnibus_expand_path(expected_omnibus_root)
end

#stderrObject



46
47
48
# File 'lib/chef-dk/helpers.rb', line 46

def stderr
  $stderr
end

#stdoutObject



42
43
44
# File 'lib/chef-dk/helpers.rb', line 42

def stdout
  $stdout
end

#system_command(*command_args) ⇒ Object

Runs given commands using mixlib-shellout



28
29
30
31
32
# File 'lib/chef-dk/helpers.rb', line 28

def system_command(*command_args)
  cmd = Mixlib::ShellOut.new(*command_args)
  cmd.run_command
  cmd
end