ablab 0.2.7 → 0.2.8

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: 5a3a8192557cb955a5a5ed9ac4cb1d5bdfa77d65
4
- data.tar.gz: af157d385087acf9efb8fcac04304ac840520f5d
3
+ metadata.gz: 58f3558e8df0966c774c936d9abb1ea3ef30cb40
4
+ data.tar.gz: 5296df570693f9db5e472cf6b18a1be20fd5fec0
5
5
  SHA512:
6
- metadata.gz: 3bb8eba0ef626352fe9a816b8d8f8eacd97b51c7fee39671642af756d4168b4520c23e3198671b41e9d001780231003b1a7f27bbd5f1330c33c1afa009af1a66
7
- data.tar.gz: 9bc780a0e4652f793797070304ba65a5f3a1796fcd9a894da569976ed3694e5ecfe9343df92e91fa266b80f6deec0cb27b821ad2108c3978ae2cdbd67274aa57
6
+ metadata.gz: 9fddf7df11963b05e36359ff02659070e1211c6c1f06ecd712725dd2ac5f936a7b05e8134bb6c8981236247226b32d4598b64545fd85156f27a815f758ec27a8
7
+ data.tar.gz: 427443b6a68e2333f898fb916ed2ddb9f895f2f9d1ee0530f120bb5ef5e0945c363e7c68d4b947823176f5a82bdda1f1f3e730c88c55e7bdddd92f761a1a3d81
@@ -44,6 +44,14 @@ module Ablab
44
44
  (@callbacks ||= []) << block
45
45
  end
46
46
 
47
+ def on_tracking_exception(&block)
48
+ @tracking_exception_handler = block
49
+ end
50
+
51
+ def tracking_exception_handler
52
+ @tracking_exception_handler || Proc.new { |e| raise e }
53
+ end
54
+
47
55
  def callbacks
48
56
  @callbacks || []
49
57
  end
@@ -114,6 +122,8 @@ module Ablab
114
122
  Thread.new do
115
123
  perform_callbacks!(:view)
116
124
  end
125
+ rescue => e
126
+ Ablab.tracking_exception_handler.call(e)
117
127
  end
118
128
 
119
129
  def track_success!
@@ -121,6 +131,8 @@ module Ablab
121
131
  Thread.new do
122
132
  perform_callbacks!(:success)
123
133
  end
134
+ rescue => e
135
+ Ablab.tracking_exception_handler.call(e)
124
136
  end
125
137
 
126
138
  def group
@@ -1,3 +1,3 @@
1
1
  module Ablab
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -61,6 +61,14 @@ describe Ablab do
61
61
  end
62
62
  end
63
63
 
64
+ describe ".on_tracking_exception" do
65
+ it "adds a tracking exception handler" do
66
+ p = Proc.new {}
67
+ ab.on_tracking_exception(&p)
68
+ expect(ab.tracking_exception_handler).to be(p)
69
+ end
70
+ end
71
+
64
72
  describe Ablab::Experiment do
65
73
  let(:experiment) do
66
74
  Ablab::Experiment.new('foo') do; end
@@ -246,6 +254,15 @@ describe Ablab do
246
254
  expect(x).to eq([:view, :foo, run.group, run.session_id, request])
247
255
  expect(y).to eq([:view, :foo, run.group, run.session_id, request])
248
256
  end
257
+
258
+ it "call exception handler if given" do
259
+ exception = nil
260
+ allow(Ablab.tracker).to receive(:track_view!) { raise "Boom!" }
261
+ allow(Ablab).to receive(:tracking_exception_handler)
262
+ .and_return(Proc.new { |e| exception = e })
263
+ expect { run.track_view! }.to_not raise_error
264
+ expect(exception).to be_a(StandardError)
265
+ end
249
266
  end
250
267
 
251
268
  describe "#track_success!" do
@@ -268,6 +285,15 @@ describe Ablab do
268
285
  expect(x).to eq([:success, :foo, run.group, run.session_id, request])
269
286
  expect(y).to eq([:success, :foo, run.group, run.session_id, request])
270
287
  end
288
+
289
+ it "call exception handler if given" do
290
+ exception = nil
291
+ allow(Ablab.tracker).to receive(:track_success!) { raise "Boom!" }
292
+ allow(Ablab).to receive(:tracking_exception_handler)
293
+ .and_return(Proc.new { |e| exception = e })
294
+ expect { run.track_success! }.to_not raise_error
295
+ expect(exception).to be_a(StandardError)
296
+ end
271
297
  end
272
298
  end
273
299
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ablab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Ongaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-04 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails