I’m fairly new to Ruby and I was wondering if there was a module that
functions similarly to the shelve module in Python.
The shelve module is a method for packaging a dictionary (hash) of
arbritrary objects into a file. I use it as a rudimentary database so
that I don’t have to rebuild objects from text files over and over.
If anyone knows of a module in Ruby that could accomplish this, or a
suggestion on how to do this, any help would be appreciated.
suggestion on how to do this, any help would be appreciated.
Ruby comes with Marshal and YAML, which sounds like what you are
looking for. Also see PStore, for transactional file storage.
The shelve module is a method for packaging a dictionary (hash) of
arbritrary objects into a file. I use it as a rudimentary database so
that I don’t have to rebuild objects from text files over and over.
Something like yaml? If I understand your request this is pretty close:
If anyone knows of a module in Ruby that could accomplish this, or a
suggestion on how to do this, any help would be appreciated.
Ruby comes with Marshal and YAML, which sounds like what you are
looking for. Also see PStore, for transactional file storage.
If you want something like PStore, but with both thread- and
process-safe transactions, with finer granularity (treating a file tree
as a single DB), and with configurable mapping to serialization types
(including YAML and Marshal):