Bugs: Browse | Submit New | Admin

[#27407] Stream output can't be no Syck

Date:
2009-11-06 02:19
Priority:
3
Submitted By:
Dice (dice)
Assigned To:
Akira FUNAI (afunai)
Category:
None
State:
Open
Summary:
Stream output can't be no Syck

Detailed description
Environment:
  Ya2YAML 0.29
  ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]


ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-02-01 12:28
Sender: Akira FUNAI

Sorry for the slooow response.
I confirmed the issue.  Also I found that when I removed the
preceding indentation from members of the structs, Syck loaded
the stream properly.

OK:
--- !ruby/struct: 
a: 1
b: 2
--- !ruby/struct: 
c: 3
d: 4

NG:
--- !ruby/struct: 
  a: 1
  b: 2
--- !ruby/struct: 
  c: 3
  d: 4

Unfortunately, there is no rigid specification for ruby-specific
objects in YAML.
http://www.yaml.org/YAML_for_ruby.html#struct_class
The first example in "Yaml Cookbook" has the mischievous
indentation. Probably this is why I added it in the first place.
I don't know if I should remove the indentation or not, but I
could make it as an another option in the next release :-)

Thanks for the report!
Date: 2009-11-06 02:28
Sender: Dice 

Sorry, I have sent wrongly. The following is correct:



Title: Stream output of Ya2YAML can't be loaded by Syck

 Two or more Struct that are serialized by Object#ya2yaml 
can't be loaded as stream by Syck.

Environment:
  Ya2YAML 0.29
  ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]


========

require 'yaml'
require 'ya2yaml'

st = Struct.new(:a, :b)
data = st.new(1, 2)
opts = {:syck_compatible => true}

single_yaml = ""
single_yaml << data.ya2yaml(opts)
puts single_yaml
YAML.load(single_yaml)

stream_yaml = ""
stream_yaml << data.ya2yaml(opts) <<
data.ya2yaml(opts)
puts stream_yaml
YAML.load_stream(stream_yaml)

========

--- !ruby/struct: 
  a: 1
  b: 2
--- !ruby/struct: 
  a: 1
  b: 2
--- !ruby/struct: 
  a: 1
  b: 2
/usr/lib/ruby/1.8/yaml.rb:272:in `load_documents': syntax 
error on line 3, col 0: `--- !ruby/struct: ' (ArgumentError)
	from /usr/lib/ruby/1.8/yaml.rb:272:in `load_stream'
	from yamltest.rb:16

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
resolution_idNone2010-02-01 12:28afunai
assigned_tonone2010-02-01 12:28afunai