Created
May 20, 2011 20:18
-
-
Save harukizaemon/983712 to your computer and use it in GitHub Desktop.
Demonstrate that psych/libyaml is borked
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 'rubygems' | |
| # Switch the following two lines to see the bug in the psych that ships with Ruby | |
| # Comment out both to see the default YAML parsing behaviour | |
| gem 'psych' | |
| # require 'psych' | |
| require 'yaml' | |
| require 'erb' | |
| puts "RUBY_VERSION: #{RUBY_VERSION}" | |
| puts "YAML::VERSION: #{YAML::VERSION}" | |
| yaml = <<-YAML | |
| common: &common | |
| adapter: postgresql | |
| development: | |
| <<: *common | |
| database: example_development | |
| test: &test | |
| <<: *common | |
| database: example_test | |
| production: | |
| <<: *common | |
| database: example_production | |
| YAML | |
| config = YAML::load(yaml) | |
| development = config["development"] | |
| database = development["database"] | |
| puts "development[database]: #{database.inspect}" |
Author
Author
YAML that ships with Ruby
RUBY_VERSION: 1.9.2
YAML::VERSION: 0.60
development[database]: "example_development"
Author
Psych 1.1.1 gem
RUBY_VERSION: 1.9.2
YAML::VERSION: 0.60
development[database]: "example_development"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Psych that ships with Ruby
RUBY_VERSION: 1.9.2
YAML::VERSION: 1.0.0
development[database]: nil