sidekiq-cron 0.6.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c9490a07af91904810a5289c0899691f70bb56b
4
- data.tar.gz: 4d79c982c22844a7f7fa887dde61925aaa26e48e
3
+ metadata.gz: 9d3a6a7e01403ef2040d6063bf5cbcb7e8ea5d18
4
+ data.tar.gz: de657abb0e9c518657e658630a86c21db81c0346
5
5
  SHA512:
6
- metadata.gz: c9717f01b61187ffb9cc2024ac3de6a01a1641159ef5f0013f742858a932b01c5a89dcb37abb254484cc1ca9edb6da10cf96fa7d0b2b068199945db18e855c3b
7
- data.tar.gz: a06735e8a699441b6b9a0218e99949710b44dc2a1fdf92725fe865594687e428cd7509efd04023a9a09d5f4580466ab117ad6ccc471ab2797fae804fef9a3ea8
6
+ metadata.gz: 8729b18fae10b77c09ec4eb578c912239feff496f9a6cd6d96c4d3ffd840513b24d096ce68d6efb05e68881bcd2866dd5434e27c8775fcad82da6424f67e87c5
7
+ data.tar.gz: 94260978f15acbd83c288dc5be7adcef976b7d10c33895824508f7d4d4d41d36cc9718f056de4718ff38e891641d879a8e1e5025a9b55f0d762c9a4a0e11f7e9
@@ -1,7 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
4
- - 2.2.2
3
+ - 2.5.0
4
+ - 2.4.3
5
+ - 2.3.6
6
+ - 2.2.9
5
7
  services:
6
8
  - redis-server
7
9
  branches:
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'sidekiq', '>= 4.2.1'
4
- gem 'rufus-scheduler', '>= 3.3.0'
4
+ gem 'fugit', '~> 1.1'
5
5
 
6
6
  group :development do
