Palsy - Set and forget it
Present ruby core data structures in a manner similar to perl's tie backed by a
SQLite database. Intended to be as simple as possible, sacrificing performance
and flexibility to do so.
It is not a 1:1 emulation of tie, as ruby cannot support this. What it does do
is provide a convincing enough facsimile by emulating the interface, and making
it easy to convert to native ruby types when that's not enough.
This library is completely unapologetic with regards to how little it does or
how slow it does things.
All writes are fully consistent, which is something SQLite gives us. Reads
always hit the database. This allows us to reason more clearly about how our
data persists, even in concurrent models where shared state can get very
complicated to use.
This was largely written to deal with problems I had to resolve in
chef-workflow. If you like the idea but
would like something more general or support for your favorite database, check
out Moneta which is a little more geared
towards having a flexible backend.
Usage Example
Here's an example for dealing with several collections.
require 'palsy'
Palsy.database = 'test.db'
set_a = Palsy::Set.new('some_sets', 'set_a')
set_b = Palsy::Set.new('some_sets', 'set_b')
set_c = Palsy::Set.new('some_sets', 'set_c')
set_a.add('something')
set_b.add('something_else')
set_c.add(set_a)
set_a.group_by(&:length)
set_a.to_set | set_b.to_set
Installation
Add this line to your application's Gemfile:
gem 'palsy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install palsy
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
)
- Commit your changes (
git commit -am 'Add some feature'
)
- Push to the branch (
git push origin my-new-feature
)
- Create new Pull Request
Changes to author, license or version information without prior approval will
be rejected regardless of other changes.
Author
Erik Hollensbe erik+github@hollensbe.org