class ChefCLI::Command::Env

Attributes

ui[RW]

Public Class Methods

new(*args) click to toggle source
Calls superclass method ChefCLI::Command::Base::new
# File lib/chef-cli/command/env.rb, line 36
def initialize(*args)
  super
  @ui = UI.new
end

Public Instance Methods

gem_environment() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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