rabbit_jobs 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rabbit_jobs/job.rb +6 -4
- data/lib/rabbit_jobs/version.rb +1 -1
- data/spec/fixtures/jobs.rb +7 -3
- data/spec/unit/job_spec.rb +13 -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: 459302e4464a2603075ca57898645a2442574ab9
|
4
|
+
data.tar.gz: cd812ebe548dbe8ef8ff8f84f4be51e708cb47a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 606585f72d012f07a5fa8c3251fbbbc7e94016ae06be1654b6cd52dedd26e56ca8fdeec85341ad1d15da9b1e3c470a46926e7ecd46cb117fc91a7a8ea3c8eb52
|
7
|
+
data.tar.gz: efe1979f043b93b048e2aa7f89274c639d9161290f2b189118672be20025ef3331e5fda471e418e67de28e211899c43ede639621c5c6c1c5352b71da211d4ce6
|
data/lib/rabbit_jobs/job.rb
CHANGED
@@ -50,9 +50,9 @@ module RabbitJobs
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def run_on_error_hooks(error, *params)
|
53
|
-
return unless
|
53
|
+
return unless self.class.on_error_hooks.try(:present?)
|
54
54
|
|
55
|
-
|
55
|
+
self.class.on_error_hooks.each do |proc_or_symbol|
|
56
56
|
proc = if proc_or_symbol.is_a?(Symbol)
|
57
57
|
method(proc_or_symbol)
|
58
58
|
else
|
@@ -109,13 +109,15 @@ module RabbitJobs
|
|
109
109
|
@expires_in
|
110
110
|
end
|
111
111
|
|
112
|
+
attr_reader :on_error_hooks
|
113
|
+
|
112
114
|
def on_error(*hooks)
|
113
|
-
@
|
115
|
+
@on_error_hooks ||= []
|
114
116
|
hooks.each do |proc_or_symbol|
|
115
117
|
unless proc_or_symbol.is_a?(Proc) || proc_or_symbol.is_a?(Symbol)
|
116
118
|
fail ArgumentError.new, 'Pass proc or symbol to on_error hook'
|
117
119
|
end
|
118
|
-
@
|
120
|
+
@on_error_hooks << proc_or_symbol
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
data/lib/rabbit_jobs/version.rb
CHANGED
data/spec/fixtures/jobs.rb
CHANGED
@@ -43,14 +43,18 @@ end
|
|
43
43
|
|
44
44
|
class JobWithErrorHook
|
45
45
|
include RJ::Job
|
46
|
-
on_error :first_hook,
|
46
|
+
on_error :first_hook, -> { puts 'second hook' }, :last_hook
|
47
47
|
|
48
48
|
def first_hook(error)
|
49
|
-
puts
|
49
|
+
puts "first hook, error: #{error}"
|
50
50
|
end
|
51
51
|
|
52
52
|
def last_hook(error)
|
53
|
-
puts
|
53
|
+
puts "last hook, error: #{error}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def some_other_method
|
57
|
+
puts 'some_other_method'
|
54
58
|
end
|
55
59
|
|
56
60
|
def perform
|
data/spec/unit/job_spec.rb
CHANGED
@@ -29,5 +29,18 @@ describe RabbitJobs::Job do
|
|
29
29
|
job.created_at = (Time.now).to_i
|
30
30
|
job.expired?.should == false
|
31
31
|
end
|
32
|
+
|
33
|
+
context :run_perform do
|
34
|
+
it 'runs on_error hooks when error occured in #perform' do
|
35
|
+
job = JobWithErrorHook.new
|
36
|
+
mock(job).first_hook.with_any_args
|
37
|
+
mock(job).last_hook.with_any_args
|
38
|
+
mock(RabbitJobs.logger).error.with_any_args
|
39
|
+
dont_allow(job).some_other_method
|
40
|
+
job.send :run_perform
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'measures and logs execution time'
|
44
|
+
end
|
32
45
|
end
|
33
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Lazureykis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|