exception_notification-slacky 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exception_notification-slacky.gemspec +30 -0
- data/lib/exception_notification/slacky.rb +4 -0
- data/lib/exception_notification/slacky/version.rb +5 -0
- data/lib/exception_notifier/slacky_notifier.rb +77 -0
- data/wercker.yml +8 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48880a6050b285b00eb2e4a69cc8df0a04192d41
|
4
|
+
data.tar.gz: 475b71e1b5c75d15438fd2cc83fdd5f7bac4b622
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ad81a5e23fadb1efdf640d10da9a0e8db8bda64a24b5968c50bced7ca9712a63ef5491114e5ae683a42b75d0de3f9d61779fb47d7a3765628846a4fbfd94b75
|
7
|
+
data.tar.gz: 038f42a6dd3b24b9cf8fcf4984c91478d4bdf888f2e47818c54511e7242d99985e6c58aa9519021fc4139f7ef1af05d278a25b7fae8d82483b5f7c877c14b093
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# ExceptionNotification::Slacky
|
2
|
+
|
3
|
+
[](https://app.wercker.com/project/bykey/f4a6b632836b07c473e73edeeaa54808)
|
4
|
+
|
5
|
+
Rich informed exception_notifier for slack.
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'exception_notification-slacky'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install exception_notification-slacky
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Work as custom notifier for exception_notification.
|
28
|
+
|
29
|
+
### Example usage with Rails
|
30
|
+
|
31
|
+
add below lines to config/initializers/exception_notification.rb.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
config.add_notifier :slacky, {
|
35
|
+
webhook_url: 'your slack incoming webhook url',
|
36
|
+
channel: 'channel you want to being notified to',
|
37
|
+
username: 'slacky',
|
38
|
+
addtional_parameters: {
|
39
|
+
icon_emoji: ':warning:'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/morygonzalez/exception_notification-slacky/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "exception_notification/slacky"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'exception_notification/slacky/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "exception_notification-slacky"
|
8
|
+
spec.version = ExceptionNotification::Slacky::VERSION
|
9
|
+
spec.licenses = ['MIT']
|
10
|
+
spec.authors = ["森井ゴンザレス"]
|
11
|
+
spec.email = ["morygonzalez@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Send Exception notification to slack}
|
14
|
+
spec.description = %q{Send Exception notification to slack. Works as ExceptionNotification Plugin.}
|
15
|
+
spec.homepage = "https://github.com/morygonzalez/exception_notification-slacky"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'exception_notification', '~> 4.0'
|
23
|
+
spec.add_runtime_dependency 'slack-notifier', '~> 1.1'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rack', '~> 1.6'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'webmock', '~> 1.21'
|
30
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module ExceptionNotifier
|
2
|
+
class SlackyNotifier
|
3
|
+
attr_reader :notifier
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
begin
|
7
|
+
webhook_url = options.fetch(:webhook_url)
|
8
|
+
@message_opts = options.fetch(:additional_parameters, {})
|
9
|
+
@notifier = Slack::Notifier.new(webhook_url, options)
|
10
|
+
rescue
|
11
|
+
@notifier = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(exception, options={})
|
16
|
+
env = options[:env] || {}
|
17
|
+
@request ||= if defined?(ActionDispatch::Request)
|
18
|
+
ActionDispatch::Request.new(env)
|
19
|
+
else
|
20
|
+
require 'rack/request'
|
21
|
+
Rack::Request.new(env)
|
22
|
+
end
|
23
|
+
message = 'Exception Occured!'
|
24
|
+
attachments = build_attachemnt(exception, options)
|
25
|
+
@message_opts.merge!(attachments: [attachments])
|
26
|
+
@notifier.ping(message, @message_opts) if valid?
|
27
|
+
rescue LoadError, NameError
|
28
|
+
raise "Please use this notifier in some kind of Rack-based webapp"
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def valid?
|
34
|
+
!@notifier.nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_attachemnt(exception, options = {})
|
38
|
+
{
|
39
|
+
fallback: "#{exception.class} #{exception.message}",
|
40
|
+
color: "danger",
|
41
|
+
title: "[ERROR] #{exception.class}",
|
42
|
+
fields: [
|
43
|
+
{
|
44
|
+
title: "Host",
|
45
|
+
value: (Socket.gethostname rescue nil),
|
46
|
+
short: true
|
47
|
+
},
|
48
|
+
{
|
49
|
+
title: "Request path",
|
50
|
+
value: @request.path_info,
|
51
|
+
short: true
|
52
|
+
},
|
53
|
+
{
|
54
|
+
title: "HTTP Method",
|
55
|
+
value: @request.request_method,
|
56
|
+
short: true
|
57
|
+
},
|
58
|
+
{
|
59
|
+
title: "IP Address",
|
60
|
+
value: @request.ip,
|
61
|
+
short: true
|
62
|
+
},
|
63
|
+
{
|
64
|
+
title: "Occurred on",
|
65
|
+
value: (exception.backtrace.first rescue nil),
|
66
|
+
short: false
|
67
|
+
},
|
68
|
+
{
|
69
|
+
title: "Error message",
|
70
|
+
value: exception.message,
|
71
|
+
short: false
|
72
|
+
}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/wercker.yml
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exception_notification-slacky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "森井ゴンザレス"
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: exception_notification
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slack-notifier
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.21'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.21'
|
111
|
+
description: Send Exception notification to slack. Works as ExceptionNotification
|
112
|
+
Plugin.
|
113
|
+
email:
|
114
|
+
- morygonzalez@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- exception_notification-slacky.gemspec
|
128
|
+
- lib/exception_notification/slacky.rb
|
129
|
+
- lib/exception_notification/slacky/version.rb
|
130
|
+
- lib/exception_notifier/slacky_notifier.rb
|
131
|
+
- wercker.yml
|
132
|
+
homepage: https://github.com/morygonzalez/exception_notification-slacky
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.2.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Send Exception notification to slack
|
156
|
+
test_files: []
|
157
|
+
has_rdoc:
|