Module: YAML
- Defined in:
- lib/knut_tools/yaml.rb
Overview
Extend YAML with some features:
-
YAML.load_with_warning Warn if a hash with double key is loaded.
-
Hash#to_yaml Sorted output
Class Method Summary collapse
-
.load_with_warning(data) ⇒ Object
Load, but warn, if a Hash key was added before.
Class Method Details
.load_with_warning(data) ⇒ Object
Load, but warn, if a Hash key was added before.
Works only on first level of hashs.
23 24 25 26 27 28 29 30 31 |
# File 'lib/knut_tools/yaml.rb', line 23 def self.load_with_warning( data ) keys = [] doc = parse(data) doc.value.each {|key, value| puts "!YAML.load: Double Hash-key: #{key.value}" if keys.include?(key.value) keys << key.value } doc.transform end |