Store emotions in Redis. Emotions allows the storage of emotions in Redis, a fast and atomic structured data store. If one's users hate, love, appreciate, despise or just-don-t-care, one can store that easily via a simple API.
It is not bound to
ActiveRecord, and any model conforming to the
conventions should work just as well.
class CatPicture < ActiveRecord::Base include Emotions::Emotive emotions :like, :dislike end
This simple example shows that in our logical model cat pictures can either be liked, or disliked.
On the flip-side, one needs a way to share one's feelings, from the model representing a user, or rater, or similar, one can easily use the opposite:
class User < ActiveRecord::Base include Emotions::Emotional end
This module will mix-into the
User the following methods:
These methods can be passed instances of any class which has those emotions defined.
Passing anything else will cause undefined behaviour.
Emotions is inspired by
schneems/likeable. A few
things concerned me about that project, so I re-wrote after contributing
significant fixes to likeable.
What's different from likeable?
There are no hard-coded assumptions about which emotions you'll be using, that's up to your project needs.
There are no callbacks, these are better handled with observers, either in the classical OOP meaning of the word, or your framework's pattern. (In Rails they're the samne thing)
A very comprehensive test suite, written with Minitest. Likeable is quite simple, and has about ~35 tests, that might be OK for you, and Gowalla, but I'd feel better with real unit, functional and integration tests.
It's not totally bound to Redis. Internally there's a Key/Value store proxy, this uses Redis out of the box, but it should be easy for someone to replace this with MongoDB, Riak, DynamoDB, SQLite, etc.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install emotions
TODO: Write usage instructions here
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request