Skip to content

Instantly share code, notes, and snippets.

@armanm
Created February 8, 2013 02:02
Show Gist options
  • Save armanm/4736034 to your computer and use it in GitHub Desktop.
Save armanm/4736034 to your computer and use it in GitHub Desktop.
To parse YAML with Ruby, do not use the YAML module, use Psych (which ships with Ruby 1.9.2, though there is also a gem). The reason is that YAML uses the unmaintained Syck library, whereas Psych uses the modern LibYAML:
>> require 'yaml'
>> YAML.load("%YAML 1.1\n---\n'test'") # %YAML directive not supported
=> "%YAML 1.1 --- 'test'"
>> require 'psych'
>> Psych.load("%YAML 1.1\n---\n'test'") # all good
=> "test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment