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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fae7b84a0557b3adfc1a873e2e7180c371d68a91
4
- data.tar.gz: 8b9b5a2596aa20b51aae08d909109b77a5595804
3
+ metadata.gz: 810f5c37accd02145848b8d6f1e5cbef69095f04
4
+ data.tar.gz: 3aab9b26d73df2d1c5077b17b82a13fe28a6257a
5
5
  SHA512:
6
- metadata.gz: 0970b1be8f09618c6ff6637f5015f426d7030fb973dd7034833f8f86bd90d3f8d70edd3056637ac6358a569dfb0e53094812d1731f9ad6b5c5b187c14e1d1ecb
7
- data.tar.gz: 3b1e6a0dda0ba62be52fec40150ebd19cd6e22564ade41eb20e639b5cd49b13b8edc99004fbf86c777ed04cb586de1685230b188361688b4e357923b43e0b61d
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
- `config/environments/development.rb`
27
+ config/environments/development.rb
26
28
  ```
27
- config.middleware.use Rack::ErrorToSlack
29
+ config.middleware.insert_before ActionDispatch::RemoteIp, Rack::ErrorToSlack
28
30
  ```
29
31
 
30
32
  #### Step2
31
- `config/initializers/error_to_slack.rb`
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)
Binary file
@@ -13,7 +13,7 @@ module Rack
13
13
  begin
14
14
  response = @app.call(env)
15
15
  rescue Exception => exception
16
- Message.new(env, exception.message).send
16
+ Message.new(env, exception.message, $@.first).send
17
17
  raise exception
18
18
  end
19
19
  response
@@ -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 while " \
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
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class ErrorToSlack
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  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.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: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler