Class: ChefCLI::Command::Env
- Inherits:
-
Base
- Object
- Base
- ChefCLI::Command::Env
show all
- Defined in:
- lib/chef-cli/command/env.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#check_license_acceptance, #needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_expand_path, #omnibus_install?, #omnibus_root, #package_home, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ Env
Returns a new instance of Env.
36
37
38
39
|
# File 'lib/chef-cli/command/env.rb', line 36
def initialize(*args)
super
@ui = UI.new
end
|
Instance Attribute Details
#ui ⇒ Object
Returns the value of attribute ui.
34
35
36
|
# File 'lib/chef-cli/command/env.rb', line 34
def ui
@ui
end
|
Instance Method Details
#gem_environment ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/chef-cli/command/env.rb', line 74
def gem_environment
h = {}
h["GEM ROOT"] = omnibus_env["GEM_ROOT"]
h["GEM HOME"] = omnibus_env["GEM_HOME"]
h["GEM PATHS"] = omnibus_env["GEM_PATH"].split(File::PATH_SEPARATOR)
rescue OmnibusInstallNotFound
h["GEM_ROOT"] = ENV["GEM_ROOT"] if ENV.key?("GEM_ROOT")
h["GEM_HOME"] = ENV["GEM_HOME"] if ENV.key?("GEM_HOME")
h["GEM PATHS"] = ENV["GEM_PATH"].split(File::PATH_SEPARATOR) if ENV.key?("GEM_PATH") && !ENV.key?("GEM_PATH").nil?
ensure
h
end
|
#paths ⇒ Object
87
88
89
90
91
|
# File 'lib/chef-cli/command/env.rb', line 87
def paths
omnibus_env["PATH"].split(File::PATH_SEPARATOR)
rescue OmnibusInstallNotFound
ENV["PATH"].split(File::PATH_SEPARATOR)
end
|
#policyfile_config ⇒ Object
93
94
95
96
97
98
|
# File 'lib/chef-cli/command/env.rb', line 93
def policyfile_config
{}.tap do |h|
h["Cache Path"] = CookbookOmnifetch.cache_path
h["Storage Path"] = CookbookOmnifetch.storage_path.to_s
end
end
|
#ruby_info ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/chef-cli/command/env.rb', line 62
def ruby_info
{}.tap do |ruby|
ruby["Executable"] = Gem.ruby
ruby["Version"] = RUBY_VERSION
ruby["RubyGems"] = {}.tap do |rubygems|
rubygems["RubyGems Version"] = Gem::VERSION
rubygems["RubyGems Platforms"] = Gem.platforms.map(&:to_s)
rubygems["Gem Environment"] = gem_environment
end
end
end
|
#run(params) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/chef-cli/command/env.rb', line 41
def run(params)
info = {}
info[ChefCLI::Dist::PRODUCT] = workstation_info
info["Ruby"] = ruby_info
info["Path"] = paths
ui.msg YAML.dump(info)
end
|
#workstation_info ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/chef-cli/command/env.rb', line 49
def workstation_info
info = {}
if omnibus_install?
info["Version"] = ChefCLI::VERSION
info["Home"] = package_home
info["Install Directory"] = omnibus_root
info["Policyfile Config"] = policyfile_config
else
info["Version"] = "Not running from within Workstation"
end
info
end
|