README.rdoc in rufus-scheduler-2.0.6 vs README.rdoc in rufus-scheduler-2.0.7
- old
+ new
@@ -8,17 +8,18 @@
== alternatives / complements
A list of related Ruby projects :
-http://github.com/javan/whenever
-http://github.com/yakischloba/em-timers/
+* http://github.com/javan/whenever
+* http://github.com/yakischloba/em-timers
+* http://github.com/adamwiggins/clockwork
More like complements :
-http://github.com/mojombo/chronic/
-http://github.com/hpoydar/chronic_duration
+* http://github.com/mojombo/chronic
+* http://github.com/hpoydar/chronic_duration
== installation
sudo gem install rufus-scheduler --source http://gemcutter.org
@@ -67,10 +68,36 @@
scheduler = Rufus::Scheduler.start_new
will return an instance of Rufus::Scheduler::EmScheduler (leveraging EventMachine).
+== a note about cron jobs
+
+This is a classical cron :
+
+ scheduler.cron '0 22 * * 1-5' do
+ # every day of the week at 22:00 (10pm)
+ end
+
+Rufus-scheduler supports two variants to that notation : seconds and timezones.
+
+ scheduler.cron '13 0 22 * * 1-5' do
+ # every day of the week at 22:00:13
+ end
+
+ scheduler.cron '0 22 * * 1-5 Europe/Paris' do
+ # every day of the week when it's 22:00 in Paris
+ end
+ scheduler.cron '0 22 * * 1-5 Etc/GMT+2' do
+ # every day of the week when it's 22:00 in GMT+2
+ end
+
+The timezones are the ones supported by the 'tzinfo' rubygem (http://tzinfo.rubyforge.org/).
+
+The timezone support was contributed by Tanzeeb Khalili.
+
+
== scheduler.join
Note that if you have a tiny script like this one :
require 'rubygems'; require 'rufus-scheduler'
@@ -185,14 +212,14 @@
== schedulables
Sometimes passing a block isn't that convenient :
class JobThing
- def initialize (relevant_info)
+ def initialize(relevant_info)
@ri = relevant_info
end
- def call (job)
+ def call(job)
do_something_about_it
end
end
# ...
@@ -203,11 +230,11 @@
rufus-scheduler accepts anything that responds to a call method with a unique parameter (it will pass the job) as a 'schedulable'.
For compatibility with older (1.x) versions, schedulables with a trigger methods are accepted :
class JobThing
- def trigger (params)
+ def trigger(params)
job = params[:job]
end
end
The 'params' correspond to the scheduler job params, and the key :job points to the rufus-scheduler job for the schedulable that is passed to a 'call schedulable'.
@@ -285,17 +312,17 @@
scheduler = Rufus::Scheduler::PlainScheduler.start_new
# or
#scheduler = Rufus::Scheduler::EmScheduler.start_new
- def scheduler.handle_exception (job, exception)
+ def scheduler.handle_exception(job, exception)
puts "job #{job.job_id} caught exception '#{exception}'"
end
For backward compatibility, overriding #log_exception is still OK :
- def scheduler.log_exception (exception)
+ def scheduler.log_exception(exception)
puts "caught exception '#{exception}'"
end
Note that an every job or a cron job will stay scheduled even if it experiences an exception.
@@ -332,16 +359,22 @@
}
== tested with
-ruby 1.8.6, ruby 1.9.1p0
-on jruby 1.2.0 it has some tiny issues (spec/blocking_spec.rb)
+* 1.8.7-p249
+* 1.9.1-p378
+* 1.9.2-p0
+* jruby-1.5.1
+on Mac OS X (Snow Leopard).
+
== dependencies
-the ruby gem 'eventmachine' if you use Rufus::Scheduler::EmScheduler, else no other dependencies.
+The 'tzinfo' rubygem.
+
+The ruby gem 'eventmachine' if you use Rufus::Scheduler::EmScheduler, else no other dependencies.
== mailing list
On the rufus-ruby list :