Find file
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (27 sloc) 1022 Bytes

Journal

This gem is intended to provide an easy way to log activities. It uses Redis as storage, if you want to use a similar thing with CouchDB or MongoDB or anyother DB please create a separate Gem for that.

How to use

Put the following line into your Gemfile

gem "journal"

Then create an initializer or some other file loaded by your app and put the following config in it (with proper values) :

Journal.setup do |config|
  config.host = ""
  config.port = ""
  config.expiry = 604800
  config.password = ""
end

how to call

To create an new entry you just have to call the Journal.log method passing the data you want and a key :

Journal.log("oh", "some data")

You can then retrieve a JournalEntry object using the Journal.last method :

a = Journal.last("oh")
a.inspect
# #<JournalEntry:0x007f980c8dacd8 @key="awesome+key", @data="some data@1337007458", @timestamp="1337007458", @date=#<DateTime: 2012-05-14T16:57:38+02:00 ((2456062j,53858s,0n),+7200s,2299161j)>