resque-scheduler 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of resque-scheduler might be problematic. Click here for more details.

Files changed (49) hide show
  1. data/.gitignore +3 -0
  2. data/.rubocop.yml +11 -11
  3. data/.simplecov +1 -0
  4. data/.travis.yml +5 -2
  5. data/AUTHORS.md +3 -0
  6. data/HISTORY.md +26 -2
  7. data/LICENSE +1 -1
  8. data/README.md +120 -31
  9. data/ROADMAP.md +10 -0
  10. data/Rakefile +7 -19
  11. data/bin/resque-scheduler +5 -0
  12. data/examples/Rakefile +2 -0
  13. data/examples/config/initializers/resque-web.rb +37 -0
  14. data/examples/dynamic-scheduling/README.md +28 -0
  15. data/examples/dynamic-scheduling/app/jobs/fix_schedules_job.rb +54 -0
  16. data/examples/dynamic-scheduling/app/jobs/send_email_job.rb +9 -0
  17. data/examples/dynamic-scheduling/app/models/user.rb +16 -0
  18. data/examples/dynamic-scheduling/config/resque.yml +4 -0
  19. data/examples/dynamic-scheduling/config/static_schedule.yml +7 -0
  20. data/examples/dynamic-scheduling/lib/tasks/resque.rake +48 -0
  21. data/examples/run-resque-web +3 -0
  22. data/lib/resque-scheduler.rb +2 -0
  23. data/lib/resque/scheduler.rb +130 -41
  24. data/lib/resque/scheduler/lock/resilient.rb +1 -1
  25. data/lib/resque/scheduler_locking.rb +3 -1
  26. data/lib/resque_scheduler.rb +73 -31
  27. data/lib/resque_scheduler/cli.rb +160 -0
  28. data/lib/resque_scheduler/logger_builder.rb +27 -8
  29. data/lib/resque_scheduler/plugin.rb +10 -7
  30. data/lib/resque_scheduler/server.rb +52 -11
  31. data/lib/resque_scheduler/server/views/delayed.erb +2 -0
  32. data/lib/resque_scheduler/server/views/delayed_schedules.erb +20 -0
  33. data/lib/resque_scheduler/server/views/scheduler.erb +4 -12
  34. data/lib/resque_scheduler/tasks.rb +15 -27
  35. data/lib/resque_scheduler/version.rb +1 -1
  36. data/resque-scheduler.gemspec +2 -0
  37. data/test/cli_test.rb +286 -0
  38. data/test/delayed_queue_test.rb +70 -1
  39. data/test/resque-web_test.rb +36 -1
  40. data/test/scheduler_args_test.rb +51 -17
  41. data/test/scheduler_hooks_test.rb +1 -1
  42. data/test/scheduler_locking_test.rb +63 -1
  43. data/test/scheduler_setup_test.rb +54 -18
  44. data/test/scheduler_task_test.rb +35 -0
  45. data/test/scheduler_test.rb +130 -42
  46. data/test/support/redis_instance.rb +8 -3
  47. data/test/test_helper.rb +47 -20
  48. metadata +77 -6
  49. checksums.yaml +0 -15
@@ -13,6 +13,7 @@ class RedisInstance
13
13
  end
14
14
 
15
15
  def run!
16
+ ensure_redis_server_present!
16
17
  ensure_pid_directory
17
18
  reassign_redis_clients
18
19
  start_redis_server
@@ -24,9 +25,7 @@ class RedisInstance
24
25
  wait_for_redis_boot
25
26
 
26
27
  # Ensure we tear down Redis on Ctrl+C / test failure.
27
- at_exit do
28
- RedisInstance.stop!
29
- end
28
+ at_exit { stop! }
30
29
  else
31
30
  fail "Failed to start Redis on port #{port}."
32
31
  end
@@ -49,6 +48,12 @@ class RedisInstance
49
48
 
50
49
  private
51
50
 
51
+ def ensure_redis_server_present!
52
+ if !system('redis-server -v')
53
+ fail "** can't find `redis-server` in your path"
54
+ end
55
+ end
56
+
52
57
  def wait_for_redis_boot
53
58
  Timeout::timeout(10) do
54
59
  begin
