exceptions_to_slack 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 18cbcfb3bda1a6a6032b8eed4782a3b5a321c1a7
4
+ data.tar.gz: eb275434209fe2a26010e8b97d5f6776295cd951
5
+ SHA512:
6
+ metadata.gz: e4bd13f1154dcf3c13365f81fe56c1b9419244f465224fd50c74f9125c7d12b17cd008ae2ddfac21d1cc8826d815d9584901cd87d866c40bc464052a3cd23393
7
+ data.tar.gz: 11465da40b9527a066b9853493d069fbd7e4651e1f44e5dc7ec09e58ba4f71bc3f9a7b459df8242404ae5342fc204e0c6df7bab5e080597ca4b8e166d18cd67d
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rake"
4
+
5
+ # Specify your gem's dependencies in exceptions_to_slack.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 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
+ # ExceptionsToSlack
2
+
3
+ Sends exceptions to Slack
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'exceptions_to_slack'
10
+
11
+ ## Usage
12
+
13
+ Rails 3: add as rack middleware to `application.rb'
14
+
15
+ config.middleware.use ExceptionsToSlack::Notifier,
16
+ :team => "YOUR TEAM",
17
+ :token => "YOUR TOKEN",
18
+ :channel => "YOUR CHANNEL",
19
+ :user => "USER MESSAGE WILL COME FROM"
20
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/exceptions_to_slack/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 Slack}
8
+ gem.homepage = "http://github.com/darrinholst/exceptions_to_slack"
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_slack"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = ExceptionsToSlack::VERSION
16
+
17
+ gem.add_dependency("slack-notifier", "~> 0.5.0")
18
+ gem.add_development_dependency("rspec", "~> 2.14.1")
19
+ end
@@ -0,0 +1,43 @@
1
+ require 'slack-notifier'
2
+
3
+ module ExceptionsToSlack
4
+ class Notifier
5
+ def initialize(app, options = {})
6
+ @app = app
7
+ @notifier = Slack::Notifier.new(team(options), token(options))
8
+ @notifier.channel = options[:channel] || raise("Channel is required")
9
+ @notifier.username = options[:user] || "Notifier"
10
+ @ignore = options[:ignore]
11
+ end
12
+
13
+ def call(env)
14
+ @app.call(env)
15
+ rescue Exception => exception
16
+ send_to_slack(exception) unless @ignore && @ignore.match(exception.to_s)
17
+ raise exception
18
+ end
19
+
20
+ def send_to_slack(exception)
21
+ begin
22
+ @notifier.ping message_for(exception)
23
+ rescue => slack_exception
24
+ $stderr.puts "\nWARN: Unable to send message to Slack: #{slack_exception}\n"
25
+ end
26
+ end
27
+
28
+ def message_for(exception)
29
+ "[#{exception.class}] #{exception}"
30
+ end
31
+
32
+ private
33
+
34
+ def team(options)
35
+ options[:team] || raise("Team name is required")
36
+ end
37
+
38
+ def token(options)
39
+ options[:token] || raise("Token is required")
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,3 @@
1
+ module ExceptionsToSlack
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ require "exceptions_to_slack/version"
2
+ require "exceptions_to_slack/notifier"
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exceptions_to_slack
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Darrin Holst
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: slack-notifier
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.0
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
41
+ description:
42
+ email:
43
+ - darrinholst@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - exceptions_to_slack.gemspec
54
+ - lib/exceptions_to_slack.rb
55
+ - lib/exceptions_to_slack/notifier.rb
56
+ - lib/exceptions_to_slack/version.rb
57
+ homepage: http://github.com/darrinholst/exceptions_to_slack
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Send rails exceptions to Slack
80
+ test_files: []