Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Gem::YAMLSerializer#dump_hash
dump_hash(hash)
lib/rubygems/yaml_serializer.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/rubygems/yaml_serializer.rb, line 13
def dump_hash(hash)
yaml = String.new("\n")
hash.each do |k, v|
yaml << k << ":"
if v.is_a?(Hash)
yaml << dump_hash(v).gsub(/^(?!$)/, " ") # indent all non-empty lines
elsif v.is_a?(Array) # Expected to be array of strings
if v.empty?
yaml << " []\n"
else
yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
end
else
yaml << " " << v.to_s.gsub(/\s+/, " ").inspect << "\n"
end
end
yaml
end
No documentation available