rubysl/rubysl-yaml — pull request #3 by splattael (2014-06-29 17:31:30+00:00)
Title: Dumping/loading anonymous Structs with Syck

While fixing deserialization of anonymous `Struct`s in Delayed Job (collectiveidea/delayed_job#612) I stumbled on `Syck`'s lack of support for anonymous `Struct`s.

This PR addresses this lack.

I've managed to fix dumping an anonymous `Struct`.

I still have trouble of loading an anonymous `Struct`.

(Please note the individual commits)

My pending questions:
* Should be `Psych` preferred over `Syck`?

* Is `rubysl-yaml` the correct repo for `Syck`?
There is also https://github.com/tenderlove/syck

* While fixing dumping anonymous `Struct`s `mspec` did not pick up the local copy of `rubysl-yaml`. It used the installed version.

```
(anon-struct) ~/devel/rubysl-yaml$ bundle exec mspec spec/to_yaml_spec.rb
rubinius 2.2.9.n179 (2.1.0 b1f7858c 2014-06-28 JI) [i686-linux-gnu]

...........E.......

1)
Object#to_yaml returns the YAML representation of an anonymous Struct object ERROR
NoMethodError: undefined method `gsub' on nil:NilClass.
Kernel(NilClass)#gsub (method_missing) at kernel/delta/kernel.rb:78
Struct.yaml_tag_class_name at /home/peter/.rvm/rubies/rbx-head/gems/gems/rubysl-yaml-2.0.4/lib/syck/rubytypes.rb:53
Struct(#)#taguri at /home/peter/.rvm/rubies/rbx-head/gems/gems/rubysl-yaml-2.0.4/lib/syck/tag.rb:70
{ } in Struct(#)#to_yaml at /home/peter/.rvm/rubies/rbx-head/gems/gems/rubysl-yaml-2.0.4/lib/syck/rubytypes.rb:94
Syck::Emitter#emit at rubyext.c
Syck.quick_emit at lib/syck.rb:409
Struct(#)#to_yaml at /home/peter/.rvm/rubies/rbx-head/gems/gems/rubysl-yaml-2.0.4/lib/syck/rubytypes.rb:90
{ } in Object#__script__ at spec/to_yaml_spec.rb:62
BasicObject(Object)#instance_eval at kernel/common/eval.rb:43
MSpec.protect at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:69
{ } in ContextState#protect at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/context.rb:179
{ } in Enumerable(Array)#all? at kernel/common/enumerable.rb:307
Array#each at kernel/bootstrap/array.rb:76
Enumerable(Array)#all? at kernel/common/enumerable.rb:307
ContextState#protect at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/context.rb:179
{ } in ContextState#process at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/context.rb:208
{ } in MSpec.repeat at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:239
Integer(Fixnum)#times at kernel/common/integer.rb:196
MSpec.repeat at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:238
{ } in ContextState#process at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/context.rb:200
Array#each at kernel/bootstrap/array.rb:76
ContextState#process at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/context.rb:199
MSpec.describe at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:38
Object#describe at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/object.rb:11
Object#__script__ at spec/to_yaml_spec.rb:4
Kernel.load at kernel/common/kernel.rb:447
{ } in MSpec.files at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:57
BasicObject(Object)#instance_eval at kernel/common/eval.rb:43
MSpec.protect at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:69
{ } in MSpec.files at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:57
Array#each at kernel/bootstrap/array.rb:76
MSpec.files at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:51
MSpec.process at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/runner/mspec.rb:43
MSpecRun#run at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/commands/mspec-run.rb:94
MSpecScript.main at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/lib/mspec/utils/script.rb:218
Object#__script__ at /home/peter/.rvm/gems/rbx-head/gems/mspec-1.5.21/bin/mspec-run:8
Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66
Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:152
Rubinius::Loader#script at kernel/loader.rb:649
Rubinius::Loader#main at kernel/loader.rb:825

Finished in 0.168612 seconds

1 file, 19 examples, 29 expectations, 0 failures, 1 error
```

Any hints?