On Thu, Jan 26, 2012 at 7:13 AM, Joel VanderWerf
<joelvanderwerf / gmail.com> wrote:
> Here's another way to do it. (FSDB does a lot of other stuff, too...)

Without looking, I'm going to guess that you created that library,
Joel.  That immediately assures me of its quality, but I found some of
the API a little unwieldy.

>
> formats =3D [
> =A0FSDB::TEXT_FORMAT.when(/\.txt$|\.html$/),
> =A0FSDB::BINARY_FORMAT.when(/\.png$/)
> ]

formats =3D { /\.txt$|\.html$/ =3D> :text, /\.png$/ =3D> :binary }
  # And should the programmer really have to specify these? Can't they
be baked in?

> =A0img["hello.png"] =3D data["hello.png"]

I don't get a sense of what that line is doing.

> # you can automatically serialize objects in yaml, json, or marshal:
> [...]
> =A0json_format =3D FSDB::Format.new(
> =A0 =A0/\.json$/, /\.js$/,
> =A0 =A0:name =3D> "JSON_FORMAT",
> =A0 =A0:load =3D> proc {|f| JSON.load(f)},
> =A0 =A0:dump =3D> proc {|object, f| f.syswrite(JSON.dump(object))}
> =A0)
> =A0tmp.formats =3D formats + [FSDB::YAML_FORMAT, json_format]

Seems to me that building yaml, json and marshal capabilities into the
library would be justified and worthwhile.

I'm starting work on a project involving a lot of file and directory
manipulation, so I'll check out fsdb enthusiastically.

Gavin