Skip to content

Instantly share code, notes, and snippets.

@nysalor
Created November 5, 2015 09:58
Show Gist options
  • Save nysalor/c2c50d9c706fa14bb808 to your computer and use it in GitHub Desktop.
Save nysalor/c2c50d9c706fa14bb808 to your computer and use it in GitHub Desktop.
yaml stringifier
require 'yaml'
def stringify(hash, prefix = nil)
hash.map { |k, v|
scope = prefix ? "#{prefix}.#{k}" : k
if v.is_a?(Hash)
stringify v, scope
else
"#{scope}: #{v}"
end
}.flatten
end
filename = ARGV[0]
yaml = YAML.load_file filename
stringify(yaml).sort.each do |x|
puts x
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment