lib/sidekiq/cron/job.rb in sidekiq-cron-0.1.5 vs lib/sidekiq/cron/job.rb in sidekiq-cron-0.1.6

- old
+ new

@@ -1,9 +1,9 @@ require 'sidekiq' require 'sidekiq/util' require 'sidekiq/actor' -require 'parse-cron' +require 'rufus-scheduler' module Sidekiq module Cron class Job @@ -261,12 +261,12 @@ errors << "'name' must be set" if @name.nil? || @name.size == 0 if @cron.nil? || @cron.size == 0 errors << "'cron' must be set" else begin - cron = CronParser.new(@cron) - cron.next(Time.now) + cron = Rufus::Scheduler::CronLine.new(@cron) + cron.next_time(Time.now) rescue Exception => e #fix for different versions of cron-parser if e.message == "Bad Vixie-style specification bad" errors << "'cron' -> #{@cron}: not a valid cronline" else @@ -334,14 +334,11 @@ end # Parse cron specification '* * * * *' and returns # time when last run should be performed def last_time now = Time.now - # add 1 minute to Time now - Cron parser return last time after minute ends, - # so by adding 60 second we will get last time after the right time happens - # without any delay! - CronParser.new(@cron).last(now + 60) + Rufus::Scheduler::CronLine.new(@cron).previous_time(now) end def formated_last_time now = Time.now last_time(now).getutc end @@ -374,9 +371,11 @@ begin Sidekiq.load_json(args) rescue JSON::ParserError [*args] # cast to string array end + when Hash + [args] # just put hash into array when Array args # do nothing, already array else [*args] # cast to string array end