Closed taazza closed 14 years ago
Yes, sub-properties of POSH formats are of an anonymous class which itself inherits from POSH. It's possible to create a #to_yaml method of POSH objects to help this along. Can you post (in a gist, or in this issue) how you've been converting your objects to YAML. In all likelihood I will take a similar approach.
Thanks.
(sorry for the redundancy)
We have been using 'current.inspect.to_yaml' to do the conversion. From posh/base.rb, I see that calling 'inspect' internally calls the 'to_h' method to generate a Hash and returns its inspect. I tried this snippet in the irb and it seems to work.
class Prism::POSH::Base
def to_yaml
to_h.to_yaml
end
end
Thanks
This technique works, but when the element increases in complexity, I get this. Is there a URL you've been testing on that I can test against? Not sure what's going on here.
ArgumentError: wrong number of arguments (1 for 0)
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:110:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:110:in `node_export'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:110:in `add'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:110:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:109:in `each'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:109:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:108:in `seq'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:108:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml.rb:391:in `call'
/usr/local/lib/ruby/1.8/yaml.rb:391:in `emit'
/usr/local/lib/ruby/1.8/yaml.rb:391:in `quick_emit'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:107:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:41:in `node_export'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:41:in `add'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:41:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:40:in `each'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:40:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:39:in `map'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:39:in `to_yaml'
/usr/local/lib/ruby/1.8/yaml.rb:391:in `call'
/usr/local/lib/ruby/1.8/yaml.rb:391:in `emit'
/usr/local/lib/ruby/1.8/yaml.rb:391:in `quick_emit'
/usr/local/lib/ruby/1.8/yaml/rubytypes.rb:38:in `to_yaml'
./../../lib/prism/posh.rb:183:in `to_yaml'
very bizarre: http://gist.github.com/351862
Conversion to YAML and recursive parsing to_h. to_yaml dumps to_h representation. Closed by 5709d199142533e378c9475cf877b2723c7fcf96
From an irb session :-
We are working around this issue by doing an inspect on current and then serializing it. We wanted to know whether this issue is something that can be fixed at your end.