hoodwink.d enhanced


Serializing To Ruby Code #

by why in inspect

Amid a discussion on the list about XML v. YAML (hope they declare a winner!), I noticed a message by Dick Davies about keeping his data in Ruby code rather than any other data formats. And then I remembered AMarshal. And then I remembered that it’s not in the Ruby stdlib.

AMarshal is a solid extension for saving your objects as straight Ruby. Readable, fast and stable. NaHi’s tested the slime outta this extension. And, well, knowing Tanaka Akira’s consummate debugging… I don’t want to bloat the Ruby dist too much more, but this is a great extension.

 >> require 'amarshal-pretty'
 => true
 >> puts AMarshal.dump_pretty(
 ?>   {'name' => 'Slavoj Zizek', 'alias' => 'Dave Thomas',
 ?>    'authored' => ['PickAxe II', 'The Prag Prog Book']} )
 {"name" => "Slavoj Zizek",
  "authored" => ["PickAxe II", "The Prag Prog Book"],
  "alias" => "Dave Thomas"}

See, make sure to use amarshal-pretty to get nicely laid out inlines.

said on 09 Jan 2005 at 07:59

Heh, fun. I wrote a to-ruby Marshal yesterday, let’s see if I can whip it up for a release.

Comments are closed for this entry.