Project

General

Profile

Bug #1653

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

=begin

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

=end

Back