Project

General

Profile

Actions

Bug #1653

closed

YAML load_documents fails on specification example without newline at end

Added by bterkuile (Benjamin ter Kuile) almost 15 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
ruby -v:
1.8.7-72
[ruby-core:23912]

Description

=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

Actions #1

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Description updated (diff)
  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0