exception_notification-slacky 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c64243d1375857814fd33a6d043a62d7090f087
4
- data.tar.gz: d07ff1574b2cee9526fa9e288d4f83ac38bb5f1f
3
+ metadata.gz: 17159e3bc74692a2ac72c58c71ba6972c91313ce
4
+ data.tar.gz: 14568b0f398ea7dde045ffc6cfc2a6235cc2071f
5
5
  SHA512:
6
- metadata.gz: 74ae0a0721bb92154a84dc368f001f2015533bc547e998c3f416122f9c19cedd0c18af9b1e64246e86770a38d2f56b7f410095e3f87f6cf5ea483722c959661d
7
- data.tar.gz: 25d112e40b4e5eb67f2dbf553bb56b689181a9cdf252d158bf439a1239b36312c1d6621c87a6b7a6d3ce28b01ef00686d6170649a08dbdb50a12b475dea8df6c
6
+ metadata.gz: 746163bf6d4776381fff1d50778584e955d1a17dda74ea118450681c1a8bd60d1f14f70b1718291231d4a28c023aa5e2fc064904ce995c4afa80afddaf6fd88c
7
+ data.tar.gz: ba9b5db8f03ab82a6c330a7c012dfb2b20a51b434b59e68a4fe2c47d6a06533697f24f051737ca4faff0ebedac000f587396ddd62cbfffddd627d9fd28acfe33
data/README.md CHANGED
@@ -36,9 +36,17 @@ add below lines to config/initializers/exception_notification.rb.
36
36
  channel: 'channel you want to being notified to',
37
37
  username: 'slacky',
38
38
  color: :danger, # optional, default to :danger
39
- addtional_parameters: {
39
+ additional_parameters: {
40
40
  icon_emoji: ':warning:'
41
- }
41
+ },
42
+ custom_fields: [
43
+ {
44
+ title: 'User Agent',
45
+ value: ->(req) { req.user_agent },
46
+ short: false,
47
+ after: 'IP Address'
48
+ }
49
+ ]
42
50
  }
43
51
  ```
44
52
 
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "exception_notification-slacky"
8
8
  spec.version = ExceptionNotification::Slacky::VERSION
9
9
  spec.licenses = ['MIT']
10
- spec.authors = ["森井ゴンザレス"]
11
- spec.email = ["morygonzalez@gmail.com"]
10
+ spec.authors = ["森井ゴンザレス", "Ryutaro Mizokami"]
11
+ spec.email = ["morygonzalez@gmail.com", "r.mizokami@gmail.com"]
12
12
 
13
13
  spec.summary = %q{Send Exception notification to slack}
14
14
  spec.description = %q{Send Exception notification to slack. Works as ExceptionNotification Plugin.}
@@ -1,5 +1,5 @@
1
1
  module ExceptionNotification
2
2
  module Slacky
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -7,6 +7,7 @@ module ExceptionNotifier
7
7
  webhook_url = options.fetch(:webhook_url)
8
8
  @color = options.fetch(:color, :danger)
9
9
  @message_opts = options.fetch(:additional_parameters, {})
10
+ @custom_fields = options.fetch(:custom_fields, [])
10
11
  @notifier = Slack::Notifier.new(webhook_url, options)
11
12
  rescue
12
13
  @notifier = nil
@@ -40,39 +41,56 @@ module ExceptionNotifier
40
41
  fallback: "#{exception.class} #{exception.message}",
41
42
  color: @color.to_s,
42
43
  title: "[ERROR] #{exception.class}",
43
- fields: [
44
- {
45
- title: "Host",
46
- value: (Socket.gethostname rescue nil),
47
- short: true
48
- },
49
- {
50
- title: "Request path",
51
- value: @request.path_info,
52
- short: true
53
- },
54
- {
55
- title: "HTTP Method",
56
- value: @request.request_method,
57
- short: true
58
- },
59
- {
60
- title: "IP Address",
61
- value: @request.ip,
62
- short: true
63
- },
64
- {
65
- title: "Occurred on",
66
- value: (exception.backtrace.first rescue nil),
67
- short: false
68
- },
69
- {
70
- title: "Error message",
71
- value: exception.message,
72
- short: false
73
- }
74
- ]
44
+ fields: build_fields(exception)
75
45
  }
76
46
  end
47
+
48
+ def build_fields(exception)
49
+ fields = [
50
+ {
51
+ title: "Host",
52
+ value: (Socket.gethostname rescue nil),
53
+ short: true
54
+ },
55
+ {
56
+ title: "Request path",
57
+ value: @request.path_info,
58
+ short: true
59
+ },
60
+ {
61
+ title: "HTTP Method",
62
+ value: @request.request_method,
63
+ short: true
64
+ },
65
+ {
66
+ title: "IP Address",
67
+ value: @request.ip,
68
+ short: true
69
+ },
70
+ {
71
+ title: "Occurred on",
72
+ value: (exception.backtrace.first rescue nil),
73
+ short: false
74
+ },
75
+ {
76
+ title: "Error message",
77
+ value: exception.message,
78
+ short: false
79
+ }
80
+ ]
81
+
82
+ @custom_fields.each do |custom_field|
83
+ field = {
84
+ title: custom_field[:title],
85
+ value: custom_field[:value].call(@request),
86
+ short: custom_field[:short]
87
+ }
88
+ i = fields.index {|f| f[:title] == custom_field[:after]}
89
+ i = i ? i.succ : -1
90
+ fields.insert(i, field)
91
+ end
92
+
93
+ fields
94
+ end
77
95
  end
78
96
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification-slacky
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
  - "森井ゴンザレス"
8
+ - Ryutaro Mizokami
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
12
+ date: 2015-12-13 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: exception_notification
@@ -112,6 +113,7 @@ description: Send Exception notification to slack. Works as ExceptionNotificatio
112
113
  Plugin.
113
114
  email:
114
115
  - morygonzalez@gmail.com
116
+ - r.mizokami@gmail.com
115
117
  executables: []
116
118
  extensions: []
117
119
  extra_rdoc_files: []
@@ -149,8 +151,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
151
  version: '0'
150
152
  requirements: []
151
153
  rubyforge_project:
152
- rubygems_version: 2.2.2
154
+ rubygems_version: 2.5.1
153
155
  signing_key:
154
156
  specification_version: 4
155
157
  summary: Send Exception notification to slack
156
158
  test_files: []
159
+ has_rdoc: