Created
January 29, 2012 06:25
-
-
Save marsbomber/1697539 to your computer and use it in GitHub Desktop.
Ruby 1.9.3 YAML parse
This file contains 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' | |
yaml = <<yaml | |
defaults: &defaults | |
cool: | |
bang: wow | |
fruit: apple | |
development: | |
<<: *defaults | |
cool: | |
fruit: banana | |
yaml | |
parsed = begin | |
YAML.load(yaml) | |
rescue ArgumentError => e | |
puts "Could not parse YAML: #{e.message}" | |
end | |
puts "Using: #{YAML::ENGINE.yamler}" | |
puts parsed.inspect | |
YAML::ENGINE.yamler= 'syck' | |
parsed = begin | |
YAML.load(yaml) | |
rescue ArgumentError => e | |
puts "Could not parse YAML: #{e.message}" | |
end | |
puts "Using: #{YAML::ENGINE.yamler}" | |
puts parsed.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment