resque_unit 0.3.7 → 0.4.0
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.
- data/lib/resque_unit/assertions.rb +6 -11
- data/lib/resque_unit/helpers.rb +1 -1
- data/lib/resque_unit/resque.rb +60 -30
- data/lib/resque_unit/scheduler.rb +5 -8
- data/lib/resque_unit/scheduler_assertions.rb +3 -1
- data/test/resque_test.rb +61 -0
- data/test/resque_unit_test.rb +53 -25
- data/test/sample_jobs.rb +64 -14
- metadata +8 -18
@@ -21,9 +21,9 @@ module ResqueUnit::Assertions
|
|
21
21
|
queue = if block_given?
|
22
22
|
snapshot = Resque.size(queue_name)
|
23
23
|
yield
|
24
|
-
Resque.
|
24
|
+
Resque.all(queue_name)[snapshot..-1]
|
25
25
|
else
|
26
|
-
Resque.
|
26
|
+
Resque.all(queue_name)
|
27
27
|
end
|
28
28
|
|
29
29
|
assert_with_custom_message(!in_queue?(queue, klass, args),
|
@@ -43,9 +43,9 @@ module ResqueUnit::Assertions
|
|
43
43
|
queue = if block_given?
|
44
44
|
snapshot = Resque.size(queue_name)
|
45
45
|
yield
|
46
|
-
Resque.
|
46
|
+
Resque.all(queue_name)[snapshot..-1]
|
47
47
|
else
|
48
|
-
Resque.
|
48
|
+
Resque.all(queue_name)
|
49
49
|
end
|
50
50
|
|
51
51
|
assert_with_custom_message(in_queue?(queue, klass, args),
|
@@ -74,13 +74,8 @@ module ResqueUnit::Assertions
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def matching_jobs(queue, klass, args = nil)
|
77
|
-
|
78
|
-
|
79
|
-
args = Resque.normalized_args(args)
|
80
|
-
queue.select {|e| e[:klass] == klass && e[:args] == args}
|
81
|
-
else # if no args were passed, retrieve all queued jobs that match klass
|
82
|
-
queue.select {|e| e[:klass] == klass}
|
83
|
-
end
|
77
|
+
normalized_args = Resque.decode(Resque.encode(args)) if args
|
78
|
+
queue.select {|e| e["class"] == klass.to_s && (!args || e["args"] == normalized_args )}
|
84
79
|
end
|
85
80
|
|
86
81
|
end
|
data/lib/resque_unit/helpers.rb
CHANGED
data/lib/resque_unit/resque.rb
CHANGED
@@ -24,13 +24,42 @@ module Resque
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Returns an array of all the jobs that have been queued. Each
|
27
|
-
# element is of the form +{
|
27
|
+
# element is of the form +{"class" => klass, "args" => args}+ where
|
28
28
|
# +klass+ is the job's class and +args+ is an array of the arguments
|
29
29
|
# passed to the job.
|
30
30
|
def queue(queue_name)
|
31
31
|
queues[queue_name]
|
32
32
|
end
|
33
33
|
|
34
|
+
# Return an array of all jobs' payloads for queue
|
35
|
+
# Elements are decoded
|
36
|
+
def all(queue_name)
|
37
|
+
result = list_range(queue_name, 0, size(queue_name))
|
38
|
+
result.is_a?(Array) ? result : [ result ]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns an array of jobs' payloads for queue.
|
42
|
+
#
|
43
|
+
# start and count should be integer and can be used for pagination.
|
44
|
+
# start is the item to begin, count is how many items to return.
|
45
|
+
#
|
46
|
+
# To get the 3rd page of a 30 item, paginatied list one would use:
|
47
|
+
# Resque.peek('my_list', 59, 30)
|
48
|
+
def peek(queue_name, start = 0, count = 1)
|
49
|
+
list_range(queue_name, start, count)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Gets a range of jobs' payloads from queue.
|
53
|
+
# Returns single element if count equal 1
|
54
|
+
# Elements are decoded
|
55
|
+
def list_range(key, start = 0, count = 1)
|
56
|
+
data = if count == 1
|
57
|
+
decode(queues[key][start])
|
58
|
+
else
|
59
|
+
(queues[key][start...start + count] || []).map { |entry| decode(entry) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
34
63
|
# Yes, all Resque hooks!
|
35
64
|
def enable_hooks!
|
36
65
|
@hooks_enabled = true
|
@@ -45,20 +74,23 @@ module Resque
|
|
45
74
|
old_queue = @queue.dup
|
46
75
|
self.reset!
|
47
76
|
|
48
|
-
|
49
|
-
|
50
|
-
|
77
|
+
|
78
|
+
old_queue.each do |queue_name, queue|
|
79
|
+
queue.each do |job_payload|
|
80
|
+
job_payload = decode(job_payload)
|
81
|
+
@hooks_enabled ? perform_with_hooks(job_payload) : perform_without_hooks(job_payload)
|
51
82
|
end
|
52
83
|
end
|
53
84
|
end
|
54
85
|
|
55
86
|
# Executes all jobs in the given queue in an undefined order.
|
56
87
|
def run_for!(queue_name)
|
57
|
-
|
88
|
+
jobs_payloads = all(queue_name)
|
89
|
+
|
58
90
|
self.reset!(queue_name)
|
59
91
|
|
60
|
-
|
61
|
-
@hooks_enabled ? perform_with_hooks(
|
92
|
+
jobs_payloads.each do |job_payload|
|
93
|
+
@hooks_enabled ? perform_with_hooks(job_payload) : perform_without_hooks(job_payload)
|
62
94
|
end
|
63
95
|
end
|
64
96
|
|
@@ -83,11 +115,7 @@ module Resque
|
|
83
115
|
queue_name = queue_for(klass)
|
84
116
|
# Behaves like Resque, raise if no queue was specifed
|
85
117
|
raise NoQueueError.new("Jobs must be placed onto a queue.") unless queue_name
|
86
|
-
enqueue_unit(queue_name, {
|
87
|
-
end
|
88
|
-
|
89
|
-
def normalized_args(args)
|
90
|
-
decode(encode(args))
|
118
|
+
enqueue_unit(queue_name, {"class" => klass.name, "args" => args })
|
91
119
|
end
|
92
120
|
|
93
121
|
# :nodoc:
|
@@ -103,33 +131,35 @@ module Resque
|
|
103
131
|
end
|
104
132
|
|
105
133
|
def enqueue_unit(queue_name, hash)
|
106
|
-
|
134
|
+
klass = constantize(hash["class"])
|
135
|
+
queue(queue_name) << encode(hash)
|
107
136
|
if @hooks_enabled
|
108
|
-
Plugin.after_enqueue_hooks(
|
109
|
-
|
137
|
+
Plugin.after_enqueue_hooks(klass).each do |hook|
|
138
|
+
klass.send(hook, *hash["args"])
|
110
139
|
end
|
111
140
|
end
|
112
141
|
queue(queue_name).size
|
113
142
|
end
|
114
143
|
|
115
144
|
# Call perform on the job class
|
116
|
-
def perform_without_hooks(
|
117
|
-
|
145
|
+
def perform_without_hooks(job_payload)
|
146
|
+
constantize(job_payload["class"]).perform(*job_payload["args"])
|
118
147
|
end
|
119
148
|
|
120
149
|
# Call perform on the job class, and adds support for Resque hooks.
|
121
|
-
def perform_with_hooks(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
150
|
+
def perform_with_hooks(job_payload)
|
151
|
+
job_class = constantize(job_payload["class"])
|
152
|
+
before_hooks = Resque::Plugin.before_hooks(job_class)
|
153
|
+
around_hooks = Resque::Plugin.around_hooks(job_class)
|
154
|
+
after_hooks = Resque::Plugin.after_hooks(job_class)
|
155
|
+
failure_hooks = Resque::Plugin.failure_hooks(job_class)
|
126
156
|
|
127
157
|
begin
|
128
158
|
# Execute before_perform hook. Abort the job gracefully if
|
129
159
|
# Resque::DontPerform is raised.
|
130
160
|
begin
|
131
161
|
before_hooks.each do |hook|
|
132
|
-
|
162
|
+
job_class.send(hook, *job_payload["args"])
|
133
163
|
end
|
134
164
|
rescue Resque::Job::DontPerform
|
135
165
|
return false
|
@@ -137,7 +167,7 @@ module Resque
|
|
137
167
|
|
138
168
|
# Execute the job. Do it in an around_perform hook if available.
|
139
169
|
if around_hooks.empty?
|
140
|
-
perform_without_hooks(
|
170
|
+
perform_without_hooks(job_payload)
|
141
171
|
job_was_performed = true
|
142
172
|
else
|
143
173
|
# We want to nest all around_perform plugins, with the last one
|
@@ -145,12 +175,12 @@ module Resque
|
|
145
175
|
stack = around_hooks.reverse.inject(nil) do |last_hook, hook|
|
146
176
|
if last_hook
|
147
177
|
lambda do
|
148
|
-
|
178
|
+
job_class.send(hook, *job_payload["args"]) { last_hook.call }
|
149
179
|
end
|
150
180
|
else
|
151
181
|
lambda do
|
152
|
-
|
153
|
-
result = perform_without_hooks(
|
182
|
+
job_class.send(hook, *job_payload["args"]) do
|
183
|
+
result = perform_without_hooks(job_payload)
|
154
184
|
job_was_performed = true
|
155
185
|
result
|
156
186
|
end
|
@@ -162,7 +192,7 @@ module Resque
|
|
162
192
|
|
163
193
|
# Execute after_perform hook
|
164
194
|
after_hooks.each do |hook|
|
165
|
-
|
195
|
+
job_class.send(hook, *job_payload["args"])
|
166
196
|
end
|
167
197
|
|
168
198
|
# Return true if the job was performed
|
@@ -171,7 +201,7 @@ module Resque
|
|
171
201
|
# If an exception occurs during the job execution, look for an
|
172
202
|
# on_failure hook then re-raise.
|
173
203
|
rescue => e
|
174
|
-
failure_hooks.each { |hook|
|
204
|
+
failure_hooks.each { |hook| job_class.send(hook, e, *job_payload["args"]) }
|
175
205
|
raise e
|
176
206
|
end
|
177
207
|
end
|
@@ -179,7 +209,7 @@ module Resque
|
|
179
209
|
class Job
|
180
210
|
extend Helpers
|
181
211
|
def self.create(queue, klass_name, *args)
|
182
|
-
Resque.enqueue_unit(queue, {
|
212
|
+
Resque.enqueue_unit(queue, {"class" => constantize(klass_name), "args" => args})
|
183
213
|
end
|
184
214
|
end
|
185
215
|
|
@@ -19,17 +19,14 @@ module ResqueUnit
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def enqueue_with_timestamp(timestamp, klass, *args)
|
22
|
-
enqueue_unit(queue_for(klass), {
|
22
|
+
enqueue_unit(queue_for(klass), {"class" => klass, "args" => args, "timestamp" => timestamp})
|
23
23
|
end
|
24
24
|
|
25
25
|
def remove_delayed(klass, *args)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
else # if no args were passed, retrieve all queued jobs that match klass
|
31
|
-
queue.delete_if {|e| e[:klass] == klass}
|
32
|
-
end
|
26
|
+
# points to real queue
|
27
|
+
encoded_job_payloads = Resque.queue(queue_for(klass))
|
28
|
+
args ||= []
|
29
|
+
encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && e["args"] == args }
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# These are a group of assertions you can use in your unit tests to
|
2
2
|
# verify that your code is using resque-scheduler correctly.
|
3
|
+
require 'time'
|
4
|
+
|
3
5
|
module ResqueUnit::SchedulerAssertions
|
4
6
|
|
5
7
|
# Asserts that +klass+ has been queued into its appropriate queue at
|
@@ -41,7 +43,7 @@ module ResqueUnit::SchedulerAssertions
|
|
41
43
|
def in_timestamped_queue?(queue_name, expected_timestamp, klass, args = nil)
|
42
44
|
# check if we have any matching jobs with a timestamp less than
|
43
45
|
# expected_timestamp
|
44
|
-
!matching_jobs(Resque.
|
46
|
+
!matching_jobs(Resque.all(queue_name), klass, args).select {|e| e["timestamp"] && Time.parse(e["timestamp"]) <= expected_timestamp}.empty?
|
45
47
|
end
|
46
48
|
|
47
49
|
end
|
data/test/resque_test.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ResqueTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Resque.reset!
|
7
|
+
end
|
8
|
+
|
9
|
+
context "with one queued job" do
|
10
|
+
setup do
|
11
|
+
Resque.enqueue(MediumPriorityJob, "some args")
|
12
|
+
@job_payload = {"args"=>["some args"], "class"=>"MediumPriorityJob"}
|
13
|
+
end
|
14
|
+
|
15
|
+
should "return job payload when peek method called with count equal 1" do
|
16
|
+
assert_equal @job_payload, Resque.peek(MediumPriorityJob.queue, 0, 1)
|
17
|
+
end
|
18
|
+
|
19
|
+
should "return array of jobs' payloads when peek method called with count different than 1" do
|
20
|
+
assert_equal [@job_payload], Resque.peek(MediumPriorityJob.queue, 0, 5)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with few queued jobs" do
|
25
|
+
setup do
|
26
|
+
Resque.enqueue(MediumPriorityJob, "1")
|
27
|
+
Resque.enqueue(MediumPriorityJob, "2")
|
28
|
+
Resque.enqueue(MediumPriorityJob, "3")
|
29
|
+
end
|
30
|
+
|
31
|
+
should "return jobs' payloads 2 and 3 when peek method called with start equal 1 and count equal 2" do
|
32
|
+
assert_equal [["2"], ["3"]], Resque.peek(MediumPriorityJob.queue, 1, 2).map{|h| h["args"]}
|
33
|
+
end
|
34
|
+
|
35
|
+
should "return empty array when peek method called with start higher than queue size" do
|
36
|
+
assert_equal [], Resque.peek(MediumPriorityJob.queue, 4, 2)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "return empty array when peek method called with count equal 0" do
|
40
|
+
assert_equal [], Resque.peek(MediumPriorityJob.queue, 0, 0)
|
41
|
+
end
|
42
|
+
|
43
|
+
should "return all jobs' payloads when all method called" do
|
44
|
+
assert Resque.all(MediumPriorityJob.queue).length == 3, "should return all 3 elements"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "without queued jobs" do
|
49
|
+
should "return nil when peek method called with count equal 1" do
|
50
|
+
assert_equal nil, Resque.peek(MediumPriorityJob.queue, 0, 1)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "return empty array when peek method called with count not equal 1" do
|
54
|
+
assert_equal [], Resque.peek(MediumPriorityJob.queue, 0, 999)
|
55
|
+
end
|
56
|
+
|
57
|
+
should "return empty array when all method called" do
|
58
|
+
assert_equal [], Resque.all(MediumPriorityJob.queue)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/test/resque_unit_test.rb
CHANGED
@@ -65,49 +65,77 @@ class ResqueUnitTest < Test::Unit::TestCase
|
|
65
65
|
context "A task that schedules a resque job with hooks" do
|
66
66
|
setup do
|
67
67
|
Resque.enable_hooks!
|
68
|
-
JobWithHooks.clear_markers
|
69
|
-
Resque.enqueue(JobWithHooks)
|
70
68
|
end
|
71
69
|
|
72
70
|
teardown do
|
73
71
|
Resque.disable_hooks!
|
74
72
|
end
|
75
73
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
context "before, around, after, failure, after_enqueue" do
|
75
|
+
setup do
|
76
|
+
JobWithHooks.clear_markers
|
77
|
+
Resque.enqueue(JobWithHooks)
|
78
|
+
end
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
should "have run the after_enqueue hook" do
|
81
|
+
assert_queued(JobWithHooks)
|
82
|
+
assert(JobWithHooks.markers[:after_enqueue], 'no after_queue marker set')
|
83
|
+
end
|
84
|
+
|
85
|
+
should "run the before and after hooks during a run" do
|
86
|
+
Resque.run!
|
87
|
+
assert(JobWithHooks.markers[:before], 'no before marker set')
|
88
|
+
assert(JobWithHooks.markers[:around], 'no around marker set')
|
89
|
+
assert(JobWithHooks.markers[:after], 'no after marker set')
|
90
|
+
assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
|
91
|
+
end
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
|
93
|
+
should "run the before and failed hooks during a run" do
|
94
|
+
JobWithHooks.make_it_fail do
|
95
|
+
assert_raise(RuntimeError) do
|
96
|
+
Resque.run!
|
97
|
+
assert(JobWithHooks.markers[:before], 'no before marker set')
|
98
|
+
assert(JobWithHooks.markers[:around], 'no around marker set')
|
99
|
+
assert(!JobWithHooks.markers[:after], 'after marker set, and it should not')
|
100
|
+
assert(JobWithHooks.markers[:failed], 'no failed marker set')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
should "not call perform if the around hook raised Resque::Job::DontPerform" do
|
106
|
+
JobWithHooks.make_it_dont_perform do
|
92
107
|
Resque.run!
|
93
108
|
assert(JobWithHooks.markers[:before], 'no before marker set')
|
94
109
|
assert(JobWithHooks.markers[:around], 'no around marker set')
|
95
110
|
assert(!JobWithHooks.markers[:after], 'after marker set, and it should not')
|
96
|
-
assert(JobWithHooks.markers[:failed], '
|
111
|
+
assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
|
97
112
|
end
|
98
113
|
end
|
99
114
|
end
|
100
115
|
|
101
|
-
|
102
|
-
|
116
|
+
context "but without before" do
|
117
|
+
setup do
|
118
|
+
JobWithHooksWithoutBefore.clear_markers
|
119
|
+
Resque.enqueue(JobWithHooksWithoutBefore)
|
120
|
+
end
|
121
|
+
|
122
|
+
should "not run before hooks during a run" do
|
103
123
|
Resque.run!
|
104
|
-
assert(
|
105
|
-
assert(JobWithHooks.markers[:around], 'no around marker set')
|
106
|
-
assert(!JobWithHooks.markers[:after], 'after marker set, and it should not')
|
107
|
-
assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
|
124
|
+
assert(!JobWithHooksWithoutBefore.markers[:before], 'before marker set, and it should not')
|
108
125
|
end
|
109
126
|
end
|
110
127
|
|
128
|
+
context "but without around" do
|
129
|
+
setup do
|
130
|
+
JobWithHooksWithoutAround.clear_markers
|
131
|
+
Resque.enqueue(JobWithHooksWithoutAround)
|
132
|
+
end
|
133
|
+
|
134
|
+
should "not run around hooks during a run" do
|
135
|
+
Resque.run!
|
136
|
+
assert(!JobWithHooksWithoutAround.markers[:around], 'around marker set, and it should not')
|
137
|
+
end
|
138
|
+
end
|
111
139
|
end
|
112
140
|
|
113
141
|
context "Block assertions" do
|
@@ -117,14 +145,14 @@ class ResqueUnitTest < Test::Unit::TestCase
|
|
117
145
|
end
|
118
146
|
end
|
119
147
|
|
120
|
-
should "pass the assert_queued(job) assertion when queued
|
148
|
+
should "pass the assert_queued(job) assertion when queued in block and outside" do
|
121
149
|
Resque.enqueue(HighPriorityJob)
|
122
150
|
assert_queues(HighPriorityJob) do
|
123
151
|
Resque.enqueue(HighPriorityJob)
|
124
152
|
end
|
125
153
|
end
|
126
154
|
|
127
|
-
should "fail the assert_queued(job) assertion when not queued in block" do
|
155
|
+
should "fail the assert_queued(job) assertion when not queued in block but outside" do
|
128
156
|
Resque.enqueue(LowPriorityJob)
|
129
157
|
assert_raise Test::Unit::AssertionFailedError do
|
130
158
|
assert_queues(LowPriorityJob) do
|
data/test/sample_jobs.rb
CHANGED
@@ -49,10 +49,26 @@ class JobThatDoesNotSpecifyAQueue
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
module HooksMethods
|
53
|
+
def after_enqueue_mark(*args)
|
54
|
+
markers[:after_enqueue] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
def after_perform_mark(*args)
|
58
|
+
markers[:after] = true
|
59
|
+
end
|
60
|
+
|
61
|
+
def failure_perform_mark(*args)
|
62
|
+
markers[:failure] = true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
52
66
|
class JobWithHooks
|
67
|
+
extend HooksMethods
|
68
|
+
|
53
69
|
@queue = :with_hooks
|
54
70
|
@markers = {}
|
55
|
-
|
71
|
+
|
56
72
|
def self.perform
|
57
73
|
raise 'FAIL!' if @will_fail
|
58
74
|
end
|
@@ -65,10 +81,6 @@ class JobWithHooks
|
|
65
81
|
@markers = {}
|
66
82
|
end
|
67
83
|
|
68
|
-
def self.after_enqueue_mark(*args)
|
69
|
-
markers[:after_enqueue] = true
|
70
|
-
end
|
71
|
-
|
72
84
|
def self.before_perform_mark(*args)
|
73
85
|
markers[:before] = true
|
74
86
|
end
|
@@ -82,14 +94,6 @@ class JobWithHooks
|
|
82
94
|
end
|
83
95
|
end
|
84
96
|
|
85
|
-
def self.after_perform_mark(*args)
|
86
|
-
markers[:after] = true
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.failure_perform_mark(*args)
|
90
|
-
markers[:failure] = true
|
91
|
-
end
|
92
|
-
|
93
97
|
def self.make_it_fail(&block)
|
94
98
|
@will_fail = true
|
95
99
|
yield
|
@@ -102,5 +106,51 @@ class JobWithHooks
|
|
102
106
|
ensure
|
103
107
|
@dont_perform = false
|
104
108
|
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class JobWithHooksWithoutBefore
|
112
|
+
extend HooksMethods
|
113
|
+
|
114
|
+
@queue = :with_hooks
|
115
|
+
@markers = {}
|
116
|
+
|
117
|
+
def self.markers
|
118
|
+
@markers
|
119
|
+
end
|
105
120
|
|
106
|
-
|
121
|
+
def self.clear_markers
|
122
|
+
@markers = {}
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.perform; end
|
126
|
+
|
127
|
+
def self.around_perform_mark(*args)
|
128
|
+
markers[:around] = true
|
129
|
+
if @dont_perform
|
130
|
+
raise Resque::Job::DontPerform
|
131
|
+
else
|
132
|
+
yield
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class JobWithHooksWithoutAround
|
138
|
+
extend HooksMethods
|
139
|
+
|
140
|
+
@queue = :with_hooks
|
141
|
+
@markers = {}
|
142
|
+
|
143
|
+
def self.markers
|
144
|
+
@markers
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.clear_markers
|
148
|
+
@markers = {}
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.perform; end
|
152
|
+
|
153
|
+
def self.before_perform_mark(*args)
|
154
|
+
markers[:before] = true
|
155
|
+
end
|
156
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 7
|
9
|
-
version: 0.3.7
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Justin Weiss
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-06-28 00:00:00 -07:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -24,10 +20,6 @@ dependencies:
|
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 4
|
30
|
-
- 6
|
31
23
|
version: 1.4.6
|
32
24
|
type: :runtime
|
33
25
|
prerelease: false
|
@@ -39,8 +31,6 @@ dependencies:
|
|
39
31
|
requirements:
|
40
32
|
- - ">="
|
41
33
|
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 0
|
44
34
|
version: "0"
|
45
35
|
type: :development
|
46
36
|
prerelease: false
|
@@ -52,8 +42,6 @@ dependencies:
|
|
52
42
|
requirements:
|
53
43
|
- - ">="
|
54
44
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
45
|
version: "0"
|
58
46
|
type: :development
|
59
47
|
prerelease: false
|
@@ -76,6 +64,7 @@ files:
|
|
76
64
|
- lib/resque_unit/scheduler_assertions.rb
|
77
65
|
- lib/resque_unit.rb
|
78
66
|
- lib/resque_unit_scheduler.rb
|
67
|
+
- test/resque_test.rb
|
79
68
|
- test/resque_unit_scheduler_test.rb
|
80
69
|
- test/resque_unit_test.rb
|
81
70
|
- test/sample_jobs.rb
|
@@ -95,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
84
|
requirements:
|
96
85
|
- - ">="
|
97
86
|
- !ruby/object:Gem::Version
|
98
|
-
hash: -
|
87
|
+
hash: -1898540308835741897
|
99
88
|
segments:
|
100
89
|
- 0
|
101
90
|
version: "0"
|
@@ -104,17 +93,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
93
|
requirements:
|
105
94
|
- - ">="
|
106
95
|
- !ruby/object:Gem::Version
|
107
|
-
hash: -
|
96
|
+
hash: -1898540308835741897
|
108
97
|
segments:
|
109
98
|
- 0
|
110
99
|
version: "0"
|
111
100
|
requirements: []
|
112
101
|
|
113
102
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.5.0
|
115
104
|
signing_key:
|
116
105
|
specification_version: 3
|
117
106
|
summary: Test::Unit support for resque job queueing
|
118
107
|
test_files:
|
108
|
+
- test/resque_test.rb
|
119
109
|
- test/resque_unit_scheduler_test.rb
|
120
110
|
- test/resque_unit_test.rb
|