From: Benjamin ter Kuile Date: 2009-06-18T18:20:59+09:00 Subject: [ruby-core:23912] [Bug #1653] YAML load_documents fails on specification example without newline at end Bug #1653: YAML load_documents fails on specification example without newline at end http://redmine.ruby-lang.org/issues/show/1653 Author: Benjamin ter Kuile Status: Open, Priority: Normal ruby -v: 1.8.7-72 I was experimenting with how multiple documents in one file are processed by YAML. I went to the yaml specification site and copied an example there(http://yaml.org/spec/current.html). In irb: str = "--- time: 20:03:20 player: Sammy Sosa action: strike (miss) ... --- time: 20:03:47 player: Sammy Sosa action: grand slam ..." YAML::load_documents(str){|d| puts d.inspect} results in: {"player"=>"Sammy Sosa", "action"=>"strike (miss)", "time"=>72200} ArgumentError: syntax error on line 8, col 3: `' from /usr/lib/ruby/1.8/yaml.rb:217:in `load_documents' from /usr/lib/ruby/1.8/yaml.rb:217:in `each_document' from /usr/lib/ruby/1.8/yaml.rb:232:in `load_documents' from (irb):11 while: YAML::load_documents(str+"\n"){|d| puts d.inspect} # Added newline ad end Results in: {"player"=>"Sammy Sosa", "action"=>"strike (miss)", "time"=>72200} {"player"=>"Sammy Sosa", "action"=>"grand slam", "time"=>72227} which is what I expected in the first place. This test is done in irb for ruby versions: 1.8.7-72 and 1.9.0 ---------------------------------------- http://redmine.ruby-lang.org