delayed_cron 0.2.1 → 0.2.2

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2E1NGU0ZTQ5NWU5NzQwZjQxOGQ0OWE4YTgyN2JhYjZkNWI3ODE0YQ==
4
+ NDRlMTJiYTJkZWU5MGVmYTk4ZDQxMWYwN2UxYzhmNDJlNTFmZDdkMg==
5
5
  data.tar.gz: !binary |-
6
- OWM4NWQyZTA2OGYyMzJiZWM0ZWMzNmMxZTE0ODI4ZGUxMTFiMjAzNw==
6
+ YzgzODYzMmE0YTFkYjA1ZTcyODE0MDFmYTZjOWYwOTEzYTZkZTA1NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGVjYmIzYWVhMjg1ZjE2ZjdhN2Q2MTIxZjdhNGIwZTYwMTQ3ZTdiN2QwNTkx
10
- NjU1NjRlNTQ5MzcxNDA3MDk1YzExODc5ZWFlMGU1NjhlZjg2MGRhMTYzMWFm
11
- NmM4NjMyNjJkMDIyN2QyMmM5YmMzMmE1MmYxNzg5NGZjOThhZTY=
9
+ OTBkZjk2ZTMxYmQ1NGMwMzBkNzliNDZlOTM2ZWRiMGI0ZWYxMjE2MDJhMTIw
10
+ ZWY3YTVjNjkxNmQyNGYwODczMGE4MGVjZjI4YjFhZTMxNmViNDE1MzA0NzA1
11
+ MGI4NWMzMzM2Y2ZmZmQ4MTI3Njk0ZWQ4Nzc3MjAwZGE4MjRhODg=
12
12
  data.tar.gz: !binary |-
13
- YjRhYmMxNjQ3NDVlNDRjYTBmOTRkYzExYjhiYzMxMGU4YTBhYjgzY2U2YTE0
14
- MjFjODY5Y2U4YjE2YThjZTg3NDQ1MGNkMTY4MWU0MDM0YjMxNmNjNjkxNmE3
15
- NmRkOGY3MmE3NDE2ODEyMWQ4MWZhMTE0ZWE5YzJkYzczMzU0ZTE=
13
+ NjljY2RjZDk2ZWQ1YzI0MTUyZmM2NGJhMDIwN2Q3ZWViZTdhMzQzOTdkNjky
14
+ Y2ExMmYzODhkODBmMDBlZDI4YTU4OWUyMTY4NDE1YmQ3ZTcwNDNlYjg5ZjE5
15
+ ZGZmZTgyOTI1MzczZTc2ZTA5NDgxNjliZTA3OWNmZTM2MGM1YzU=
data/.gitignore CHANGED
@@ -1,3 +1,2 @@
1
1
  *.DS_Store
2
-
3
2
  pkg
data/Gemfile.lock CHANGED
@@ -1,54 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- delayed_cron (0.2.0)
4
+ delayed_cron (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionmailer (4.0.4)
10
- actionpack (= 4.0.4)
9
+ actionmailer (4.1.2)
10
+ actionpack (= 4.1.2)
11
+ actionview (= 4.1.2)
11
12
  mail (~> 2.5.4)
12
- actionpack (4.0.4)
13
- activesupport (= 4.0.4)
14
- builder (~> 3.1.0)
15
- erubis (~> 2.7.0)
13
+ actionpack (4.1.2)
14
+ actionview (= 4.1.2)
15
+ activesupport (= 4.1.2)
16
16
  rack (~> 1.5.2)
17
17
  rack-test (~> 0.6.2)
18
- activemodel (4.0.4)
19
- activesupport (= 4.0.4)
20
- builder (~> 3.1.0)
21
- activerecord (4.0.4)
22
- activemodel (= 4.0.4)
23
- activerecord-deprecated_finders (~> 1.0.2)
24
- activesupport (= 4.0.4)
25
- arel (~> 4.0.0)
26
- activerecord-deprecated_finders (1.0.3)
27
- activesupport (4.0.4)
18
+ actionview (4.1.2)
19
+ activesupport (= 4.1.2)
20
+ builder (~> 3.1)
21
+ erubis (~> 2.7.0)
22
+ activemodel (4.1.2)
23
+ activesupport (= 4.1.2)
24
+ builder (~> 3.1)
25
+ activerecord (4.1.2)
26
+ activemodel (= 4.1.2)
27
+ activesupport (= 4.1.2)
28
+ arel (~> 5.0.0)
29
+ activesupport (4.1.2)
28
30
  i18n (~> 0.6, >= 0.6.9)
29
- minitest (~> 4.2)
30
- multi_json (~> 1.3)
31
+ json (~> 1.7, >= 1.7.7)
32
+ minitest (~> 5.1)
31
33
  thread_safe (~> 0.1)
32
- tzinfo (~> 0.3.37)
33
- arel (4.0.2)
34
- atomic (1.1.15)
35
- builder (3.1.4)
34
+ tzinfo (~> 1.1)
35
+ arel (5.0.1.20140414130214)
36
+ builder (3.2.2)
36
37
  celluloid (0.15.2)
37
38
  timers (~> 1.1.0)
38
39
  codeclimate-test-reporter (0.3.0)
39
40
  simplecov (>= 0.7.1, < 1.0.0)
40
- columnize (0.3.6)
41
- connection_pool (1.2.0)
42
- debugger (1.6.6)
41
+ columnize (0.8.9)
42
+ connection_pool (2.0.0)
43
+ debugger (1.6.8)
43
44
  columnize (>= 0.3.1)
44
45
  debugger-linecache (~> 1.2.0)
45
- debugger-ruby_core_source (~> 1.3.2)
46
+ debugger-ruby_core_source (~> 1.3.5)
46
47
  debugger-linecache (1.2.0)
47
- debugger-ruby_core_source (1.3.2)
48
- delayed_job (4.0.0)
49
- activesupport (>= 3.0, < 4.1)
48
+ debugger-ruby_core_source (1.3.5)
49
+ delayed_job (4.0.2)
50
+ activesupport (>= 3.0, < 4.2)
50
51
  diff-lcs (1.2.5)
51
- docile (1.1.3)
52
+ docile (1.1.5)
52
53
  erubis (2.7.0)
53
54
  hike (1.2.3)
54
55
  i18n (0.6.9)
@@ -57,52 +58,54 @@ GEM
57
58
  mime-types (~> 1.16)
58
59
  treetop (~> 1.4.8)
59
60
  mime-types (1.25.1)
60
- minitest (4.7.5)
61
+ minitest (5.3.5)
61
62
  mono_logger (1.1.0)
62
- multi_json (1.9.0)
63
- polyglot (0.3.4)
63
+ multi_json (1.10.1)
64
+ polyglot (0.3.5)
64
65
  rack (1.5.2)
65
- rack-protection (1.5.2)
66
+ rack-protection (1.5.3)
66
67
  rack
67
68
  rack-test (0.6.2)
68
69
  rack (>= 1.0)
69
- rails (4.0.4)
70
- actionmailer (= 4.0.4)
71
- actionpack (= 4.0.4)
72
- activerecord (= 4.0.4)
73
- activesupport (= 4.0.4)
70
+ rails (4.1.2)
71
+ actionmailer (= 4.1.2)
72
+ actionpack (= 4.1.2)
73
+ actionview (= 4.1.2)
74
+ activemodel (= 4.1.2)
75
+ activerecord (= 4.1.2)
76
+ activesupport (= 4.1.2)
74
77
  bundler (>= 1.3.0, < 2.0)
75
- railties (= 4.0.4)
76
- sprockets-rails (~> 2.0.0)
77
- railties (4.0.4)
78
- actionpack (= 4.0.4)
79
- activesupport (= 4.0.4)
78
+ railties (= 4.1.2)
79
+ sprockets-rails (~> 2.0)
80
+ railties (4.1.2)
81
+ actionpack (= 4.1.2)
82
+ activesupport (= 4.1.2)
80
83
  rake (>= 0.8.7)
81
84
  thor (>= 0.18.1, < 2.0)
82
- rake (10.1.1)
83
- redis (3.0.7)
84
- redis-namespace (1.4.1)
85
- redis (~> 3.0.4)
86
- resque (1.25.1)
85
+ rake (10.3.2)
86
+ redis (3.1.0)
87
+ redis-namespace (1.5.0)
88
+ redis (~> 3.0, >= 3.0.4)
89
+ resque (1.25.2)
87
90
  mono_logger (~> 1.0)
88
91
  multi_json (~> 1.0)
89
- redis-namespace (~> 1.2)
92
+ redis-namespace (~> 1.3)
90
93
  sinatra (>= 0.9.2)
91
94
  vegas (~> 0.1.2)
92
- rspec (2.14.1)
93
- rspec-core (~> 2.14.0)
94
- rspec-expectations (~> 2.14.0)
95
- rspec-mocks (~> 2.14.0)
96
- rspec-core (2.14.7)
97
- rspec-expectations (2.14.5)
95
+ rspec (2.99.0)
96
+ rspec-core (~> 2.99.0)
97
+ rspec-expectations (~> 2.99.0)
98
+ rspec-mocks (~> 2.99.0)
99
+ rspec-core (2.99.1)
100
+ rspec-expectations (2.99.1)
98
101
  diff-lcs (>= 1.1.3, < 2.0)
99
- rspec-mocks (2.14.6)
100
- rspec-sidekiq (1.0.0)
101
- rspec (>= 2.0.0)
102
+ rspec-mocks (2.99.1)
103
+ rspec-sidekiq (1.1.0)
104
+ rspec (~> 2.0)
102
105
  sidekiq (>= 2.4.0)
103
- sidekiq (2.17.6)
106
+ sidekiq (3.1.4)
104
107
  celluloid (>= 0.15.2)
105
- connection_pool (>= 1.0.0)
108
+ connection_pool (>= 2.0.0)
106
109
  json
107
110
  redis (>= 3.0.6)
108
111
  redis-namespace (>= 1.3.1)
@@ -111,29 +114,31 @@ GEM
111
114
  multi_json
112
115
  simplecov-html (~> 0.8.0)
113
116
  simplecov-html (0.8.0)
114
- sinatra (1.4.4)
117
+ sinatra (1.4.5)
115
118
  rack (~> 1.4)
116
119
  rack-protection (~> 1.4)
117
120
  tilt (~> 1.3, >= 1.3.4)
118
- sprockets (2.12.0)
121
+ sprockets (2.12.1)
119
122
  hike (~> 1.2)
120
123
  multi_json (~> 1.0)
121
124
  rack (~> 1.0)
122
125
  tilt (~> 1.1, != 1.3.0)
123
- sprockets-rails (2.0.1)
126
+ sprockets-rails (2.1.3)
124
127
  actionpack (>= 3.0)
125
128
  activesupport (>= 3.0)
126
129
  sprockets (~> 2.8)
127
- thor (0.18.1)
128
- thread_safe (0.2.0)
129
- atomic (>= 1.1.7, < 2)
130
+ sucker_punch (1.1)
131
+ celluloid (~> 0.15.2)
132
+ thor (0.19.1)
133
+ thread_safe (0.3.4)
130
134
  tilt (1.4.1)
131
135
  timecop (0.7.1)
132
136
  timers (1.1.0)
133
137
  treetop (1.4.15)
134
138
  polyglot
135
139
  polyglot (>= 0.3.1)
136
- tzinfo (0.3.39)
140
+ tzinfo (1.2.1)
141
+ thread_safe (~> 0.1)
137
142
  vegas (0.1.11)
138
143
  rack (>= 1.0.0)
139
144
 
@@ -150,4 +155,5 @@ DEPENDENCIES
150
155
  rspec
151
156
  rspec-sidekiq
152
157
  sidekiq
158
+ sucker_punch
153
159
  timecop
data/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
  [![Code Climate](https://codeclimate.com/github/sellect/delayed_cron.png?branch=master)](https://codeclimate.com/github/sellect/delayed_cron)
3
3
 
4
4
  # DelayedCron
5
- run cron jobs with sidekiq, delayed_job, or resque
5
+ run cron jobs with sidekiq, delayed_job, resque, or sucker_punch
6
6
 
7
7
  ### DEPENDENCIES:
8
- - background process handler: sidekiq, delayed_job, or resque
8
+ - background process handler: sidekiq, delayed_job, resque, or sucker_punch
9
9
 
10
10
  ### INSTALL
11
11
 
12
12
  ```ruby
13
- gem "delayed_cron", "0.2.0"
13
+ gem "delayed_cron", "0.2.2"
14
14
  ```
15
15
 
16
16
  ### USE IN MODEL
data/delayed_cron.gemspec CHANGED
@@ -6,14 +6,15 @@ Gem::Specification.new do |s|
6
6
  s.version = DelayedCron::VERSION
7
7
 
8
8
  s.authors = ["Justin Grubbs"]
9
- s.summary = %q{Run your cron jobs with sidekiq, delayed_job, or resque.}
10
- s.description = %q{Run your cron jobs with sidekiq, delayed_job, or resque.}
9
+ s.summary = %q{Run your cron jobs with sidekiq, delayed_job, resque, or sucker_punch.}
10
+ s.description = %q{Run your cron jobs with sidekiq, delayed_job, resque, or sucker_punch.}
11
11
  s.email = %q{justin@sellect.com}
12
12
  s.homepage = %q{http://github.com/sellect/delayed_cron}
13
13
 
14
14
  s.add_development_dependency "delayed_job"
15
15
  s.add_development_dependency "resque"
16
16
  s.add_development_dependency "sidekiq"
17
+ s.add_development_dependency "sucker_punch"
17
18
  s.add_development_dependency "rspec"
18
19
  s.add_development_dependency "rails"
19
20
  s.add_development_dependency "debugger"
@@ -1,4 +1,5 @@
1
1
  require 'sidekiq/worker'
2
+ require 'sidekiq/api'
2
3
 
3
4
  module DelayedCron
4
5
  module Jobs
@@ -0,0 +1,29 @@
1
+ require 'sucker_punch'
2
+
3
+ module DelayedCron
4
+ module Jobs
5
+ class SuckerPunch
6
+ include ::SuckerPunch::Job
7
+
8
+ def self.enqueue_delayed_cron(klass, method_name, options)
9
+ unless scheduled?(klass)
10
+ options.symbolize_keys!
11
+ self.new.later(options[:interval], klass, method_name, options)
12
+ end
13
+ end
14
+
15
+ def self.scheduled?(klass)
16
+ ::SuckerPunch::Queue.new(klass).registered?
17
+ end
18
+
19
+ def perform(klass, method_name, options)
20
+ DelayedCron.process_job(klass, method_name, options)
21
+ end
22
+
23
+ def later(sec, *args)
24
+ after(sec) { perform(*args) }
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module DelayedCron
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/delayed_cron.rb CHANGED
@@ -22,9 +22,10 @@ module DelayedCron
22
22
  end
23
23
 
24
24
  def processor
25
- return DelayedCron::Jobs::DelayedJob if defined? ::Delayed::Job
26
- return DelayedCron::Jobs::Resque if defined? ::Resque
27
- return DelayedCron::Jobs::Sidekiq if defined? ::Sidekiq
25
+ return DelayedCron::Jobs::DelayedJob if defined? ::Delayed::Job
26
+ return DelayedCron::Jobs::Resque if defined? ::Resque
27
+ return DelayedCron::Jobs::Sidekiq if defined? ::Sidekiq
28
+ return DelayedCron::Jobs::SuckerPunch if defined? ::SuckerPunch
28
29
  end
29
30
 
30
31
  def schedule(klass, method_name, options)
@@ -56,9 +57,9 @@ module DelayedCron
56
57
  def parse_time(time_array)
57
58
  {
58
59
  hours: time_array[0],
59
- mins: time_array[1],
60
- secs: time_array[2] || 0,
61
- tz: time_array[3] || Time.now.strftime("%z").to_i
60
+ mins: time_array[1],
61
+ secs: time_array[2] || 0,
62
+ tz: time_array[3] || Time.now.strftime("%z").to_i
62
63
  }
63
64
  end
64
65
 
@@ -73,6 +74,7 @@ module DelayedCron
73
74
  module ClassMethods
74
75
 
75
76
  def cron_job(name, options = { interval: DelayedCron.default_interval })
77
+ return false if options.delete(:if) == false
76
78
  DelayedCron.schedule(self.name.to_s, name, options)
77
79
  end
78
80
 
@@ -97,10 +97,26 @@ describe DelayedCron do
97
97
  end
98
98
 
99
99
  describe "cron_job" do
100
- it "schedules cron jobs found in a model" do
101
- klass, name = "SomeClass", "some_method"
102
- DelayedCron.should_receive(:schedule).with(klass, name, {})
103
- build_class(klass, name)
100
+ context 'if not present' do
101
+ it "schedules cron jobs found in a model" do
102
+ klass, name = "SomeClass", "some_method"
103
+ DelayedCron.should_receive(:schedule).with(klass, name, {})
104
+ build_class(klass, name)
105
+ end
106
+ end
107
+ context 'if present and true' do
108
+ it "schedules cron jobs found in a model" do
109
+ klass, name = "SomeClass", "some_method"
110
+ DelayedCron.should_receive(:schedule).with(klass, name, {})
111
+ build_class(klass, name, {if: true})
112
+ end
113
+ end
114
+ context 'if present and false' do
115
+ it "schedules cron jobs found in a model" do
116
+ klass, name = "SomeClass", "some_method"
117
+ DelayedCron.should_not_receive(:schedule).with(klass, name, {})
118
+ build_class(klass, name, {if: false})
119
+ end
104
120
  end
105
121
  end
106
122
 
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Grubbs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: delayed_job
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sucker_punch
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +150,7 @@ dependencies:
136
150
  - - ! '>='
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
- description: Run your cron jobs with sidekiq, delayed_job, or resque.
153
+ description: Run your cron jobs with sidekiq, delayed_job, resque, or sucker_punch.
140
154
  email: justin@sellect.com
141
155
  executables: []
142
156
  extensions: []
@@ -157,6 +171,7 @@ files:
157
171
  - lib/delayed_cron/jobs/delayed_job.rb
158
172
  - lib/delayed_cron/jobs/resque.rb
159
173
  - lib/delayed_cron/jobs/sidekiq.rb
174
+ - lib/delayed_cron/jobs/sucker_punch.rb
160
175
  - lib/delayed_cron/railtie.rb
161
176
  - lib/delayed_cron/version.rb
162
177
  - rails/init.rb
@@ -184,7 +199,7 @@ rubyforge_project:
184
199
  rubygems_version: 2.1.11
185
200
  signing_key:
186
201
  specification_version: 4
187
- summary: Run your cron jobs with sidekiq, delayed_job, or resque.
202
+ summary: Run your cron jobs with sidekiq, delayed_job, resque, or sucker_punch.
188
203
  test_files:
189
204
  - spec/delayed_cron_spec.rb
190
205
  - spec/spec_helper.rb