I am writing an app that is utilizing the Rufus-Scheduler Ruby Gem. This is what a returned hash looks like when display ALL running jobs...
{"Rufus::Scheduler::EveryJob_2154902980"=>#, @jobs=[#, #, @t="20s", @params={:allow_overlapping=>false, :tags=>[]}开发者_开发知识库, @block=#, @running=false, @job_id="Rufus::Scheduler::EveryJob_2174059660", @frequency=20.0, @last=2011-07-28 11:29:55 -0500, @at=1311870615.636462, @last_job_thread=#>, #, @t="20s", @params={:allow_overlapping=>false, :tags=>[]}, @block=#, @running=false, @job_id="Rufus::Scheduler::EveryJob_2172810900", @frequency=20.0, @last=2011-07-28 11:30:02 -0500, @at=1311870622.743519, @last_job_thread=#>, #, @t="20s", @params={:allow_overlapping=>false, :tags=>[]}, @block=#, @running=false, @job_id="Rufus::Scheduler::EveryJob_2163415980", @frequency=20.0, @last=2011-07-28 11:30:10 -0500, @at=1311870630.107751, @last_job_thread=#>, #, @t="20s", @params={:allow_overlapping=>false, :tags=>[]}, @block=#, @running=false, @job_id="Rufus::Scheduler::EveryJob_2163895880", @frequency=20.0, @last=nil, @at=1311870633.0427048>]>, @cron_jobs=#, @jobs=[], @last_cron_second=13>, @frequency=0.33, @thread=#>, @t="20s", @params={:allow_overlapping=>false, :tags=>[]}, @block=#, @running=false, @job_id="Rufus::Scheduler::EveryJob_2154902980", @frequency=20.0, @last=2011-07-28 11:29:53 -0500, @at=1311870613.4696362, @last_job_thread=#>,
I am having a hard time trying to process this. I have tried turning it to a JSON string, but my application dies hard and displays an Illegal Instruction
error in the error log.
I have tried iterating of it with a .each
but it only returns Rufus::Scheduler::EveryJob_2154902980 => #
Any ideas on how to go about parsing this out?
the hash is mapping job String ids to Job instances. Granted, everything is a string when seen from the console.
This should help :
scheduler.all_jobs.each do |job_id, job|
p [ job_id, job.class, job.t, job.tags ]
end
No need to parse anything.
精彩评论