Sha256: 5822dd7589f4658c7a36ca558db4f7275922cbaa9e36c8c500cb0a52b814d8cf
Contents?: true
Size: 500 Bytes
Versions: 30
Compression:
Stored size: 500 Bytes
Contents
# http://www.dzone.com/snippets/generating-yaml-hashes-sorted require 'yaml' class Hash # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) # # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb def to_yaml( opts = {} ) YAML::quick_emit( object_id, opts ) do |out| out.map( taguri, to_yaml_style ) do |map| sort.each do |k, v| # <-- here's my addition (the 'sort') map.add( k, v ) end end end end end
Version data entries
30 entries across 30 versions & 1 rubygems