rabbit_jobs 0.12.1 → 0.12.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d36769d8fc6a0ac19a16b99fad47c5e57689b9d
4
- data.tar.gz: 1af3fde5136cf8bcf2d15eac7232c1be8c94ba14
3
+ metadata.gz: 459302e4464a2603075ca57898645a2442574ab9
4
+ data.tar.gz: cd812ebe548dbe8ef8ff8f84f4be51e708cb47a8
5
5
  SHA512:
6
- metadata.gz: 172d4010683cb8cb8ba0546c6446a76365485d093de6d022fa01e2a65d9bf54e88dffdf86df91574d08123fa9bd531dcf0eddca5db9503932e262df541253440
7
- data.tar.gz: 7252412a56b66d6788b011794776fcdad917eb54c38874ca498c1174c13f7531d5decfbeda63926172a06bf2cdf6feebb1434151bf07d105dc631c1a081f8d17
6
+ metadata.gz: 606585f72d012f07a5fa8c3251fbbbc7e94016ae06be1654b6cd52dedd26e56ca8fdeec85341ad1d15da9b1e3c470a46926e7ecd46cb117fc91a7a8ea3c8eb52
7
+ data.tar.gz: efe1979f043b93b048e2aa7f89274c639d9161290f2b189118672be20025ef3331e5fda471e418e67de28e211899c43ede639621c5c6c1c5352b71da211d4ce6
@@ -50,9 +50,9 @@ module RabbitJobs
50
50
  end
51
51
 
52
52
  def run_on_error_hooks(error, *params)
53
- return unless @@rj_on_error_hooks.try(:present?)
53
+ return unless self.class.on_error_hooks.try(:present?)
54
54
 
55
- @@rj_on_error_hooks.each do |proc_or_symbol|
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
- @rj_on_error_hooks ||= []
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
- @rj_on_error_hooks << proc_or_symbol
120
+ @on_error_hooks << proc_or_symbol
119
121
  end
120
122
  end
121
123
 
@@ -1,3 +1,3 @@
1
1
  module RabbitJobs
2
- VERSION = '0.12.1'
2
+ VERSION = '0.12.2'
3
3
  end
@@ -43,14 +43,18 @@ end
43
43
 
44
44
  class JobWithErrorHook
45
45
  include RJ::Job
46
- on_error :first_hook, lambda { puts "second hook" }, :last_hook
46
+ on_error :first_hook, -> { puts 'second hook' }, :last_hook
47
47
 
48
48
  def first_hook(error)
49
- puts 'first hook'
49
+ puts "first hook, error: #{error}"
50
50
  end
51
51
 
52
52
  def last_hook(error)
53
- puts 'last hook'
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
@@ -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.1
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-05 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny