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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c34b1f4a8ad81433f720139d2ab42fc434e57c26
4
- data.tar.gz: 35e783bd8f72dfa67fcf02ec651a1b148738dab2
3
+ metadata.gz: c6fe770d7d97f8a9d7fdb92905e00b26d4e9c0d6
4
+ data.tar.gz: 11bac5d4b29ae8bea2196fce52573ada1cf67d8e
5
5
  SHA512:
6
- metadata.gz: bde551335a82a185dbcdebd8631d9c57b6528f47302c3dd90bc10240e2794d7c508558dd4ce5788bd79303fc5177816455a175c4e0fd3bfad3053113662758ac
7
- data.tar.gz: 3225ce660f0a19b7c20a3a76e93544a22e598882052d2bf98014f4a88d984bed7793b36f36b6fe5cee22f0753851a82c6e3d72352245f19e09b5f58c11775c4f
6
+ metadata.gz: 689013117dd11c13c5cb50178155f99d112824e2747a613125194e0cc46f53c7d8d78f5f3ed7937117ebc8a1e8def1d3a7a1775e7dc0c34cee187c100fe222ff
7
+ data.tar.gz: ccb01e5dce56a3c3b454d088e204ef831bf4128b5d03090033b34a527e2599f15a99a98c22bc45b8d2c37b2901ecbc902f033079fd5e8465ea0c18d5392f9063
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- delayed_cron (0.2.4)
4
+ delayed_cron (0.2.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -10,7 +10,7 @@ run cron jobs with sidekiq, delayed_job, resque, or sucker_punch
10
10
  ### INSTALL
11
11
 
12
12
  ```ruby
13
- gem "delayed_cron", "0.2.4"
13
+ gem "delayed_cron", "0.2.5"
14
14
  ```
15
15
 
16
16
  ### USE IN MODEL
@@ -1,3 +1,3 @@
1
1
  module DelayedCron
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
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
- DelayedCron.schedule(klass, name, { interval: interval })
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)
@@ -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
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-01-11 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: delayed_job