зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Keep compatiblity of Bundler specs
https://github.com/rubygems/rubygems/commit/b211eeacba
This commit is contained in:
Родитель
364c2fea34
Коммит
bf8d8ce1ee
|
@ -461,7 +461,7 @@ module Bundler
|
|||
new_k = k.gsub("-", "___")
|
||||
end
|
||||
|
||||
config[new_k] = v
|
||||
config[new_k] = v.to_s
|
||||
config
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ module Bundler
|
|||
str.split(/\r?\n/).each do |line|
|
||||
if match = HASH_REGEX.match(line)
|
||||
indent, key, quote, val = match.captures
|
||||
key = convert_to_backward_compatible_key(key) if key.match?(/__/)
|
||||
key = convert_to_backward_compatible_key(key)
|
||||
key = key[1..-1].to_sym if key.start_with?(":")
|
||||
depth = indent.scan(/ /).length
|
||||
if quote.empty? && val.empty?
|
||||
|
@ -77,24 +77,9 @@ module Bundler
|
|||
last_hash[last_empty_key].push(convert_to_ruby_value(val))
|
||||
end
|
||||
end
|
||||
deep_transform_values_with_empty_hash!(res)
|
||||
res
|
||||
end
|
||||
|
||||
def deep_transform_values_with_empty_hash!(hash)
|
||||
hash.transform_values! do |v|
|
||||
if v.is_a?(Hash)
|
||||
if v.empty?
|
||||
nil
|
||||
else
|
||||
deep_transform_values_with_empty_hash!(v)
|
||||
end
|
||||
else
|
||||
v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def convert_to_ruby_value(val)
|
||||
if val.match?(/\A:(.*)\Z/)
|
||||
val[1..-1].to_sym
|
||||
|
@ -102,8 +87,6 @@ module Bundler
|
|||
val.to_i
|
||||
elsif val.match?(/\Atrue|false\Z/)
|
||||
val == "true"
|
||||
elsif val.empty?
|
||||
nil
|
||||
else
|
||||
val
|
||||
end
|
||||
|
|
|
@ -352,7 +352,27 @@ if you believe they were disclosed to a third party.
|
|||
|
||||
begin
|
||||
content = Bundler::YAMLSerializer.load(File.read(filename))
|
||||
unless content.is_a? Hash
|
||||
if content.is_a? Hash
|
||||
content.transform_keys! do |k|
|
||||
if k.match?(/__/)
|
||||
if k.is_a?(Symbol)
|
||||
k.to_s.gsub(/__/,".").to_sym
|
||||
else
|
||||
k.dup.gsub(/__/,".")
|
||||
end
|
||||
else
|
||||
k
|
||||
end
|
||||
end
|
||||
|
||||
content.transform_values! do |v|
|
||||
if (v.is_a?(Hash) || v.is_a?(String)) && v.empty?
|
||||
nil
|
||||
else
|
||||
v
|
||||
end
|
||||
end
|
||||
else
|
||||
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
|
||||
return {}
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче