module ChefUtils::DSL::DefaultPaths

Public Instance Methods

default_paths(env = nil) click to toggle source

@since 15.5

# File lib/chef-utils/dsl/default_paths.rb, line 28
def default_paths(env = nil)
  env_path = env ? env["PATH"] : __env_path
  env_path = "" if env_path.nil?
  path_separator = ChefUtils.windows? ? ";" : ":"
  # ensure the Ruby and Gem bindirs are included for omnibus chef installs
  new_paths = env_path.split(path_separator)
  [ __ruby_bindir, __gem_bindir ].compact.each do |path|
    new_paths = [ path ] + new_paths unless new_paths.include?(path)
  end
  __default_paths.each do |path|
    new_paths << path unless new_paths.include?(path)
  end
  new_paths.join(path_separator).encode("utf-8", invalid: :replace, undef: :replace)
end

Private Instance Methods

__default_paths() click to toggle source
# File lib/chef-utils/dsl/default_paths.rb, line 45
def __default_paths
  ChefUtils.windows? ? %w{} : %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}
end
__gem_bindir() click to toggle source
# File lib/chef-utils/dsl/default_paths.rb, line 53
def __gem_bindir
  Gem.bindir
end
__ruby_bindir() click to toggle source
# File lib/chef-utils/dsl/default_paths.rb, line 49
def __ruby_bindir
  RbConfig::CONFIG["bindir"]
end