delayed_cron 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/delayed_cron/version.rb +1 -1
- data/lib/delayed_cron.rb +9 -1
- data/spec/delayed_cron_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6fe770d7d97f8a9d7fdb92905e00b26d4e9c0d6
|
4
|
+
data.tar.gz: 11bac5d4b29ae8bea2196fce52573ada1cf67d8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 689013117dd11c13c5cb50178155f99d112824e2747a613125194e0cc46f53c7d8d78f5f3ed7937117ebc8a1e8def1d3a7a1775e7dc0c34cee187c100fe222ff
|
7
|
+
data.tar.gz: ccb01e5dce56a3c3b454d088e204ef831bf4128b5d03090033b34a527e2599f15a99a98c22bc45b8d2c37b2901ecbc902f033079fd5e8465ea0c18d5392f9063
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/delayed_cron/version.rb
CHANGED
data/lib/delayed_cron.rb
CHANGED
@@ -19,9 +19,11 @@ module DelayedCron
|
|
19
19
|
job_is_hash = job.is_a?(Hash)
|
20
20
|
job = job_is_hash ? obj[:job] : job
|
21
21
|
interval = job_is_hash ? obj[:interval] : default_interval
|
22
|
+
options_at = job_is_hash ? obj[:at] : nil
|
22
23
|
klass, name = job.split(".")
|
23
24
|
# TODO: raise error if interval is not set
|
24
|
-
|
25
|
+
options = timing_opts(interval, options_at)
|
26
|
+
DelayedCron.schedule(klass, name, options)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -39,6 +41,12 @@ module DelayedCron
|
|
39
41
|
processor.enqueue_delayed_cron(klass, method_name, options)
|
40
42
|
end
|
41
43
|
|
44
|
+
def timing_opts(interval, options_at)
|
45
|
+
timing_opts = { interval: interval }
|
46
|
+
timing_opts.merge!(at: options_at) if options_at.present?
|
47
|
+
timing_opts
|
48
|
+
end
|
49
|
+
|
42
50
|
def process_job(klass, method_name, options)
|
43
51
|
# TODO: add ability to send args to klass method
|
44
52
|
klass.constantize.send(method_name)
|
data/spec/delayed_cron_spec.rb
CHANGED
@@ -69,6 +69,20 @@ describe DelayedCron do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
describe ".timing_opts" do
|
73
|
+
|
74
|
+
let(:options) do
|
75
|
+
{ interval: 1.day, at: "05:00:00 -0400" }
|
76
|
+
end
|
77
|
+
|
78
|
+
it "collects the timing options" do
|
79
|
+
interval = { interval: 1.day }
|
80
|
+
timing_opts = DelayedCron.timing_opts(options[:interval], options[:at])
|
81
|
+
expect(timing_opts).to eq(options)
|
82
|
+
expect(timing_opts).not_to eq(interval)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
72
86
|
describe ".process_job" do
|
73
87
|
|
74
88
|
it "should call the cron jobs method" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Grubbs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: delayed_job
|