Simplify rendering of environment variables.

This commit is contained in:
Markus Reiter 2017-02-04 21:53:35 +01:00
parent 46e051b1c2
commit d8eab8c211

View File

@ -7,25 +7,28 @@ module Hbc
ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom) ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom)
ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads
ohai "Homebrew-Cask Taps:" ohai "Homebrew-Cask Taps:"
puts render_taps(Hbc.default_tap) puts render_taps(Hbc.default_tap, *alt_taps)
puts render_taps(*alt_taps)
ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH) ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH)
ohai "Environment Variables:" ohai "Environment Variables:"
render_env_var("RUBYLIB")
render_env_var("RUBYOPT") environment_variables = [
render_env_var("RUBYPATH") "RUBYLIB",
render_env_var("RBENV_VERSION") "RUBYOPT",
render_env_var("CHRUBY_VERSION") "RUBYPATH",
render_env_var("GEM_HOME") "RBENV_VERSION",
render_env_var("GEM_PATH") "CHRUBY_VERSION",
render_env_var("BUNDLE_PATH") "GEM_HOME",
render_env_var("PATH") "GEM_PATH",
render_env_var("SHELL") "BUNDLE_PATH",
locale_variables "PATH",
"SHELL",
]
(locale_variables + environment_variables).sort.each(&method(:render_env_var))
end end
def self.locale_variables def self.locale_variables
ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort.each(&method(:render_env_var)) ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort
end end
def self.none_string def self.none_string
@ -63,10 +66,9 @@ module Hbc
end end
def self.render_env_var(var) def self.render_env_var(var)
if ENV.key?(var) return unless ENV.key?(var)
var = %Q(#{var}="#{ENV[var]}") var = %Q(#{var}="#{ENV[var]}")
puts user_tilde(var) puts user_tilde(var)
end
end end
def self.user_tilde(path) def self.user_tilde(path)