@@ -1,33 +1,28 @@
1
-
2
1
  # Pretty much copied this file from the resque test_helper since we want
3
2
  # to do all the same stuff
4
3
 
5
4
  dir = File.dirname(File.expand_path(__FILE__))
6
5
 
7
6
  require 'rubygems'
7
+ require 'bundler/setup'
8
+
9
+ require 'simplecov' unless RUBY_VERSION < '1.9'
10
+
8
11
  require 'test/unit'
9
12
  require 'mocha/setup'
10
13
  require 'resque'
14
+
11
15
  $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'
12
16
  require 'resque_scheduler'
13
17
  require 'resque_scheduler/server'
14
18
 
15
- #
16
- # make sure we can run redis
17
- #
18
-
19
- if !system("which redis-server")
20
- puts '', "** can't find `redis-server` in your path"
21
- puts "** try running `sudo rake install`"
22
- abort ''
19
+ unless ENV['RESQUE_SCHEDULER_DISABLE_TEST_REDIS_SERVER']
20
+ # Start our own Redis when the tests start. RedisInstance will take care of
21
+ # starting and stopping.
22
+ require File.expand_path('../support/redis_instance', __FILE__)
23
+ RedisInstance.run!
23
24
  end
24
25
 
25
-
26
- # Start our own Redis when the tests start. RedisInstance will take care of
27
- # starting and stopping.
28
- require File.dirname(__FILE__) + '/support/redis_instance'
29
- RedisInstance.run!
30
-
31
26
  at_exit do
32
27
  next if $!
33
28
 
@@ -37,7 +32,7 @@ at_exit do
37
32
  exit_code = Test::Unit::AutoRunner.run
38
33
  end
39
34
 
40
- exit exit_code
35
+ exit(exit_code || 0)
41
36
  end
42
37
 
43
38
  ##
@@ -60,6 +55,14 @@ def context(*args, &block)
60
55
  klass.class_eval(&block)
61
56
  end
62
57
 
58
+ unless defined?(Rails)
59
+ module Rails
60
+ class << self
61
+ attr_accessor :env
62
+ end
63
+ end
64
+ end
65
+
63
66
  class FakeCustomJobClass
64
67
  def self.scheduled(queue, klass, *args); end
65
68
  end
@@ -92,9 +95,33 @@ end
92
95
 
93
96
  JobWithoutParams = Class.new(JobWithParams)
94
97
 
98
+ %w(
99
+ APP_NAME
100
+ DYNAMIC_SCHEDULE
101
+ LOGFILE
102
+ LOGFORMAT
103
+ MUTE
104
+ RAILS_ENV
105
+ RESQUE_SCHEDULER_INTERVAL
106
+ VERBOSE
107
+ ).each do |envvar|
108
+ ENV[envvar] = nil
109
+ end
110
+
95
111
  def nullify_logger
96
- Resque::Scheduler.mute = nil
97
- Resque::Scheduler.verbose = nil
98
- Resque::Scheduler.logfile = nil
99
- Resque::Scheduler.logger = nil
112
+ Resque::Scheduler.configure do |c|
113
+ c.mute = nil
114
+ c.verbose = nil
115
+ c.logfile = nil
116
+ c.logger = nil
117
+ end
118
+
119
+ ENV['LOGFILE'] = nil
100
120
  end
121
+
122
+ def restore_devnull_logfile
123
+ nullify_logger
124
+ ENV['LOGFILE'] = '/dev/null'
125
+ end
126
+
127
+ restore_devnull_logfile
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ben VandenBos
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: mocha
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,23 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
37
58
  requirements:
38
59
  - - ! '>='
39
60
  - !ruby/object:Gem::Version
@@ -41,6 +62,7 @@ dependencies:
41
62
  - !ruby/object:Gem::Dependency
42
63
  name: rack-test
43
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
44
66
  requirements:
45
67
  - - ! '>='
46
68
  - !ruby/object:Gem::Version
@@ -48,6 +70,7 @@ dependencies:
48
70
  type: :development
49
71
  prerelease: false
50
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
51
74
  requirements:
52
75
  - - ! '>='
53
76
  - !ruby/object:Gem::Version
@@ -55,6 +78,7 @@ dependencies:
55
78
  - !ruby/object:Gem::Dependency
