diff options
-rw-r--r-- | lib/bundler/settings.rb | 28 | ||||
-rw-r--r-- | spec/bundler/settings_spec.rb | 10 |
2 files changed, 26 insertions, 12 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 7339f721ad..1898738b7c 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -62,15 +62,7 @@ module Bundler nil end end end end end - if value.nil? - nil - elsif is_bool(name) || value == "false" - to_bool(value) - elsif is_num(name) - value.to_i - else - value - end + converted_value(value, name) end def []=(key, value) @@ -160,15 +152,15 @@ module Bundler locations = [] if @local_config.key?(key) - locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}" + locations << "Set for your local app (#{local_config_file}): #{converted_value(@local_config[key], exposed_key).inspect}" end if value = ENV[key] - locations << "Set via #{key}: #{value.inspect}" + locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}" end if @global_config.key?(key) - locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}" + locations << "Set for the current user (#{global_config_file}): #{converted_value(@global_config[key], exposed_key).inspect}" end return ["You have not configured a value for `#{exposed_key}`"] if locations.empty? @@ -281,6 +273,18 @@ module Bundler value end + def converted_value(value, key) + if value.nil? + nil + elsif is_bool(key) || value == "false" + to_bool(value) + elsif is_num(key) + value.to_i + else + value + end + end + def global_config_file if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty? Pathname.new(ENV["BUNDLE_CONFIG"]) diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index 020897882c..7302da5421 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -151,6 +151,16 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end end + describe "#pretty_values_for" do + it "prints the converted value rather than the raw string" do + bool_key = described_class::BOOL_KEYS.first + settings[bool_key] = false + expect(subject.pretty_values_for(bool_key)).to eq [ + "Set for your local app (#{bundled_app("config")}): false", + ] + end + end + describe "#mirror_for" do let(:uri) { URI("https://rubygems.org/") } |