Ruby<->Perl and syck-0.25 problem

Any syck users out there? I have an urgent need to get some Perl<->Ruby
communication and I thought YAML RPC would be a good way to do this, now
there is a fast YAML parser for Ruby (this assumes there is a decent YAML
implementation for Perl of course, which syck doesn’t support)

However I’ve tried installing syck-0.25 and it seems to have some bits
missing:

irb(main):002:0> require 'yaml’
NameError: undefined method add_ruby_type' for YAML:Module from /usr/local/lib/ruby/site_ruby/1.6/yaml/rubytypes.rb:26 from /usr/local/lib/ruby/site_ruby/1.6/yaml.rb:19:inrequire’
from /usr/local/lib/ruby/site_ruby/1.6/yaml.rb:19
from (irb):2:in `require’
from (irb):2

Grepping the source I can see where add_ruby_type and add_builtin_type are
used, but not where they are defined.

Am I missing some magic source file?

Also, anybody have any other smart ideas about how to exchange a tree of
objects between Ruby and Perl? SOAP is too slow, and XMLRPC doesn’t keep the
inter-object references properly (in fact I think it dies completely when
given a circular reference). A simple request-response model is all I need,
and the two bits are on the same machine, so no need to go via a socket if
there’s a direct way of integrating them.

Cheers…

Brian.

irb(main):002:0> require ‘yaml’
NameError: undefined method `add_ruby_type’ for YAML:Module

These are fixed in Syck CVS. I will make another release soon if there
is a demand.

Also, anybody have any other smart ideas about how to exchange a tree of
objects between Ruby and Perl?

I hear Iain Truskett is working on a Syck Perl extension. I think
YAML.pm is okay, though you will probably wrestle with compatibility
between YAML.pm and Syck since I coded against the very latest
specification.

So until my lower abdominal arms begin to appear, I’m afraid there’s a
bit of a wait. You may also consider using YAML.rb 0.49.2 with YAML.pm,
as they may talk friendlier.

_why

···

Brian Candler (B.Candler@pobox.com) wrote:

Brian Candler B.Candler@pobox.com wrote in message news:20030513145842.A72368@linnet.org

However I’ve tried installing syck-0.25 and it seems to have some bits
missing:

irb(main):002:0> require ‘yaml’
NameError: undefined method add_ruby_type' for YAML:Module from /usr/local/lib/ruby/site_ruby/1.6/yaml/rubytypes.rb:26 from /usr/local/lib/ruby/site_ruby/1.6/yaml.rb:19:in require’
from /usr/local/lib/ruby/site_ruby/1.6/yaml.rb:19
from (irb):2:in `require’
from (irb):2

Grepping the source I can see where add_ruby_type and add_builtin_type are
used, but not where they are defined.

Am I missing some magic source file?

You need to:
require “syck”
not, “yaml”.

Then change your code:
object = YAML.load(whatever)
becomes
parser = YAML::Syck::Parser.new({})
object = parser.load(whatever)

HTH,

Tom

Actually, no longer the case with newer versions. YAML.rb will leverage Syck
if it is available. Either of the above will work.

_why

···

On Tuesday 13 May 2003 11:34 am, Tom Payne wrote:

You need to:
require “syck”
not, “yaml”.

Then change your code:
object = YAML.load(whatever)
becomes
parser = YAML::Syck::Parser.new({})
object = parser.load(whatever)

But that doesn’t let me do:

foo.to_yaml

which is an essential half of the solution. I’ll look at CVS when I get a
chance. I’ve pretty much discounted YAML for my problem though, because
Perl’s YAML.pm doesn’t seem to have any support for Okay (RPC over YAML).

I am currently playing with SOAP again, but have been unable to get Perl’s
SOAP::Lite to serialize a hash in the right way so that Ruby deserializes it
as a hash…

Cheers,

Brian.

···

On Wed, May 14, 2003 at 02:34:57AM +0900, Tom Payne wrote:

You need to:
require “syck”
not, “yaml”.

Then change your code:
object = YAML.load(whatever)
becomes
parser = YAML::Syck::Parser.new({})
object = parser.load(whatever)