56
79
  name: rake
57
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
58
82
  requirements:
59
83
  - - ! '>='
60
84
  - !ruby/object:Gem::Version
@@ -62,6 +86,7 @@ dependencies:
62
86
  type: :development
63
87
  prerelease: false
64
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
65
90
  requirements:
66
91
  - - ! '>='
67
92
  - !ruby/object:Gem::Version
@@ -69,6 +94,23 @@ dependencies:
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rubocop
71
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
72
114
  requirements:
73
115
  - - ! '>='
74
116
  - !ruby/object:Gem::Version
@@ -76,6 +118,7 @@ dependencies:
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
79
122
  requirements:
80
123
  - - ! '>='
81
124
  - !ruby/object:Gem::Version
@@ -83,6 +126,7 @@ dependencies:
83
126
  - !ruby/object:Gem::Dependency
84
127
  name: redis
85
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
86
130
  requirements:
87
131
  - - ! '>='
88
132
  - !ruby/object:Gem::Version
@@ -90,6 +134,7 @@ dependencies:
90
134
  type: :runtime
91
135
  prerelease: false
92
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
93
138
  requirements:
94
139
  - - ! '>='
95
140
  - !ruby/object:Gem::Version
@@ -97,6 +142,7 @@ dependencies:
97
142
  - !ruby/object:Gem::Dependency
98
143
  name: resque
99
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
100
146
  requirements:
101
147
  - - ~>
102
148
  - !ruby/object:Gem::Version
@@ -104,6 +150,7 @@ dependencies:
104
150
  type: :runtime
105
151
  prerelease: false
106
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
107
154
  requirements:
108
155
  - - ~>
109
156
  - !ruby/object:Gem::Version
@@ -111,6 +158,7 @@ dependencies:
111
158
  - !ruby/object:Gem::Dependency
112
159
  name: rufus-scheduler
113
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
114
162
  requirements:
115
163
  - - ~>
116
164
  - !ruby/object:Gem::Version
@@ -118,6 +166,7 @@ dependencies:
118
166
  type: :runtime
119
167
  prerelease: false
120
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
121
170
  requirements:
122
171
  - - ~>
123
172
  - !ruby/object:Gem::Version
@@ -127,12 +176,14 @@ description: ! "Light weight job scheduling on top of Resque.\n Adds methods
127
176
  schedule."
128
177
  email:
129
178
  - bvandenbos@gmail.com
130
- executables: []
179
+ executables:
180
+ - resque-scheduler
131
181
  extensions: []
132
182
  extra_rdoc_files: []
133
183
  files:
134
184
  - .gitignore
135
185
  - .rubocop.yml
186
+ - .simplecov
136
187
  - .travis.yml
137
188
  - AUTHORS.md
138
189
  - CONTRIBUTING.md
@@ -140,7 +191,20 @@ files:
140
191
  - HISTORY.md
141
192
  - LICENSE
142
193
  - README.md
194
+ - ROADMAP.md
143
195
  - Rakefile
196
+ - bin/resque-scheduler
197
+ - examples/Rakefile
198
+ - examples/config/initializers/resque-web.rb
199
+ - examples/dynamic-scheduling/README.md
200
+ - examples/dynamic-scheduling/app/jobs/fix_schedules_job.rb
201
+ - examples/dynamic-scheduling/app/jobs/send_email_job.rb
202
+ - examples/dynamic-scheduling/app/models/user.rb
203
+ - examples/dynamic-scheduling/config/resque.yml
204
+ - examples/dynamic-scheduling/config/static_schedule.yml
205
+ - examples/dynamic-scheduling/lib/tasks/resque.rake
206
+ - examples/run-resque-web
207
+ - lib/resque-scheduler.rb
144
208
  - lib/resque/scheduler.rb
145
209
  - lib/resque/scheduler/lock.rb
146
210
  - lib/resque/scheduler/lock/base.rb
@@ -148,10 +212,12 @@ files:
148
212
  - lib/resque/scheduler/lock/resilient.rb
149
213
  - lib/resque/scheduler_locking.rb
150
214
  - lib/resque_scheduler.rb
215
+ - lib/resque_scheduler/cli.rb
151
216
  - lib/resque_scheduler/logger_builder.rb
