Recurr allows you to manage recurring events in a Rails application (ouch!)
Add this line to your application's Gemfile:
gem 'recurr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install recurr
-
First run the generator to copy the necessary migration.
-
Run the migration with
rake db:migrate
. -
You can configure the behavior of Raterr:
Raterr.configure do |config|
config.adapter = :activerecord
config.event_table_name = 'recurring_events'
end
- Let's say you have a
PaymentEvent
job and you want it to be recurring.
class PaymentEvent < ApplicationJob
include Recurr::Adapters::ActiveRecord
recurr :daily
# Perform event every day at 18 o'clock
recurr :daily, at: 18
#Perform every week on tuesday(day 2) at 13 o'clock
recurr :weekly, on: 2, at: 13
# Perform event every month on the 10th at 14 o'clock
recurr :monthly, on: 10, at: 14
# Perform event every new year at midnight
recurr :monthly, on: 31, if: -> { month.is_a?('December') }
def perform(*args)
# Perform something stupid...
end
end
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/wizardonee/recurr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.