[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

YAML::quick_emit api change

Ara.T.Howard

2/3/2006 3:35:00 PM

5 Answers

why the lucky stiff

2/3/2006 5:18:00 PM

0

ara.t.howard@noaa.gov wrote:

> which toggled the yaml output style from the standard one to an inline
> one. it
> blows up now (1.8.4) with
>
> NoMethodError: undefined method `<<' for nil:NilClass
>
Yeah, you can't write directly to the output stream any longer. But the
emitter is much smarter, more capable now (and utterly non-rdoc'd).

In current versions, you can define a `to_yaml_style' method which
expects a symbol describing how to output the object. In this case,
you'll want to reply with :inline.

>> hsh = {'to' => 'ara.t.howard@noaa.gov', 'x-mail-count' => 178223,
'from' => 'why@ruby-lang.org'}
>> def hsh.to_yaml_style; :inline end
=> nil
>> y [hsh, {'Subject' => 'Re: YAML::quick_emit api change'}]
---
- {from: why@ruby-lang.org, x-mail-count: 178223, to:
ara.t.howard@noaa.gov}
- Subject: "Re: YAML::quick_emit api change"
=> nil

> i checked in the docs and am reading the source now - but the fix
> isn't jumping
> out at me. any ideas?

I just need to improve the rdoc. What a sorry state I've left us all in!

_why


Ara.T.Howard

2/3/2006 5:29:00 PM

0

why the lucky stiff

2/3/2006 5:44:00 PM

0

ara.t.howard@noaa.gov wrote:

> but is a nil value by default ok?

>> require 'yaml'
>> hsh = {'to' => 'ara.t.howard@noaa.gov', 'x-mail-count' => 178223,
'from' => 'why@ruby-lang.org'}
>> hsh.to_yaml_style
=> nil

If you really need to sniff, I'd use YAML::Syck::VERSION. In case you
encounter someone who'se upgraded their extension.

why@stungun ~ $ ~/sand/RUBY-1_8_4/bin/ruby -v -ryaml -e 'p
YAML::Syck::VERSION'
ruby 1.8.4 (2005-12-24) [i686-linux]
"0.60"

why@stungun ~ $ ~/sand/RUBY-1_8_3/bin/ruby -v -ryaml -e 'p
YAML::Syck::VERSION'
ruby 1.8.3 (2005-09-21) [i686-linux]
"0.60"

why@stungun ~ $ ~/sand/RUBY-1_8_2/bin/ruby -v -ryaml -e 'p
YAML::Syck::VERSION'
ruby 1.8.2 (2004-12-25) [i686-linux]
"0.45"

There shouldn't be any 0.5x Sycks floating around in stable Ruby releases.

_why


Ara.T.Howard

2/3/2006 6:58:00 PM

0

why the lucky stiff

2/3/2006 7:46:00 PM

0

ara.t.howard@noaa.gov wrote:

> and where would the to_yaml_style attr come in at - which version is
> the break
> point?

0.55:

http://code.whytheluckystiff.net/syck/cha...

_why