7
7
  gem 'bundler'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Sidekiq-Cron [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](http://badge.fury.io/rb/sidekiq-cron) [![Build Status](https://travis-ci.org/ondrejbartas/sidekiq-cron.svg?branch=master)](https://travis-ci.org/ondrejbartas/sidekiq-cron) [![Coverage Status](https://coveralls.io/repos/ondrejbartas/sidekiq-cron/badge.svg?branch=master)](https://coveralls.io/r/ondrejbartas/sidekiq-cron?branch=master) [![Dependency Status](https://dependencyci.com/github/ondrejbartas/sidekiq-cron/badge)](https://dependencyci.com/github/ondrejbartas/sidekiq-cron)
1
+ Sidekiq-Cron [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](http://badge.fury.io/rb/sidekiq-cron) [![Build Status](https://travis-ci.org/ondrejbartas/sidekiq-cron.svg?branch=master)](https://travis-ci.org/ondrejbartas/sidekiq-cron) [![Coverage Status](https://coveralls.io/repos/github/ondrejbartas/sidekiq-cron/badge.svg?branch=master)](https://coveralls.io/github/ondrejbartas/sidekiq-cron?branch=master)
2
2
  ================================================================================================================================================================================================================================================================================================================================================================================================================================================
3
3
 
4
4
  [![Join the chat at https://gitter.im/ondrejbartas/sidekiq-cron](https://badges.gitter.im/ondrejbartas/sidekiq-cron.svg)](https://gitter.im/ondrejbartas/sidekiq-cron?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -7,11 +7,11 @@ Sidekiq-Cron [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](http://
7
7
 
8
8
  A scheduling add-on for [Sidekiq](http://sidekiq.org).
9
9
 
10
- Runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Rufus-Scheduler](https://github.com/jmettraux/rufus-scheduler), more about [cron notation](http://www.nncron.ru/help/EN/working/cron-format.htm).
10
+ Runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Fugit](https://github.com/floraison/fugit), more about [cron notation](http://www.nncron.ru/help/EN/working/cron-format.htm).
11
11
 
12
- Checks for new jobs to schedule every 10 seconds and doesn't schedule the same job multiple times when more than one Sidekiq worker is running.
12
+ Checks for new jobs to schedule every 30 seconds and doesn't schedule the same job multiple times when more than one Sidekiq worker is running.
13
13
 
14
- Scheduling jobs are added only when at least one Sidekiq process is running.
14
+ Scheduling jobs are added only when at least one Sidekiq process is running, but it is safe to use Sidekiq-Cron in environments where multiple Sidekiq processes or nodes are running.
15
15
 
16
16
  If you want to know how scheduling work, check out [under the hood](#under-the-hood)
17
17
 
@@ -37,7 +37,7 @@ Installation
37
37
 
38
38
  or add to your `Gemfile`
39
39
 
40
- gem "sidekiq-cron", "~> 0.4.0"
40
+ gem "sidekiq-cron", "~> 0.6.3"
41
41
 
42
42
 
43
43
  Getting Started
@@ -64,11 +64,15 @@ _Job properties_:
64
64
 
65
65
  ### Time, cron and sidekiq-cron
66
66
 
67
- sidekiq-cron uses [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) to parse the cronline.
68
- By default, the timezone this is evaluated against UTC.
67
+ For testing your cron notation you can use [crontab.guru](https://crontab.guru).
68
+
69
+ sidekiq-cron uses [Fugit](https://github.com/floraison/fugit) to parse the cronline.
70
+ If using Rails, this is evaluated against the timezone configured in Rails, otherwise the default is UTC.
71
+
69
72
  If you want to have your jobs enqueued based on a different time zone you can specify a timezone in the cronline,
70
73
  like this `'0 22 * * 1-5 America/Chicago'`.
71
- See [rufus-scheduler documentation](https://github.com/jmettraux/rufus-scheduler#a-note-about-timezones) for more information.
74
+
75
+ See [rufus-scheduler documentation](https://github.com/jmettraux/rufus-scheduler#a-note-about-timezones) for more information. (note. Rufus scheduler is using Fugit under the hood, so documentation for Rufus Scheduler can help you also)
72
76
 
73
77
  ### What objects/classes can be scheduled
74
78
  #### Sidekiq Worker
@@ -192,7 +196,7 @@ second_job:
192
196
  #initializers/sidekiq.rb
193
197
  schedule_file = "config/schedule.yml"
194
198
 
195
- if File.exists?(schedule_file) && Sidekiq.server?
199
+ if File.exist?(schedule_file) && Sidekiq.server?
196
200
  Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
197
201
  end
198
202
  ```
@@ -263,13 +267,13 @@ before the process forks, causing the following exception
263
267
 
264
268
  Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
265
269
 
266
- to occcur. To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
270
+ to occur. To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
267
271
 
268
272
  ```ruby
269
273
  Sidekiq.configure_server do |config|
270
274
  schedule_file = "config/schedule.yml"
271
275
 
272
- if File.exists?(schedule_file)
276
+ if File.exist?(schedule_file)
273
277
  Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
274
278
  end
275
279
  end
@@ -288,6 +292,8 @@ Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can chang
288
292
  Sidekiq.options[:poll_interval] = 10
289
293
  ```
290
294
 
295
+ Sidekiq-Cron is safe to use with multiple sidekiq processes or nodes. It uses a Redis sorted set to determine that only the first process who asks can enqueue scheduled jobs into the queue.
296
+
291
297
  ## Thanks to
292
298
  * [@7korobi](https://github.com/7korobi)
293
299
  * [@antulik](https://github.com/antulik)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 1.0.0
@@ -1,6 +1,6 @@
1
+ require 'fugit'
1
2
  require 'sidekiq'
2
3
  require 'sidekiq/util'
3
- require 'rufus-scheduler'
4
4
  require 'sidekiq/cron/support'
5
5
 
6
6
  module Sidekiq
@@ -12,6 +12,7 @@ module Sidekiq
12
12
 
13
13
  #how long we would like to store informations about previous enqueues
14
14
  REMEMBER_THRESHOLD = 24 * 60 * 60
15
+ LAST_ENQUEUE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
15
16
 
16
17
  #crucial part of whole enquing job
17
18
  def should_enque? time
@@ -46,7 +47,7 @@ module Sidekiq
46
47
 
47
48
  #enque cron job to queue
48
49
  def enque! time = Time.now.utc
49
- @last_enqueue_time = time
50
+ @last_enqueue_time = time.strftime(LAST_ENQUEUE_TIME_FORMAT)
50
51
 
51
52
  klass_const =
52
53
  begin
@@ -123,6 +124,7 @@ module Sidekiq
123
124
  def active_job_message
124
125
  {
125
126
  'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',
127
+ 'wrapped' => @klass,
126
128
  'queue' => @queue_name_with_prefix,
127
129
  'description' => @description,
128
130
  'args' => [{
@@ -273,7 +275,7 @@ module Sidekiq
273
275
 
274
276
  #set last enqueue time - from args or from existing job
275
277
  if args['last_enqueue_time'] && !args['last_enqueue_time'].empty?
276
- @last_enqueue_time = Time.parse(args['last_enqueue_time'])
278
+ @last_enqueue_time = Time.strptime(args['last_enqueue_time'], LAST_ENQUEUE_TIME_FORMAT)
277
279
  else
278
280
  @last_enqueue_time = last_enqueue_time_from_redis
279
281
  end
@@ -362,7 +364,7 @@ module Sidekiq
362
364
  out = nil
363
365
  if fetch_missing_args
364
366
  Sidekiq.redis do |conn|
365
- out = Time.parse(conn.hget(redis_key, "last_enqueue_time")) rescue nil
367
+ out = Time.strptime(conn.hget(redis_key, "last_enqueue_time"), LAST_ENQUEUE_TIME_FORMAT) rescue nil
366
368
  end
367
369
  end
368
370
  out
@@ -390,7 +392,7 @@ module Sidekiq
390
392
  end
391
393
 
392
394
  def valid?
393
- #clear previos errors
395
+ #clear previous errors
394
396
  @errors = []
395
397
 
396
398
  errors << "'name' must be set" if @name.nil? || @name.size == 0
@@ -398,21 +400,15 @@ module Sidekiq
398
400
  errors << "'cron' must be set"
399
401
  else
400
402
  begin
401
- cron = Rufus::Scheduler::CronLine.new(@cron)
402
- cron.next_time(Time.now.utc).utc
403
- rescue Exception => e
404
- #fix for different versions of cron-parser
405
- if e.message == "Bad Vixie-style specification bad"
406
- errors << "'cron' -> #{@cron}: not a valid cronline"
407
- else
408
- errors << "'cron' -> #{@cron}: #{e.message}"
409
- end
403
+ @parsed_cron = Fugit.do_parse_cron(@cron)
404
+ rescue => e
405
+ errors << "'cron' -> #{@cron.inspect} -> #{e.class}: #{e.message}"
410
406
  end
411
407
  end
412
408
 
413
409
  errors << "'klass' (or class) must be set" unless klass_valid
414
410
 
415
- !errors.any?
411
+ errors.empty?
416
412
  end
417
413
 
418
414
  def klass_valid
@@ -496,7 +492,7 @@ module Sidekiq
496
492
  # Parse cron specification '* * * * *' and returns
497
493
  # time when last run should be performed
498
494
  def last_time now = Time.now.utc
499
- Rufus::Scheduler::CronLine.new(@cron).previous_time(now.utc).utc
495
+ parsed_cron.previous_time(now.utc).utc
500
496
  end
501
497
 
502
498
  def formated_enqueue_time now = Time.now.utc
@@ -525,6 +521,10 @@ module Sidekiq
525
521
 
526
522
  private
527
523
 
524
+ def parsed_cron
525
+ @parsed_cron ||= Fugit.parse_cron(@cron)
526
+ end
527
+
528
528
  def not_enqueued_after?(time)
529
529
  @last_enqueue_time.nil? || @last_enqueue_time.to_i < last_time(time).to_i
530
530
  end
@@ -551,7 +551,9 @@ module Sidekiq
551
551
  end
552
552
 
553
553
  def not_past_scheduled_time?(current_time)
554
- last_cron_time = Rufus::Scheduler::CronLine.new(@cron).previous_time(current_time).utc
554
+ last_cron_time = parsed_cron.previous_time(current_time).utc
555
+ # or could it be?
556
+ #last_cron_time = last_time(current_time)
555
557
  return false if (current_time.to_i - last_cron_time.to_i) > 60
556
558
  true
557
559
  end
@@ -0,0 +1,18 @@
1
+ ja:
2
+ Job: ジョブ
3
+ Cron: Cron
4
+ CronJobs: Cronジョブ
5
+ EnqueueNow: すぐにキューに入れる
6
+ EnableAll: すべて有効にする
7
+ DisableAll: すべて無効にする
8
+ EnqueueAll: すべてキューに入れる
9
+ DeleteAll: すべて削除
10
+ 'Cron string': Cron
11
+ AreYouSureDeleteCronJobs: 本当にすべてのcronジョブを削除しますか?
12
+ AreYouSureDeleteCronJob: 本当に%{job}のcronジョブを削除しますか?
13
+ NoCronJobsFound: Cronジョブが見つかりませんでした
14
+ Enable: 有効にする
15
+ Disable: 無効にする
16
+ 'Last enque': 最後のキュー
17
+ disabled: 無効
18
+ enabled: 有効
@@ -0,0 +1,19 @@
1
+ zh-CN:
2
+ Job: 任务
3
+ Cron: 定时任务
4
+ CronJobs: 定时任务列表
5
+ EnqueueNow: 立刻执行
6
+ EnableAll: 启用所有
7
+ DisableAll: 禁用所有
8
+ EnqueueAll: 执行所有
9
+ DeleteAll: 删除所有
10
+ 'Cron string': 定时策略
11
+ AreYouSureDeleteCronJobs: 你确定删除所有的定时任务吗?
12
+ AreYouSureDeleteCronJob: 你确定删除定时任务(%{job})吗?
13
+ NoCronJobsFound: 没有定时任务
14
+ Enable: 启用
15
+ Disable: 禁用
16
+ 'Last enque': 放入队列时间
17
+ disabled: 已禁用
18
+ enabled: 已启用
19
+
@@ -19,6 +19,7 @@ module Sidekiq
19
19
  # Punt and try again at the next interval
20
20
  logger.error ex.message
21
21
  logger.error ex.backtrace.first
22
+ handle_exception(ex) if respond_to?(:handle_exception)
22
23
  end
23
24
 
24
25
  private
@@ -29,6 +30,7 @@ module Sidekiq
29
30
  # problem somewhere in one job
30
31
  logger.error "CRON JOB: #{ex.message}"
31
32
  logger.error "CRON JOB: #{ex.backtrace.first}"
33
+ handle_exception(ex) if respond_to?(:handle_exception)
32
34
  end
33
35
 
34
36
  def poll_interval_average
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: sidekiq-cron 0.6.3 ruby lib
5
+ # stub: sidekiq-cron 1.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "sidekiq-cron"
9
- s.version = "0.6.3"
9
+ s.version = "1.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Ondrej Bartas"]
14
- s.date = "2017-06-20"
14
+ s.date = "2018-07-09"
15
15
  s.description = "Enables to set jobs to be run in specified time (using CRON notation)"
16
16
  s.email = "ondrej@bartas.cz"
17
17
  s.extra_rdoc_files = [
@@ -37,7 +37,9 @@ Gem::Specification.new do |s|
37
37
  "lib/sidekiq/cron/launcher.rb",
38
38
  "lib/sidekiq/cron/locales/de.yml",
39
39
  "lib/sidekiq/cron/locales/en.yml",
40
+ "lib/sidekiq/cron/locales/ja.yml",
40
41
  "lib/sidekiq/cron/locales/ru.yml",
42
+ "lib/sidekiq/cron/locales/zh-CN.yml",
41
43
  "lib/sidekiq/cron/poller.rb",
42
44
  "lib/sidekiq/cron/support.rb",
43
45
  "lib/sidekiq/cron/views/cron.erb",
@@ -61,7 +63,7 @@ Gem::Specification.new do |s|
61
63
 
62
64
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
65
  s.add_runtime_dependency(%q<sidekiq>, [">= 4.2.1"])
64
- s.add_runtime_dependency(%q<rufus-scheduler>, [">= 3.3.0"])
66
+ s.add_runtime_dependency(%q<fugit>, ["~> 1.1"])
65
67
  s.add_development_dependency(%q<bundler>, [">= 0"])
66
68
  s.add_development_dependency(%q<simplecov>, [">= 0"])
67
69
  s.add_development_dependency(%q<redis-namespace>, [">= 1.5.2"])
@@ -81,7 +83,7 @@ Gem::Specification.new do |s|
81
83
  s.add_development_dependency(%q<guard-minitest>, [">= 0"])
82
84
  else
83
85
  s.add_dependency(%q<sidekiq>, [">= 4.2.1"])
84
- s.add_dependency(%q<rufus-scheduler>, [">= 3.3.0"])
86
+ s.add_dependency(%q<fugit>, ["~> 1.1"])
85
87
  s.add_dependency(%q<bundler>, [">= 0"])
86
88
  s.add_dependency(%q<simplecov>, [">= 0"])
87
89
  s.add_dependency(%q<redis-namespace>, [">= 1.5.2"])
@@ -102,7 +104,7 @@ Gem::Specification.new do |s|
102
104
  end
103
105
  else
104
106
  s.add_dependency(%q<sidekiq>, [">= 4.2.1"])
105
- s.add_dependency(%q<rufus-scheduler>, [">= 3.3.0"])
107
+ s.add_dependency(%q<fugit>, ["~> 1.1"])
106
108
  s.add_dependency(%q<bundler>, [">= 0"])
107
109
  s.add_dependency(%q<simplecov>, [">= 0"])
108
110
  s.add_dependency(%q<redis-namespace>, [">= 1.5.2"])
@@ -2,7 +2,7 @@
2
2
  require './test/test_helper'
3
3
  require 'benchmark'
4
4
 
5
- describe 'Perfromance Poller' do
5
+ describe 'Performance Poller' do
6
6
  X = 10000
7
7
  before do
8
8
  Sidekiq.redis = REDIS
@@ -28,8 +28,8 @@ describe 'Perfromance Poller' do
28
28
  end
29
29
 
30
30
  @poller = Sidekiq::Cron::Poller.new
31
- now = Time.now.utc
32
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 10, 5)
31
+ now = Time.now.utc + 3600
32
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 10, 5)
33
33
  Time.stubs(:now).returns(enqueued_time)
34
34
  end
35
35
 
@@ -46,7 +46,7 @@ describe 'Perfromance Poller' do
46
46
  assert_equal X, conn.llen("queue:default"), 'Queue should be full'
47
47
  end
48
48
 
49
- puts "Perfomance test finished in #{bench.real}"
50
- assert_operator 30, :>, bench.real
49
+ puts "Performance test finished in #{bench.real}"
50
+ assert_operator bench.real, :<, 30
51
51
  end
52
52
  end
@@ -210,24 +210,24 @@ describe "Cron Job" do
210
210
 
211
211
  it "return previous minute" do
212
212
  @job.cron = "* * * * *"
213
- time = Time.now.utc
213
+ time = Time.new(2018, 8, 10, 13, 24, 56).utc
214
214
  assert_equal @job.last_time(time).strftime("%Y-%m-%d-%H-%M-%S"), time.strftime("%Y-%m-%d-%H-%M-00")
215
215
  end
216
216
 
217
217
  it "return previous hour" do
218
218
  @job.cron = "1 * * * *"
219
- time = Time.now.utc
219
+ time = Time.new(2018, 8, 10, 13, 24, 56).utc
220
220
  assert_equal @job.last_time(time).strftime("%Y-%m-%d-%H-%M-%S"), time.strftime("%Y-%m-%d-%H-01-00")
221
221
  end
222
222
 
223
223
  it "return previous day" do
224
224
  @job.cron = "1 2 * * * Etc/GMT"
225
- time = Time.now.utc
225
+ time = Time.new(2018, 8, 10, 13, 24, 56).utc
226
226
 
227
227
  if time.hour >= 2
228
228
  assert_equal @job.last_time(time).strftime("%Y-%m-%d-%H-%M-%S"), time.strftime("%Y-%m-%d-02-01-00")
229
229
  else
230
- yesterday = (Date.today - 1)
230
+ yesterday = time - 1.day
231
231
  assert_equal @job.last_time(time).strftime("%Y-%m-%d-%H-%M-%S"), yesterday.strftime("%Y-%m-%d-02-01-00")
232
232
  end
233
233
  end
@@ -299,6 +299,7 @@ describe "Cron Job" do
299
299
  it 'should return valid payload for Sidekiq::Client' do
300
300
  payload = {
301
301
  'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',
302
+ 'wrapped' => 'ActiveJobCronTestClass',
302
303
  'queue' => 'super_queue',
303
304
  'description' => nil,
304
305
  'args' => [{
@@ -330,10 +331,11 @@ describe "Cron Job" do
330
331
 
331
332
  it 'should return valid payload for Sidekiq::Client' do
332
333
  payload = {
333
- 'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',
334
- 'queue' => 'prefix_super_queue',
334
+ 'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',
335
+ 'wrapped' => 'ActiveJobCronTestClass',
336
+ 'queue' => 'prefix_super_queue',
335
337
  'description' => nil,
336
- 'args' =>[{
338
+ 'args' => [{
337
339
  'job_class' => 'ActiveJobCronTestClass',
338
340
  'job_id' => 'XYZ',
339
341
  'queue_name' => 'prefix_super_queue',
@@ -522,7 +524,6 @@ describe "Cron Job" do
522
524
  assert @job.save
523
525
  end
524
526
 
525
-
526
527
  it "be saved and found by name" do
527
528
  assert @job.save, "not saved"
528
529
  assert Sidekiq::Cron::Job.find("Test").is_a?(Sidekiq::Cron::Job)
@@ -883,7 +884,7 @@ describe "Cron Job" do
883
884
  @jobs_hash['name_of_job']['cron'] = "bad cron"
884
885
  out = Sidekiq::Cron::Job.load_from_hash @jobs_hash
885
886
  assert_equal 1, out.size, "should have 1 error"
886
- assert_equal ({"name_of_job"=>["'cron' -> bad cron: not a valid cronline : 'bad cron'"]}), out
887
+ assert_equal ({"name_of_job"=>["'cron' -> \"bad cron\" -> ArgumentError: not a cron string \"bad cron\""]}), out
887
888
  assert_equal 1, Sidekiq::Cron::Job.all.size, "Should have only 1 job after load"
888
889
  end
889
890
 
@@ -28,8 +28,8 @@ describe 'Cron Poller' do
28
28
  end
29
29
 
30
30
  it 'not enqueue any job - new jobs' do
31
- now = Time.now.utc
32
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 5, 1)
31
+ now = Time.now.utc + 3600
32
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 5, 1)
33
33
  Time.stubs(:now).returns(enqueued_time)
34
34
  #new jobs!
35
35
  Sidekiq::Cron::Job.create(@args)
@@ -43,19 +43,20 @@ describe 'Cron Poller' do
43
43
  end
44
44
 
45
45
  #30 seconds after!
46
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 5, 30)
46
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 5, 30)
47
47
  Time.stubs(:now).returns(enqueued_time)
48
- @poller.enqueue
49
48
 
50
- Sidekiq.redis do |conn|
51
- assert_equal 0, conn.llen("queue:default")
52
- assert_equal 0, conn.llen("queue:super")
53
- end
49
+ @poller.enqueue
50
+
51
+ Sidekiq.redis do |conn|
52
+ assert_equal 0, conn.llen("queue:default")
53
+ assert_equal 0, conn.llen("queue:super")
54
+ end
54
55
  end
55
56
 
56
57
  it 'should enqueue only job with cron */2' do
57
- now = Time.now.utc
58
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 5, 1)
58
+ now = Time.now.utc + 3600
59
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 5, 1)
59
60
  Time.stubs(:now).returns(enqueued_time)
60
61
  #new jobs!
61
62
  Sidekiq::Cron::Job.create(@args)
@@ -68,7 +69,7 @@ describe 'Cron Poller' do
68
69
  assert_equal 0, conn.llen("queue:super")
69
70
  end
70
71
 
71
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 6, 1)
72
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 6, 1)
72
73
  Time.stubs(:now).returns(enqueued_time)
73
74
  @poller.enqueue
74
75
 
@@ -79,8 +80,8 @@ describe 'Cron Poller' do
79
80
  end
80
81
 
81
82
  it 'should enqueue both jobs' do
82
- now = Time.now.utc
83
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 8, 1)
83
+ now = Time.now.utc + 3600
84
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 8, 1)
84
85
  Time.stubs(:now).returns(enqueued_time)
85
86
  #new jobs!
86
87
  Sidekiq::Cron::Job.create(@args)
@@ -93,7 +94,7 @@ describe 'Cron Poller' do
93
94
  assert_equal 0, conn.llen("queue:super")
94
95
  end
95
96
 
96
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 10, 5)
97
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 10, 5)
97
98
  Time.stubs(:now).returns(enqueued_time)
98
99
  @poller.enqueue
99
100
 
@@ -104,8 +105,8 @@ describe 'Cron Poller' do
104
105
  end
105
106
 
106
107
  it 'should enqueue both jobs but only one time each' do
107
- now = Time.now.utc
108
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 8, 1)
108
+ now = Time.now.utc + 3600
109
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 8, 1)
109
110
  Time.stubs(:now).returns(enqueued_time)
110
111
  #new jobs!
111
112
  Sidekiq::Cron::Job.create(@args)
@@ -118,7 +119,7 @@ describe 'Cron Poller' do
118
119
  assert_equal 0, conn.llen("queue:super")
119
120
  end
120
121
 
121
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 20, 1)
122
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 20, 1)
122
123
  Time.stubs(:now).returns(enqueued_time)
123
124
  @poller.enqueue
124
125
  Sidekiq.redis do |conn|
@@ -126,7 +127,7 @@ describe 'Cron Poller' do
126
127
  assert_equal 1, conn.llen("queue:super")
127
128
  end
128
129
 
129
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 20, 2)
130
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 20, 2)
130
131
  Time.stubs(:now).returns(enqueued_time)
131
132
  @poller.enqueue
132
133
  Sidekiq.redis do |conn|
@@ -134,7 +135,7 @@ describe 'Cron Poller' do
134
135
  assert_equal 1, conn.llen("queue:super")
135
136
  end
136
137
 
137
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 20, 20)
138
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 20, 20)
138
139
  Time.stubs(:now).returns(enqueued_time)
139
140
  @poller.enqueue
140
141
  Sidekiq.redis do |conn|
@@ -142,7 +143,7 @@ describe 'Cron Poller' do
142
143
  assert_equal 1, conn.llen("queue:super")
143
144
  end
144
145
 
145
- enqueued_time = Time.new(now.year, now.month, now.day, now.hour + 1, 20, 50)
146
+ enqueued_time = Time.new(now.year, now.month, now.day, now.hour, 20, 50)
146
147
  Time.stubs(:now).returns(enqueued_time)
147
148
  @poller.enqueue
148
149
  Sidekiq.redis do |conn|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-20 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: rufus-scheduler
28
+ name: fugit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.3.0
33
+ version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.3.0
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -302,7 +302,9 @@ files:
302
302
  - lib/sidekiq/cron/launcher.rb
303
303
  - lib/sidekiq/cron/locales/de.yml
304
304
  - lib/sidekiq/cron/locales/en.yml
305
+ - lib/sidekiq/cron/locales/ja.yml
305
306
  - lib/sidekiq/cron/locales/ru.yml
307
+ - lib/sidekiq/cron/locales/zh-CN.yml
306
308
  - lib/sidekiq/cron/poller.rb
307
309
  - lib/sidekiq/cron/support.rb
308
310
  - lib/sidekiq/cron/views/cron.erb