Skip to content

Instantly share code, notes, and snippets.

@harukizaemon
Created May 20, 2011 20:18
Show Gist options
  • Select an option

  • Save harukizaemon/983712 to your computer and use it in GitHub Desktop.

Select an option

Save harukizaemon/983712 to your computer and use it in GitHub Desktop.
Demonstrate that psych/libyaml is borked
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}"
@harukizaemon
Copy link
Copy Markdown
Author

Psych that ships with Ruby

RUBY_VERSION: 1.9.2
YAML::VERSION: 1.0.0
development[database]: nil

@harukizaemon
Copy link
Copy Markdown
Author

YAML that ships with Ruby

RUBY_VERSION: 1.9.2
YAML::VERSION: 0.60
development[database]: "example_development"

@harukizaemon
Copy link
Copy Markdown
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