dboard 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/collector.rb +10 -0
- data/lib/version.rb +1 -1
- data/spec/collector_spec.rb +15 -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: ba48cb0ffab690f4b38502e4bdf8f28d1e94422d
|
4
|
+
data.tar.gz: fc969a6e7516b14b8f4a222abde3db307f998a99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4df321724dde11ae0227ba274290a71da77d01cf7655488016f2f95d8a12d790d7dd1cf3c35bddca804d292baa365cb412719da0253f3fa832033467d9dbda2
|
7
|
+
data.tar.gz: 1e7f06619130542469f208ffbc53ce86dc3f6d759f8c2040d7bac7c97bb1284766117f907f410645fa6d811a6d9b529df6b3be2d6768b4140d8fcf9e59d18579
|
data/lib/collector.rb
CHANGED
@@ -15,6 +15,10 @@ module Dboard
|
|
15
15
|
Collector.instance.register_after_update_callback(callback)
|
16
16
|
end
|
17
17
|
|
18
|
+
def self.register_error_callback(callback)
|
19
|
+
Collector.instance.register_error_callback(callback)
|
20
|
+
end
|
21
|
+
|
18
22
|
def self.start
|
19
23
|
instance.start
|
20
24
|
end
|
@@ -22,6 +26,7 @@ module Dboard
|
|
22
26
|
def initialize
|
23
27
|
@sources = {}
|
24
28
|
@after_update_callback = lambda {}
|
29
|
+
@error_callback = lambda { |exception| }
|
25
30
|
end
|
26
31
|
|
27
32
|
def start
|
@@ -45,6 +50,10 @@ module Dboard
|
|
45
50
|
@after_update_callback = callback
|
46
51
|
end
|
47
52
|
|
53
|
+
def register_error_callback(callback)
|
54
|
+
@error_callback = callback
|
55
|
+
end
|
56
|
+
|
48
57
|
# Public because the old tests depend on it
|
49
58
|
def update_source(source, instance)
|
50
59
|
begin
|
@@ -56,6 +65,7 @@ module Dboard
|
|
56
65
|
rescue Exception => ex
|
57
66
|
puts "Failed to update #{source}: #{ex.message}"
|
58
67
|
puts ex.backtrace
|
68
|
+
@error_callback.call(ex)
|
59
69
|
end
|
60
70
|
|
61
71
|
private
|
data/lib/version.rb
CHANGED
data/spec/collector_spec.rb
CHANGED
@@ -25,6 +25,21 @@ describe Dboard::Collector, "register_source" do
|
|
25
25
|
# since it is a singleton, and this callbacks leaks into the other tests
|
26
26
|
Dboard::Collector.register_after_update_callback(lambda {})
|
27
27
|
end
|
28
|
+
|
29
|
+
it "can register an error callback" do
|
30
|
+
new_relic = mock
|
31
|
+
error = RuntimeError.new("error")
|
32
|
+
new_relic.stub!(:fetch).and_raise(error)
|
33
|
+
callback = mock
|
34
|
+
Dboard::Collector.register_error_callback callback
|
35
|
+
|
36
|
+
callback.should_receive(:call).with(error)
|
37
|
+
Dboard::Publisher.stub!(:publish)
|
38
|
+
Dboard::Collector.instance.update_source(:new_relic, new_relic)
|
39
|
+
|
40
|
+
# since it is a singleton, and this callbacks leaks into the other tests
|
41
|
+
Dboard::Collector.register_error_callback(lambda { |_| })
|
42
|
+
end
|
28
43
|
end
|
29
44
|
|
30
45
|
describe Dboard::Collector, "update_source" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Kolsjö
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|