sidekiq-cron 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/VERSION +1 -1
- data/lib/sidekiq/cron/job.rb +9 -7
- data/lib/sidekiq/cron/support.rb +38 -0
- data/sidekiq-cron.gemspec +10 -3
- data/test/test_helper.rb +3 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c9490a07af91904810a5289c0899691f70bb56b
|
4
|
+
data.tar.gz: 4d79c982c22844a7f7fa887dde61925aaa26e48e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9717f01b61187ffb9cc2024ac3de6a01a1641159ef5f0013f742858a932b01c5a89dcb37abb254484cc1ca9edb6da10cf96fa7d0b2b068199945db18e855c3b
|
7
|
+
data.tar.gz: a06735e8a699441b6b9a0218e99949710b44dc2a1fdf92725fe865594687e428cd7509efd04023a9a09d5f4580466ab117ad6ccc471ab2797fae804fef9a3ea8
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.3
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'sidekiq'
|
2
2
|
require 'sidekiq/util'
|
3
3
|
require 'rufus-scheduler'
|
4
|
+
require 'sidekiq/cron/support'
|
4
5
|
|
5
6
|
module Sidekiq
|
6
7
|
module Cron
|
@@ -49,7 +50,7 @@ module Sidekiq
|
|
49
50
|
|
50
51
|
klass_const =
|
51
52
|
begin
|
52
|
-
@klass.to_s
|
53
|
+
Sidekiq::Cron::Support.constantize(@klass.to_s)
|
53
54
|
rescue NameError
|
54
55
|
nil
|
55
56
|
end
|
@@ -73,7 +74,7 @@ module Sidekiq
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def is_active_job?
|
76
|
-
@active_job || defined?(ActiveJob::Base) && @klass.to_s
|
77
|
+
@active_job || defined?(ActiveJob::Base) && Sidekiq::Cron::Support.constantize(@klass.to_s) < ActiveJob::Base
|
77
78
|
rescue NameError
|
78
79
|
false
|
79
80
|
end
|
@@ -296,18 +297,19 @@ module Sidekiq
|
|
296
297
|
|
297
298
|
#get right data for message
|
298
299
|
#only if message wasn't specified before
|
299
|
-
|
300
|
+
klass_data = case @klass
|
300
301
|
when Class
|
301
|
-
@klass.get_sidekiq_options
|
302
|
+
@klass.get_sidekiq_options
|
302
303
|
when String
|
303
304
|
begin
|
304
|
-
@klass.
|
305
|
-
rescue
|
305
|
+
Sidekiq::Cron::Support.constantize(@klass).get_sidekiq_options
|
306
|
+
rescue Exception => e
|
306
307
|
#Unknown class
|
307
|
-
|
308
|
+
{"queue"=>"default"}
|
308
309
|
end
|
309
310
|
end
|
310
311
|
|
312
|
+
message_data = klass_data.merge(message_data)
|
311
313
|
#override queue if setted in config
|
312
314
|
#only if message is hash - can be string (dumped JSON)
|
313
315
|
if args['queue']
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# https://github.com/rails/rails/blob/352865d0f835c24daa9a2e9863dcc9dde9e5371a/activesupport/lib/active_support/inflector/methods.rb#L270
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Cron
|
5
|
+
module Support
|
6
|
+
def self.constantize(camel_cased_word)
|
7
|
+
names = camel_cased_word.split("::".freeze)
|
8
|
+
|
9
|
+
# Trigger a built-in NameError exception including the ill-formed constant in the message.
|
10
|
+
Object.const_get(camel_cased_word) if names.empty?
|
11
|
+
|
12
|
+
# Remove the first blank element in case of '::ClassName' notation.
|
13
|
+
names.shift if names.size > 1 && names.first.empty?
|
14
|
+
|
15
|
+
names.inject(Object) do |constant, name|
|
16
|
+
if constant == Object
|
17
|
+
constant.const_get(name)
|
18
|
+
else
|
19
|
+
candidate = constant.const_get(name)
|
20
|
+
next candidate if constant.const_defined?(name, false)
|
21
|
+
next candidate unless Object.const_defined?(name)
|
22
|
+
|
23
|
+
# Go down the ancestors to check if it is owned directly. The check
|
24
|
+
# stops when we reach Object or the end of ancestors tree.
|
25
|
+
constant = constant.ancestors.inject(constant) do |const, ancestor|
|
26
|
+
break const if ancestor == Object
|
27
|
+
break ancestor if ancestor.const_defined?(name, false)
|
28
|
+
const
|
29
|
+
end
|
30
|
+
|
31
|
+
# owner is in Object, so raise
|
32
|
+
constant.const_get(name, false)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/sidekiq-cron.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.
|
5
|
+
# stub: sidekiq-cron 0.6.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sidekiq-cron"
|
9
|
-
s.version = "0.6.
|
9
|
+
s.version = "0.6.3"
|
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"]
|
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
"lib/sidekiq/cron/locales/en.yml",
|
40
40
|
"lib/sidekiq/cron/locales/ru.yml",
|
41
41
|
"lib/sidekiq/cron/poller.rb",
|
42
|
+
"lib/sidekiq/cron/support.rb",
|
42
43
|
"lib/sidekiq/cron/views/cron.erb",
|
43
44
|
"lib/sidekiq/cron/views/cron.slim",
|
44
45
|
"lib/sidekiq/cron/web.rb",
|
@@ -52,7 +53,7 @@ Gem::Specification.new do |s|
|
|
52
53
|
]
|
53
54
|
s.homepage = "http://github.com/ondrejbartas/sidekiq-cron"
|
54
55
|
s.licenses = ["MIT"]
|
55
|
-
s.rubygems_version = "2.
|
56
|
+
s.rubygems_version = "2.5.1"
|
56
57
|
s.summary = "Sidekiq Cron helps to add repeated scheduled jobs"
|
57
58
|
|
58
59
|
if s.respond_to? :specification_version then
|
@@ -76,6 +77,8 @@ Gem::Specification.new do |s|
|
|
76
77
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
77
78
|
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
78
79
|
s.add_development_dependency(%q<shotgun>, [">= 0"])
|
80
|
+
s.add_development_dependency(%q<guard>, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<guard-minitest>, [">= 0"])
|
79
82
|
else
|
80
83
|
s.add_dependency(%q<sidekiq>, [">= 4.2.1"])
|
81
84
|
s.add_dependency(%q<rufus-scheduler>, [">= 3.3.0"])
|
@@ -94,6 +97,8 @@ Gem::Specification.new do |s|
|
|
94
97
|
s.add_dependency(%q<mocha>, [">= 0"])
|
95
98
|
s.add_dependency(%q<coveralls>, [">= 0"])
|
96
99
|
s.add_dependency(%q<shotgun>, [">= 0"])
|
100
|
+
s.add_dependency(%q<guard>, [">= 0"])
|
101
|
+
s.add_dependency(%q<guard-minitest>, [">= 0"])
|
97
102
|
end
|
98
103
|
else
|
99
104
|
s.add_dependency(%q<sidekiq>, [">= 4.2.1"])
|
@@ -113,6 +118,8 @@ Gem::Specification.new do |s|
|
|
113
118
|
s.add_dependency(%q<mocha>, [">= 0"])
|
114
119
|
s.add_dependency(%q<coveralls>, [">= 0"])
|
115
120
|
s.add_dependency(%q<shotgun>, [">= 0"])
|
121
|
+
s.add_dependency(%q<guard>, [">= 0"])
|
122
|
+
s.add_dependency(%q<guard-minitest>, [">= 0"])
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
data/test/test_helper.rb
CHANGED
@@ -44,9 +44,11 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
44
44
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
45
45
|
require 'sidekiq-cron'
|
46
46
|
require 'sidekiq/cron/web'
|
47
|
+
require 'pp'
|
47
48
|
|
48
49
|
class CronTestClass
|
49
50
|
include Sidekiq::Worker
|
51
|
+
sidekiq_options retry: true
|
50
52
|
|
51
53
|
def perform args = {}
|
52
54
|
puts "super croned job #{args}"
|
@@ -55,7 +57,7 @@ end
|
|
55
57
|
|
56
58
|
class CronTestClassWithQueue
|
57
59
|
include Sidekiq::Worker
|
58
|
-
sidekiq_options :
|
60
|
+
sidekiq_options queue: :super, retry: false, backtrace: true
|
59
61
|
|
60
62
|
def perform args = {}
|
61
63
|
puts "super croned job #{args}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-cron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondrej Bartas
|
@@ -248,6 +248,34 @@ dependencies:
|
|
248
248
|
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: guard
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: guard-minitest
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
251
279
|
description: Enables to set jobs to be run in specified time (using CRON notation)
|
252
280
|
email: ondrej@bartas.cz
|
253
281
|
executables: []
|
@@ -276,6 +304,7 @@ files:
|
|
276
304
|
- lib/sidekiq/cron/locales/en.yml
|
277
305
|
- lib/sidekiq/cron/locales/ru.yml
|
278
306
|
- lib/sidekiq/cron/poller.rb
|
307
|
+
- lib/sidekiq/cron/support.rb
|
279
308
|
- lib/sidekiq/cron/views/cron.erb
|
280
309
|
- lib/sidekiq/cron/views/cron.slim
|
281
310
|
- lib/sidekiq/cron/web.rb
|
@@ -306,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
335
|
version: '0'
|
307
336
|
requirements: []
|
308
337
|
rubyforge_project:
|
309
|
-
rubygems_version: 2.
|
338
|
+
rubygems_version: 2.5.1
|
310
339
|
signing_key:
|
311
340
|
specification_version: 4
|
312
341
|
summary: Sidekiq Cron helps to add repeated scheduled jobs
|