Created
November 5, 2015 09:58
-
-
Save nysalor/c2c50d9c706fa14bb808 to your computer and use it in GitHub Desktop.
yaml stringifier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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