README.rdoc in rufus-scheduler-2.0.2 vs README.rdoc in rufus-scheduler-2.0.3

- old
+ new

@@ -19,11 +19,11 @@ http://github.com/hpoydar/chronic_duration == installation - sudo gem install rufus-scheduler + sudo gem install rufus-scheduler --source http://gemcutter.org == usage The usage is similar to the one of the old rufus-scheduler. There are a few differences though. @@ -67,10 +67,33 @@ scheduler = Rufus::Scheduler.start_new will return an instance of Rufus::Scheduler::EmScheduler (leveraging EventMachine). +== scheduler.join + +Note that if you have a tiny script like this one : + + require 'rubygems'; require 'rufus-scheduler' + + scheduler = Rufus::Scheduler.start_new + + scheduler.at 'Thu Mar 26 07:31:43 +0900 2009' do + puts 'order pizza' + end + +And you run it, it will exit immediately. + +If you place + + scheduler.join + +at then end of it will make the current (main) thread join the scheduler and prevent the Ruby runtime from exiting. + +You shouldn't be exposed to this issue when using EventMachine, since while running EM, your runtime won't exit. + + == block parameters Scheduled blocks accept 0 or 1 parameter (this unique parameter is the job instance itself). @@ -176,9 +199,19 @@ scheduler.in '3d', JobThing.new('http://news.example.com/data_xyz') scheduler.in '1w', JobThing.new('http://news.example.com/data_abc'), :timeout => '1d' 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) + 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'. == looking up jobs scheduler.jobs