rufus-scheduler 3.5.0 released
rufus-scheduler 3.5.0 just got released.
Rufus-scheduler is a job scheduling (at, in, every, cron) library available as a Ruby gem. It is not meant as a cron replacement, it lives within the Ruby process using it and dies with it.
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
# ...
scheduler.in '10d' do
# do something in 10 days
end
scheduler.at '2030/12/12 23:30:00' do
# do something at a given point in time
end
scheduler.at '2030/12/12 23:30:00 Europe/Rome' do
# do something at a given point in time (Rome time zone)
end
scheduler.every '3h' do
# do something every 3 hours
end
scheduler.cron '5 0 * * *' do
# do something every day, five minutes after midnight
# (see "man 5 crontab" in your terminal)
end
scheduler.cron '5 0 * * * America/Los_Angeles' do
# same as above, but in the Los Angeles time zone
end
Rufus-scheduler lives in its own thread, keep that in mind when using it on a forking application server.
If you're looking for something that leverages the cron daemon, look at the excellent Whenever.
This 3.5.0 uses fugit for parsing time strings thrown at it. Fugit is the extraction of the time parsing/representing component of rufus-scheduler in its own gem.
Time.now #=> 2018-05-15 08:47:27 +0900
require 'fugit'
Fugit.parse('0 0 1 jan *').class # => Fugit::Cron
Fugit.parse('0 0 1 jan *').next_time.to_s # => "2019-01-01 00:00:00 +0900"
Fugit.parse('0 0 1 jan *').previous_time.to_s # => "2018-01-01 00:00:00 +0900"
Fugit.parse('12y12M').class # => Fugit::Duration
Fugit.parse('12y12M').to_sec # => 409536000
Fugit.parse('12y12M').to_iso_s # => "P12Y12M"
Fugit.parse('2017-12-12').class # => EtOrbi::EoTime
Fugit.parse('2017-12-12').to_s # => "2017-12-12 00:00:00 +0900"
Fugit.parse('2017-12-12 UTC').class # => EtOrbi::EoTime
Fugit.parse('2017-12-12 UTC').to_s # => "2017-12-12 00:00:00 Z"
Fugit.parse('every day at noon').next_time.to_s # => "2018-05-15 12:00:00 +0900"
Fugit.parse('every day at noon').previous_time.to_s # => "2018-05-14 12:00:00 +0900"
I need a separate time parsing library for flor so I extracted fugit out of rufus-scheduler.
Fugit uses raabro to parse strings, flor uses it as well but for parsing process definitions.
If you encounter issues with this new version of rufus-scheduler, please report at https://github.com/jmettraux/rufus-scheduler/issues.
Out.