152
217
  - lib/resque_scheduler/plugin.rb
153
218
  - lib/resque_scheduler/server.rb
154
219
  - lib/resque_scheduler/server/views/delayed.erb
220
+ - lib/resque_scheduler/server/views/delayed_schedules.erb
155
221
  - lib/resque_scheduler/server/views/delayed_timestamp.erb
156
222
  - lib/resque_scheduler/server/views/requeue-params.erb
157
223
  - lib/resque_scheduler/server/views/scheduler.erb
@@ -161,6 +227,7 @@ files:
161
227
  - resque-scheduler.gemspec
162
228
  - script/migrate_to_timestamps_set.rb
163
229
  - tasks/resque_scheduler.rake
230
+ - test/cli_test.rb
164
231
  - test/delayed_queue_test.rb
165
232
  - test/redis-test.conf
166
233
  - test/resque-web_test.rb
@@ -168,34 +235,37 @@ files:
168
235
  - test/scheduler_hooks_test.rb
169
236
  - test/scheduler_locking_test.rb
170
237
  - test/scheduler_setup_test.rb
238
+ - test/scheduler_task_test.rb
171
239
  - test/scheduler_test.rb
172
240
  - test/support/redis_instance.rb
173
241
  - test/test_helper.rb
174
242
  homepage: http://github.com/resque/resque-scheduler
175
243
  licenses:
176
244
  - MIT
177
- metadata: {}
178
245
  post_install_message:
179
246
  rdoc_options: []
180
247
  require_paths:
181
248
  - lib
182
249
  required_ruby_version: !ruby/object:Gem::Requirement
250
+ none: false
183
251
  requirements:
184
252
  - - ! '>='
185
253
  - !ruby/object:Gem::Version
186
254
  version: '0'
187
255
  required_rubygems_version: !ruby/object:Gem::Requirement
256
+ none: false
188
257
  requirements:
189
258
  - - ! '>='
190
259
  - !ruby/object:Gem::Version
191
260
  version: '0'
192
261
  requirements: []
193
262
  rubyforge_project:
194
- rubygems_version: 2.0.3
263
+ rubygems_version: 1.8.23
195
264
  signing_key:
196
- specification_version: 4
265
+ specification_version: 3
197
266
  summary: Light weight job scheduling on top of Resque
198
267
  test_files:
268
+ - test/cli_test.rb
199
269
  - test/delayed_queue_test.rb
200
270
  - test/redis-test.conf
201
271
  - test/resque-web_test.rb
@@ -203,6 +273,7 @@ test_files:
203
273
  - test/scheduler_hooks_test.rb
204
274
  - test/scheduler_locking_test.rb
205
275
  - test/scheduler_setup_test.rb
276
+ - test/scheduler_task_test.rb
206
277
  - test/scheduler_test.rb
207
278
  - test/support/redis_instance.rb
208
279
  - test/test_helper.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDgyOTE0ZDU0NTg0MDZlNGRlM2ExZjQ0OWY5ZThhM2I3YzEyMGVmYg==
5
- data.tar.gz: !binary |-
6
- NjFkMGU4MDU2YTZiODdjMjk5NDdjNjY4YTg0MjY2ZWM3MmI5NGJhOA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- OGIwZjNmYzUyYzQwNGQ0ZjFhMGMzZjdiNTViMDVhYWU3Y2NmZDdiMjEyYzFj
10
- MjBmMTU1MTg2ZjQ0M2QzZjJiY2E5ZDZhM2YyYzFlYWZlYWIwZjI1Y2I2NjBh
11
- Y2M2ZDgzZDk3ZmRiODQ4ZjhhMGVjYTAxMzU0YjU3MTJiNTM1NTE=
12
- data.tar.gz: !binary |-
13
- MjEwNDRlOTkxNzZkMzQ2Y2U2YjUyY2FkMWEyZDFmZjUwOGUzNzM4YTNjOWJk
14
- MTZmMjQzNDczNWM4NjQ2NTk2NmU2OTQ3YzNhM2IwOThjZGUyMGI0MDgyNGQ3
15
- NWM4MDVlODllODkxZDM2MDcxNTBlODI2NjkyMjU4MjI3NjdlNjg=