[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Is there any standard package to dump to ruby data structures

adm

4/4/2008 11:05:00 AM

Is there any standard package to dump ruby data structures into a
string/stream? which can be eval'd back in ruby script. something like
perl's Data::Dumper?
7 Answers

Eivind Eklund

4/4/2008 11:23:00 AM

0

On Fri, Apr 4, 2008 at 1:10 PM, adm <avinash.magar@gmail.com> wrote:
> Is there any standard package to dump ruby data structures into a
> string/stream? which can be eval'd back in ruby script. something like
> perl's Data::Dumper?

You may want to look at YAML or Marshall; they are not quite what
you're describing, but may fill the need you're thinking about.

I don't know of anything that outputs code for eval.

Eivind.

Jano Svitok

4/4/2008 11:25:00 AM

0

On Fri, Apr 4, 2008 at 1:10 PM, adm <avinash.magar@gmail.com> wrote:
> Is there any standard package to dump ruby data structures into a
> string/stream? which can be eval'd back in ruby script. something like
> perl's Data::Dumper?

Marshal - faster; shorter binary data
YAML - slower, human readable/editable data

Abdelkader Boudih

4/4/2008 11:32:00 AM

0

You could use Marshal
see :
Marshal.dump
&
Marshal.load

adm wrote:
> Is there any standard package to dump ruby data structures into a
> string/stream? which can be eval'd back in ruby script. something like
> perl's Data::Dumper?
>
>
>


adm

4/4/2008 1:42:00 PM

0

On Apr 4, 4:24 pm, Jano Svitok <jan.svi...@gmail.com> wrote:
> On Fri, Apr 4, 2008 at 1:10 PM, adm <avinash.ma...@gmail.com> wrote:
> > Is there any standard package to dump ruby data structures into a
> >  string/stream? which can be eval'd back in ruby script. something like
> >  perl's Data::Dumper?
>
> Marshal - faster; shorter binary data
> YAML - slower, human readable/editable data

Yes, I can use Marshal.
Thank you guys.

M. Edward (Ed) Borasky

4/4/2008 3:16:00 PM

0

adm wrote:
> On Apr 4, 4:24 pm, Jano Svitok <jan.svi...@gmail.com> wrote:
>> On Fri, Apr 4, 2008 at 1:10 PM, adm <avinash.ma...@gmail.com> wrote:
>>> Is there any standard package to dump ruby data structures into a
>>> string/stream? which can be eval'd back in ruby script. something like
>>> perl's Data::Dumper?
>> Marshal - faster; shorter binary data
Ruby-specific format
>> YAML - slower, human readable/editable data
Language-independent format


bob

4/4/2008 4:18:00 PM

0

adm wrote:
> Is there any standard package to dump ruby data structures into a
> string/stream? which can be eval'd back in ruby script. something like
> perl's Data::Dumper?

In addition to the other suggestions of Marshal and YAML you can also
use 'pp' on data objects.

irb(main):002:0> require 'pp'
=> true
irb(main):003:0> pp x
"foo"
irb(main):007:0> pp y
[1, nil, 3]
irb(main):012:0> pp z
{"three"=>3, "two"=>2, "one"=>1}

Bob

Joel VanderWerf

4/4/2008 6:56:00 PM

0

adm wrote:
> Is there any standard package to dump ruby data structures into a
> string/stream? which can be eval'd back in ruby script. something like
> perl's Data::Dumper?

Probably, the other answers are more helpful, but if you really want to
dump to ruby code that can be eval-ed back to get the objects, there is
amarshal:

http://www.a-k-r.or...

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407