sidekiq-cron 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -4
- data/VERSION +1 -1
- data/lib/sidekiq/cron/job.rb +15 -4
- data/sidekiq-cron.gemspec +5 -2
- data/test/test_helper.rb +1 -0
- data/test/unit/job_test.rb +12 -0
- metadata +19 -3
data/Gemfile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gem 'tilt' , '< 2.0.0'
|
3
4
|
gem "sidekiq", ">= 2.17.3"
|
4
5
|
gem 'rufus-scheduler', '>= 2.0.24'
|
5
6
|
|
6
7
|
group :development do
|
7
8
|
gem "bundler"
|
8
9
|
gem "simplecov"
|
9
|
-
|
10
|
+
|
10
11
|
gem 'shoulda-context'
|
11
12
|
gem "turn"
|
12
13
|
|
@@ -14,12 +15,12 @@ group :development do
|
|
14
15
|
gem 'rack-test'
|
15
16
|
|
16
17
|
gem "jeweler", "~> 1.8.3"
|
17
|
-
|
18
|
+
|
18
19
|
gem "sdoc" # sdoc -N .
|
19
|
-
|
20
|
+
|
20
21
|
gem "slim"
|
21
22
|
gem "sinatra"
|
22
|
-
|
23
|
+
|
23
24
|
gem 'mocha'
|
24
25
|
gem 'coveralls'
|
25
26
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -168,8 +168,11 @@ module Sidekiq
|
|
168
168
|
#set status of job
|
169
169
|
@status = args['status'] || status_from_redis
|
170
170
|
|
171
|
+
#set last enqueue time - from args or from existing job
|
171
172
|
if args['last_enqueue_time'] && !args['last_enqueue_time'].empty?
|
172
173
|
@last_enqueue_time = Time.parse(args['last_enqueue_time'])
|
174
|
+
else
|
175
|
+
@last_enqueue_time = last_enqueue_time_from_redis
|
173
176
|
end
|
174
177
|
|
175
178
|
#get right arguments for job
|
@@ -223,15 +226,23 @@ module Sidekiq
|
|
223
226
|
end
|
224
227
|
|
225
228
|
def status_from_redis
|
229
|
+
out = "enabled"
|
226
230
|
if exists?
|
227
|
-
out = "enabled"
|
228
231
|
Sidekiq.redis do |conn|
|
229
232
|
out = conn.hget redis_key, "status"
|
230
233
|
end
|
231
|
-
out
|
232
|
-
else
|
233
|
-
"enabled"
|
234
234
|
end
|
235
|
+
out
|
236
|
+
end
|
237
|
+
|
238
|
+
def last_enqueue_time_from_redis
|
239
|
+
out = nil
|
240
|
+
if exists?
|
241
|
+
Sidekiq.redis do |conn|
|
242
|
+
out = Time.parse(conn.hget(redis_key, "last_enqueue_time")) rescue nil
|
243
|
+
end
|
244
|
+
end
|
245
|
+
out
|
235
246
|
end
|
236
247
|
|
237
248
|
#export job data to hash
|
data/sidekiq-cron.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "sidekiq-cron"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ondrej Bartas"]
|
12
|
-
s.date = "2014-01-
|
12
|
+
s.date = "2014-01-31"
|
13
13
|
s.description = "Enables to set jobs to be run in specified time (using CRON notation)"
|
14
14
|
s.email = "ondrej@bartas.cz"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -53,6 +53,7 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.specification_version = 3
|
54
54
|
|
55
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<tilt>, ["< 2.0.0"])
|
56
57
|
s.add_runtime_dependency(%q<sidekiq>, [">= 2.17.3"])
|
57
58
|
s.add_runtime_dependency(%q<rufus-scheduler>, [">= 2.0.24"])
|
58
59
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
@@ -69,6 +70,7 @@ Gem::Specification.new do |s|
|
|
69
70
|
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
70
71
|
s.add_development_dependency(%q<shotgun>, [">= 0"])
|
71
72
|
else
|
73
|
+
s.add_dependency(%q<tilt>, ["< 2.0.0"])
|
72
74
|
s.add_dependency(%q<sidekiq>, [">= 2.17.3"])
|
73
75
|
s.add_dependency(%q<rufus-scheduler>, [">= 2.0.24"])
|
74
76
|
s.add_dependency(%q<bundler>, [">= 0"])
|
@@ -86,6 +88,7 @@ Gem::Specification.new do |s|
|
|
86
88
|
s.add_dependency(%q<shotgun>, [">= 0"])
|
87
89
|
end
|
88
90
|
else
|
91
|
+
s.add_dependency(%q<tilt>, ["< 2.0.0"])
|
89
92
|
s.add_dependency(%q<sidekiq>, [">= 2.17.3"])
|
90
93
|
s.add_dependency(%q<rufus-scheduler>, [">= 2.0.24"])
|
91
94
|
s.add_dependency(%q<bundler>, [">= 0"])
|
data/test/test_helper.rb
CHANGED
data/test/unit/job_test.rb
CHANGED
@@ -291,6 +291,18 @@ class CronJobTest < Test::Unit::TestCase
|
|
291
291
|
job = Sidekiq::Cron::Job.find(@args)
|
292
292
|
assert_equal job.status, "disabled", "after second find"
|
293
293
|
end
|
294
|
+
|
295
|
+
should "last_enqueue_time shouldn't be rewritten after save" do
|
296
|
+
#adding last_enqueue_time to initialize is only for test purpose
|
297
|
+
last_enqueue_time = '2013-01-01 23:59:59'
|
298
|
+
Sidekiq::Cron::Job.create(@args.merge('last_enqueue_time' => last_enqueue_time))
|
299
|
+
job = Sidekiq::Cron::Job.find(@args)
|
300
|
+
assert_equal job.last_enqueue_time, Time.parse(last_enqueue_time)
|
301
|
+
|
302
|
+
Sidekiq::Cron::Job.create(@args)
|
303
|
+
job = Sidekiq::Cron::Job.find(@args)
|
304
|
+
assert_equal job.last_enqueue_time, Time.parse(last_enqueue_time), "after second create should have same time"
|
305
|
+
end
|
294
306
|
end
|
295
307
|
|
296
308
|
context "initialize args" do
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: tilt
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - <
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: sidekiq
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -299,7 +315,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
299
315
|
version: '0'
|
300
316
|
segments:
|
301
317
|
- 0
|
302
|
-
hash: -
|
318
|
+
hash: -1703053486073250500
|
303
319
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
320
|
none: false
|
305
321
|
requirements:
|