exceptions_to_hipchat 0.1.0 → 0.1.1
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 +7 -0
- data/.rspec +2 -0
- data/Rakefile +7 -2
- data/exceptions_to_hipchat.gemspec +1 -0
- data/lib/exceptions_to_hipchat/notifier.rb +4 -3
- data/lib/exceptions_to_hipchat/version.rb +1 -1
- data/spec/exceptions_to_hipchat/notifier_spec.rb +79 -0
- data/spec/spec_helper.rb +2 -0
- metadata +27 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4640cc2e5f42a6da4cfe98f43c46fff7fc4580d8
|
4
|
+
data.tar.gz: df2bdb0a0dd8d4d712f00e65e566dbf69c33b48e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9c2c048abc0941fd04b63348cdf84c9d8cac6552522a0c3393dfb5116b85b2a93a216c35b192dcd0ea3a54bef6be0ffd7187ba9f5731f367868b163f50e2650
|
7
|
+
data.tar.gz: 48e6f7931859f5675a547e569405ff2e0f2cd761b3d7b978e5e74e378fb357a2f847a925dd0289ce55f704ee148af44a2bc73f013751f45b8fb9d0f7dbbd39f3
|
data/.rspec
ADDED
data/Rakefile
CHANGED
@@ -2,19 +2,20 @@ require 'hipchat'
|
|
2
2
|
|
3
3
|
module ExceptionsToHipchat
|
4
4
|
class Notifier
|
5
|
-
def initialize(app, options = {})
|
5
|
+
def initialize(app, options = {}, client = nil)
|
6
6
|
@app = app
|
7
|
-
@client = HipChat::Client.new(options[:api_token] || raise("HipChat API token is required"))
|
7
|
+
@client = client || HipChat::Client.new(options[:api_token] || raise("HipChat API token is required"))
|
8
8
|
@room = options[:room] || raise("HipChat room is required")
|
9
9
|
@color = options[:color] || :red
|
10
10
|
@notify = options[:notify]
|
11
11
|
@user = (options[:user] || "Notifier")[0...14]
|
12
|
+
@ignore = options[:ignore]
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(env)
|
15
16
|
@app.call(env)
|
16
17
|
rescue Exception => exception
|
17
|
-
send_to_hipchat exception
|
18
|
+
send_to_hipchat(exception) unless @ignore && @ignore.match(exception.to_s)
|
18
19
|
raise exception
|
19
20
|
end
|
20
21
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ExceptionsToHipchat::Notifier do
|
4
|
+
let(:app) { double('app') }
|
5
|
+
let(:room) { double('room') }
|
6
|
+
let(:client) { {testing: room } }
|
7
|
+
|
8
|
+
describe 'sending' do
|
9
|
+
let(:exception) { Exception.new('Some Exception') }
|
10
|
+
|
11
|
+
it 'sends to hipchat with default options' do
|
12
|
+
notifier = ExceptionsToHipchat::Notifier.new(app, {room: :testing}, client)
|
13
|
+
|
14
|
+
room.should_receive(:send).with('Notifier', '[Exception] Some Exception', color: :red, notify: nil)
|
15
|
+
app.stub(:call).and_raise(exception)
|
16
|
+
|
17
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'sends to hipchat with a different color' do
|
21
|
+
notifier = ExceptionsToHipchat::Notifier.new(app, {room: :testing, color: :purple}, client)
|
22
|
+
|
23
|
+
room.should_receive(:send).with('Notifier', '[Exception] Some Exception', color: :purple, notify: nil)
|
24
|
+
app.stub(:call).and_raise(exception)
|
25
|
+
|
26
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'sends to hipchat with a notification' do
|
30
|
+
notifier = ExceptionsToHipchat::Notifier.new(app, {room: :testing, notify: true}, client)
|
31
|
+
|
32
|
+
room.should_receive(:send).with('Notifier', '[Exception] Some Exception', color: :red, notify: true)
|
33
|
+
app.stub(:call).and_raise(exception)
|
34
|
+
|
35
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'sends to hipchat with a notifier' do
|
39
|
+
notifier = ExceptionsToHipchat::Notifier.new(app, {room: :testing, user: 'New Guy'}, client)
|
40
|
+
|
41
|
+
room.should_receive(:send).with('New Guy', '[Exception] Some Exception', color: :red, notify: nil)
|
42
|
+
app.stub(:call).and_raise(exception)
|
43
|
+
|
44
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'sends to hipchat with a truncated notifier' do
|
48
|
+
notifier = ExceptionsToHipchat::Notifier.new(app, {room: :testing, user: 'New Guyyyyyyyyyyyyyyyyyyyyyy'}, client)
|
49
|
+
|
50
|
+
room.should_receive(:send).with('New Guyyyyyyyy', '[Exception] Some Exception', color: :red, notify: nil)
|
51
|
+
app.stub(:call).and_raise(exception)
|
52
|
+
|
53
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'ignoring' do
|
58
|
+
let(:notifier) { ExceptionsToHipchat::Notifier.new(app, {room: :testing, ignore: /Some Exception/}, client) }
|
59
|
+
|
60
|
+
it 'ignores exceptions that match' do
|
61
|
+
exception = Exception.new('Some Exception')
|
62
|
+
|
63
|
+
app.stub(:call).and_raise(exception)
|
64
|
+
room.should_not_receive(:send)
|
65
|
+
|
66
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'does not ignore exceptions that do not match' do
|
70
|
+
exception = Exception.new('Some Other Exception')
|
71
|
+
|
72
|
+
app.stub(:call).and_raise(exception)
|
73
|
+
room.should_receive(:send)
|
74
|
+
|
75
|
+
expect {notifier.call('env')}.to raise_exception(exception)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exceptions_to_hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Darrin Holst
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: hipchat
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,11 +20,24 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.14.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.14.1
|
30
41
|
description:
|
31
42
|
email:
|
32
43
|
- darrinholst@gmail.com
|
@@ -35,6 +46,7 @@ extensions: []
|
|
35
46
|
extra_rdoc_files: []
|
36
47
|
files:
|
37
48
|
- .gitignore
|
49
|
+
- .rspec
|
38
50
|
- Gemfile
|
39
51
|
- LICENSE
|
40
52
|
- README.md
|
@@ -43,34 +55,31 @@ files:
|
|
43
55
|
- lib/exceptions_to_hipchat.rb
|
44
56
|
- lib/exceptions_to_hipchat/notifier.rb
|
45
57
|
- lib/exceptions_to_hipchat/version.rb
|
58
|
+
- spec/exceptions_to_hipchat/notifier_spec.rb
|
59
|
+
- spec/spec_helper.rb
|
46
60
|
homepage: http://github.com/darrinholst/exceptions_to_hipchat
|
47
61
|
licenses: []
|
62
|
+
metadata: {}
|
48
63
|
post_install_message:
|
49
64
|
rdoc_options: []
|
50
65
|
require_paths:
|
51
66
|
- lib
|
52
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
68
|
requirements:
|
55
|
-
- -
|
69
|
+
- - '>='
|
56
70
|
- !ruby/object:Gem::Version
|
57
71
|
version: '0'
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
hash: -2052345150592881705
|
61
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
73
|
requirements:
|
64
|
-
- -
|
74
|
+
- - '>='
|
65
75
|
- !ruby/object:Gem::Version
|
66
76
|
version: '0'
|
67
|
-
segments:
|
68
|
-
- 0
|
69
|
-
hash: -2052345150592881705
|
70
77
|
requirements: []
|
71
78
|
rubyforge_project:
|
72
|
-
rubygems_version:
|
79
|
+
rubygems_version: 2.0.6
|
73
80
|
signing_key:
|
74
|
-
specification_version:
|
81
|
+
specification_version: 4
|
75
82
|
summary: Send rails exceptions to HipChat
|
76
|
-
test_files:
|
83
|
+
test_files:
|
84
|
+
- spec/exceptions_to_hipchat/notifier_spec.rb
|
85
|
+
- spec/spec_helper.rb
|