rack-error_to_slack 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -3
- data/doc/sample.png +0 -0
- data/lib/rack/error_to_slack.rb +1 -1
- data/lib/rack/error_to_slack/message.rb +9 -4
- data/lib/rack/error_to_slack/version.rb +1 -1
- 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: 810f5c37accd02145848b8d6f1e5cbef69095f04
|
4
|
+
data.tar.gz: 3aab9b26d73df2d1c5077b17b82a13fe28a6257a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60588c8efc4663ee3eba0aba90a43f19ab4a21309b5271557fdf70e64ab1aae5cd8290b5e9cb7632d5b6f34f65fc1d8de590d91854f0c0d7bba295fb6105f716
|
7
|
+
data.tar.gz: b055bf06e447d0ff1339e29c09af3b873d03d204c7d55cff7c895276de88f77fda68997e6983cf1b430ca828cdff6aad2100806da0126d8681fd18cc3ff987f1
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Rack::ErrorToSlack
|
2
2
|
This is a rack middleware that post error to slack.
|
3
|
+
Strongly recommended to use **only Development environment**.
|
3
4
|
EXAMPLE: ![](https://github.com/showwin/rack-error_to_slack/blob/master/doc/sample.png)
|
4
5
|
|
6
|
+
Inspired by [hitode909/Plack-Middleware-PostErrorToSlack](https://github.com/hitode909/Plack-Middleware-PostErrorToSlack)
|
5
7
|
|
6
8
|
## Installation
|
7
9
|
|
@@ -22,13 +24,13 @@ Or install it yourself as:
|
|
22
24
|
## Usage
|
23
25
|
### for Rails 4.x
|
24
26
|
#### Step1
|
25
|
-
|
27
|
+
config/environments/development.rb
|
26
28
|
```
|
27
|
-
config.middleware.
|
29
|
+
config.middleware.insert_before ActionDispatch::RemoteIp, Rack::ErrorToSlack
|
28
30
|
```
|
29
31
|
|
30
32
|
#### Step2
|
31
|
-
|
33
|
+
config/initializers/error_to_slack.rb
|
32
34
|
```
|
33
35
|
Rack::ErrorToSlack.configure do |config|
|
34
36
|
config.webhook_url = 'https://hooks.slack.com/services/your_webhook_url'
|
@@ -42,5 +44,26 @@ Rack::ErrorToSlack.configure do |config|
|
|
42
44
|
end
|
43
45
|
```
|
44
46
|
|
47
|
+
## :warning: WARNING :warning:
|
48
|
+
This gem is recommended to use **only Development environment**.
|
49
|
+
Your application cannot respond to users until `rack-error_to_message` succeeds to post error message to Slack.
|
50
|
+
|
51
|
+
|
52
|
+
Following settings are recommended.
|
53
|
+
|
54
|
+
Gemfile
|
55
|
+
```
|
56
|
+
gem 'rack-error_to_slack', group: :development
|
57
|
+
```
|
58
|
+
|
59
|
+
config/initializers/error_to_slack.rb
|
60
|
+
```
|
61
|
+
if Rails.env == "development"
|
62
|
+
Rack::ErrorToSlack.configure do |config|
|
63
|
+
config.webhook_url = 'https://hooks.slack.com/services/your_webhook_url'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
45
68
|
## LICENSE
|
46
69
|
[MIT](https://github.com/showwin/rack-error_to_slack/blob/master/LICENSE)
|
data/doc/sample.png
CHANGED
Binary file
|
data/lib/rack/error_to_slack.rb
CHANGED
@@ -6,12 +6,13 @@ module Rack
|
|
6
6
|
class ErrorToSlack
|
7
7
|
# Message Class
|
8
8
|
class Message
|
9
|
-
def initialize(env, err_msg)
|
9
|
+
def initialize(env, err_msg, err_location)
|
10
10
|
@data = {
|
11
|
-
'text': "#{username} encountered an error
|
12
|
-
"`#{env['REQUEST_METHOD']} #{env['PATH_INFO']}` " \
|
11
|
+
'text': "#{username} encountered an error " \
|
12
|
+
"while `#{env['REQUEST_METHOD']} #{env['PATH_INFO']}` " \
|
13
13
|
"on branch `#{branch}`\n" \
|
14
|
-
"```#{err_msg}
|
14
|
+
"```#{err_msg}```\n" \
|
15
|
+
"`#{err_location.gsub(/^#{root_path}/, '').tr('`', "'")}`",
|
15
16
|
'username': slackname,
|
16
17
|
'icon_emoji': emoji
|
17
18
|
}
|
@@ -24,6 +25,10 @@ module Rack
|
|
24
25
|
|
25
26
|
private
|
26
27
|
|
28
|
+
def root_path
|
29
|
+
Rails.root.to_s || ''
|
30
|
+
end
|
31
|
+
|
27
32
|
def username
|
28
33
|
ErrorToSlack.configuration.username
|
29
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-error_to_slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- showwin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|