summaryrefslogtreecommitdiff
path: root/lib/rubygems/config_file.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/config_file.rb')
-rw-r--r--lib/rubygems/config_file.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 7874ad0dc9..a2bcb6dfbc 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -522,12 +522,12 @@ if you believe they were disclosed to a third party.
# Return the configuration information for +key+.
def [](key)
- @hash[key.to_s]
+ @hash[key] || @hash[key.to_s]
end
# Set configuration option +key+ to +value+.
def []=(key, value)
- @hash[key.to_s] = value
+ @hash[key] = value
end
def ==(other) # :nodoc:
@@ -555,8 +555,13 @@ if you believe they were disclosed to a third party.
require_relative "yaml_serializer"
content = Gem::YAMLSerializer.load(yaml)
+ deep_transform_config_keys!(content)
+ end
- content.transform_keys! do |k|
+ private
+
+ def self.deep_transform_config_keys!(config)
+ config.transform_keys! do |k|
if k.match?(/\A:(.*)\Z/)
k[1..-1].to_sym
elsif k.include?("__") || k.match?(%r{/\Z})
@@ -570,7 +575,7 @@ if you believe they were disclosed to a third party.
end
end
- content.transform_values! do |v|
+ config.transform_values! do |v|
if v.is_a?(String)
if v.match?(/\A:(.*)\Z/)
v[1..-1].to_sym
@@ -583,18 +588,18 @@ if you believe they were disclosed to a third party.
else
v
end
- elsif v.is_a?(Hash) && v.empty?
+ elsif v.empty?
nil
+ elsif v.is_a?(Hash)
+ deep_transform_config_keys!(v)
else
v
end
end
- content
+ config
end
- private
-
def set_config_file_name(args)
@config_file_name = ENV["GEMRC"]
need_config_file_name = false