delayed_cron 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/delayed_cron.gemspec +0 -1
- data/lib/delayed_cron/jobs.rb +1 -0
- data/lib/delayed_cron/jobs/sidekiq.rb +1 -1
- data/lib/delayed_cron/version.rb +1 -1
- data/spec/delayed_cron_spec.rb +15 -15
- data/spec/scheduling_spec.rb +1 -1
- metadata +28 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 794d097692d2a62b9afda86ab4ef063222346956
|
4
|
+
data.tar.gz: 9ec982d8f66359e2c385cde299f4c152cd0ab934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb6954c254ec218b44ac7266135ada9d2213c63f82bf346057bae07dd336ddb8737fe3777762757c720c616669d581992d6123823971e08c09bb2f58186facb
|
7
|
+
data.tar.gz: f6982f58ca882e82d32ead011b243c9f3ea85dc67372b9c8ca166debe0d32aa3e79d7ceaa721ce525c750b7d890042dc524ce7ebdef298dbde5e4f3ce05b4b85
|
data/README.md
CHANGED
data/delayed_cron.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency "rspec-sidekiq"
|
22
22
|
s.add_development_dependency "codeclimate-test-reporter"
|
23
23
|
s.add_development_dependency "hashie"
|
24
|
-
s.add_development_dependency "debugger"
|
25
24
|
|
26
25
|
s.files = `git ls-files`.split("\n")
|
27
26
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/delayed_cron/jobs.rb
CHANGED
@@ -10,7 +10,7 @@ module DelayedCron
|
|
10
10
|
def self.enqueue_delayed_cron(klass, method_name, options)
|
11
11
|
options.symbolize_keys!
|
12
12
|
unless do_not_enqueue?(klass, method_name, options)
|
13
|
-
perform_in(options[:interval], klass, method_name, options)
|
13
|
+
perform_in(options[:interval].to_i, klass, method_name, options)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/delayed_cron/version.rb
CHANGED
data/spec/delayed_cron_spec.rb
CHANGED
@@ -8,12 +8,12 @@ describe DelayedCron do
|
|
8
8
|
|
9
9
|
it "yields self" do
|
10
10
|
DelayedCron.setup do |config|
|
11
|
-
DelayedCron.
|
11
|
+
expect(DelayedCron).to eq(config)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "sends cron jobs to define_cron_jobs" do
|
16
|
-
DelayedCron.
|
16
|
+
expect(DelayedCron).to receive(:define_cron_jobs)
|
17
17
|
setup(default_interval: 1.hour)
|
18
18
|
end
|
19
19
|
|
@@ -23,12 +23,12 @@ describe DelayedCron do
|
|
23
23
|
|
24
24
|
it "should have a default_interval" do
|
25
25
|
setup(default_interval: 1.hour)
|
26
|
-
DelayedCron.default_interval.
|
26
|
+
expect(DelayedCron.default_interval).not_to be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should have an array of cron_jobs" do
|
30
30
|
setup(default_interval: 1.hour)
|
31
|
-
DelayedCron.cron_jobs.
|
31
|
+
expect(DelayedCron.cron_jobs).to be_an(Array)
|
32
32
|
end
|
33
33
|
|
34
34
|
let(:options) do
|
@@ -46,7 +46,7 @@ describe DelayedCron do
|
|
46
46
|
job_is_hash = cron_job.is_a?(Hash)
|
47
47
|
klass, method_name = job_is_hash ? cron_job[:job].split(".") : cron_job.split(".")
|
48
48
|
interval = job_is_hash ? cron_job[:interval] : options[:default_interval]
|
49
|
-
DelayedCron.
|
49
|
+
expect(DelayedCron).to receive(:schedule).with(klass, method_name, { interval: interval })
|
50
50
|
end
|
51
51
|
setup(options)
|
52
52
|
end
|
@@ -56,7 +56,7 @@ describe DelayedCron do
|
|
56
56
|
describe ".processor" do
|
57
57
|
|
58
58
|
it "returns processor" do
|
59
|
-
DelayedCron.processor.
|
59
|
+
expect(DelayedCron.processor).to eq(DelayedCron::Jobs::Sidekiq)
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -64,16 +64,16 @@ describe DelayedCron do
|
|
64
64
|
describe ".process_job" do
|
65
65
|
|
66
66
|
it "should call the cron jobs method" do
|
67
|
-
klass = build_class("SomeClass", "long_method", {})
|
68
|
-
klass.
|
69
|
-
DelayedCron.process_job(klass.name, "long_method", {})
|
67
|
+
klass = build_class("SomeClass", "long_method", {interval: 1.day})
|
68
|
+
expect(klass).to receive(:long_method)
|
69
|
+
DelayedCron.process_job(klass.name, "long_method", {interval: 1.day})
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should reschedule the cron job after processing" do
|
73
73
|
klass, name = "SomeClass", "test_method"
|
74
|
-
build_class(klass, name)
|
75
|
-
DelayedCron.
|
76
|
-
DelayedCron.process_job(klass, name, {})
|
74
|
+
build_class(klass, name, {interval: 1.day})
|
75
|
+
expect(DelayedCron).to receive(:schedule).with(klass, name, {interval: 1.day})
|
76
|
+
DelayedCron.process_job(klass, name, {interval: 1.day})
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
@@ -82,21 +82,21 @@ describe DelayedCron do
|
|
82
82
|
context 'if not present' do
|
83
83
|
it "schedules cron jobs found in a model" do
|
84
84
|
klass, name = "SomeClass", "some_method"
|
85
|
-
DelayedCron.
|
85
|
+
expect(DelayedCron).to receive(:schedule).with(klass, name, {})
|
86
86
|
build_class(klass, name)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
context 'if present and true' do
|
90
90
|
it "schedules cron jobs found in a model" do
|
91
91
|
klass, name = "SomeClass", "some_method"
|
92
|
-
DelayedCron.
|
92
|
+
expect(DelayedCron).to receive(:schedule).with(klass, name, {})
|
93
93
|
build_class(klass, name, {if: true})
|
94
94
|
end
|
95
95
|
end
|
96
96
|
context 'if present and false' do
|
97
97
|
it "schedules cron jobs found in a model" do
|
98
98
|
klass, name = "SomeClass", "some_method"
|
99
|
-
DelayedCron.
|
99
|
+
expect(DelayedCron).not_to receive(:schedule).with(klass, name, {})
|
100
100
|
build_class(klass, name, {if: false})
|
101
101
|
end
|
102
102
|
end
|
data/spec/scheduling_spec.rb
CHANGED
@@ -64,7 +64,7 @@ describe DelayedCron::Scheduling do
|
|
64
64
|
Timecop.freeze(Time.local(2014, 1, 1, 12, 0, 0))
|
65
65
|
interval = 9.days
|
66
66
|
adjusted_interval = interval - 12.hours
|
67
|
-
DelayedCron.processor.
|
67
|
+
expect(DelayedCron.processor).to receive(:enqueue_delayed_cron)
|
68
68
|
.with("SomeClass", "long_method", { interval: adjusted_interval.to_i, at: "00:00" })
|
69
69
|
DelayedCron.schedule("SomeClass", "long_method", { interval: interval, at: "00:00" })
|
70
70
|
end
|
metadata
CHANGED
@@ -1,167 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_cron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Grubbs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: delayed_job
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: resque
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sidekiq
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sucker_punch
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: timecop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-sidekiq
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: codeclimate-test-reporter
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: hashie
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: debugger
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - '>='
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - '>='
|
150
|
+
- - ">="
|
165
151
|
- !ruby/object:Gem::Version
|
166
152
|
version: '0'
|
167
153
|
description: Run your cron jobs with sidekiq, delayed_job, resque, or sucker_punch.
|
@@ -170,10 +156,10 @@ executables: []
|
|
170
156
|
extensions: []
|
171
157
|
extra_rdoc_files: []
|
172
158
|
files:
|
173
|
-
- .gitignore
|
174
|
-
- .rspec
|
175
|
-
- .ruby-version
|
176
|
-
- .travis.yml
|
159
|
+
- ".gitignore"
|
160
|
+
- ".rspec"
|
161
|
+
- ".ruby-version"
|
162
|
+
- ".travis.yml"
|
177
163
|
- Gemfile
|
178
164
|
- README.md
|
179
165
|
- Rakefile
|
@@ -202,12 +188,12 @@ require_paths:
|
|
202
188
|
- lib
|
203
189
|
required_ruby_version: !ruby/object:Gem::Requirement
|
204
190
|
requirements:
|
205
|
-
- -
|
191
|
+
- - ">="
|
206
192
|
- !ruby/object:Gem::Version
|
207
193
|
version: '0'
|
208
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
195
|
requirements:
|
210
|
-
- -
|
196
|
+
- - ">="
|
211
197
|
- !ruby/object:Gem::Version
|
212
198
|
version: '0'
|
213
199
|
requirements: []
|