exceptions_to_hipchat 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +20 -0
- data/Rakefile +2 -0
- data/exceptions_to_hipchat.gemspec +18 -0
- data/lib/exceptions_to_hipchat/notifier.rb +33 -0
- data/lib/exceptions_to_hipchat/version.rb +3 -0
- data/lib/exceptions_to_hipchat.rb +2 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Darrin Holst
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# ExceptionsToHipchat
|
2
|
+
|
3
|
+
Sends exceptions to HipChat
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'exceptions_to_hipchat'
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Rails 3: add as rack middleware to `application.rb'
|
14
|
+
|
15
|
+
config.middleware.use ExceptionsToHipchat::Notifier,
|
16
|
+
:api_token => "YOUR TOKEN",
|
17
|
+
:room => "YOUR ROOM",
|
18
|
+
:user => "USER MESSAGE WILL COME FROM (MAX 15 CHARACTERS)",
|
19
|
+
:notify => Rails.env.production?
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/exceptions_to_hipchat/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Darrin Holst"]
|
6
|
+
gem.email = ["darrinholst@gmail.com"]
|
7
|
+
gem.summary = %q{Send rails exceptions to HipChat}
|
8
|
+
gem.homepage = "http://github.com/darrinholst/exceptions_to_hipchat"
|
9
|
+
|
10
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
gem.name = "exceptions_to_hipchat"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = ExceptionsToHipchat::VERSION
|
16
|
+
|
17
|
+
gem.add_dependency("hipchat", "~> 0.4.1")
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'hipchat'
|
2
|
+
|
3
|
+
module ExceptionsToHipchat
|
4
|
+
class Notifier
|
5
|
+
def initialize(app, options = {})
|
6
|
+
@app = app
|
7
|
+
@client = HipChat::Client.new(options[:api_token] || raise("HipChat API token is required"))
|
8
|
+
@room = options[:room] || raise("HipChat room is required")
|
9
|
+
@color = options[:color] || :red
|
10
|
+
@notify = options[:notify]
|
11
|
+
@user = (options[:user] || "Notifier")[0..15]
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
@app.call(env)
|
16
|
+
rescue Exception => exception
|
17
|
+
send_to_hipchat exception
|
18
|
+
raise exception
|
19
|
+
end
|
20
|
+
|
21
|
+
def send_to_hipchat(exception)
|
22
|
+
begin
|
23
|
+
@client[@room].send(@user, message_for(exception), :color => @color, :notify => @notify)
|
24
|
+
rescue => hipchat_exception
|
25
|
+
$stderr.puts "\nWARN: Unable to send message to HipChat: #{hipchat_exception}\n"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def message_for(exception)
|
30
|
+
"[#{exception.class}] #{exception}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exceptions_to_hipchat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Darrin Holst
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hipchat
|
16
|
+
requirement: &70303600310880 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.4.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70303600310880
|
25
|
+
description:
|
26
|
+
email:
|
27
|
+
- darrinholst@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- exceptions_to_hipchat.gemspec
|
38
|
+
- lib/exceptions_to_hipchat.rb
|
39
|
+
- lib/exceptions_to_hipchat/notifier.rb
|
40
|
+
- lib/exceptions_to_hipchat/version.rb
|
41
|
+
homepage: http://github.com/darrinholst/exceptions_to_hipchat
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
hash: -3902427524639276860
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
hash: -3902427524639276860
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.16
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Send rails exceptions to HipChat
|
71
|
+
test_files: []
|