Skip to content

Commit

Permalink
[rubygems/rubygems] Replaced empty hash to nil value in YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt authored and matzbot committed Apr 19, 2023
1 parent 7e537e9 commit 364c2fe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/bundler/yaml_serializer.rb
Expand Up @@ -77,9 +77,24 @@ def load(str)
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
Expand Down

0 comments on commit 364c2fe

Please sign in to comment.