uniform_notifier 1.12.0 → 1.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f27b211c1e550787b74d7a57a1f534fda78a5271
4
- data.tar.gz: 052c8e0d80a431a89c71d5578c0603fd5609686f
2
+ SHA256:
3
+ metadata.gz: 2e0dc90eb392f340e5bcb87c74e7f5ff5abdfe056c2f9a477349ed21806c981c
4
+ data.tar.gz: da95631ac719cf684e878f377cd93ab1678ed6d5d18ba63c22b3f04d77224386
5
5
  SHA512:
6
- metadata.gz: 925e6cf2f2dfc20a84fef57e1bee9872d5ddb18396142b63e335f9db5fe275650a3def097a6a2688e7411ffe2dd980be1313b5271e577514193f9faf0f2f071b
7
- data.tar.gz: 2056c09e18698a84e87f4c8029fea3c73643c7ded92af0f30a40c79edb58b02721a88517012183ebf76f1f6f829150307e3e594151c234fb9e2a438b1feb9eab
6
+ metadata.gz: 73a4d1e31f1604646b28f703ab865b6644413e42d41096c5e983d7fbbb0ae8a6ea1b2d14c88ffea7c15007d431aebedefd948d4365e265a3f074efd166ccc3a6
7
+ data.tar.gz: '08c69d23ee80f460409ab2edd5949a7beff96799afc5aa5ea8adb89536969fb9c1defa096ac24a652551280ff0b1a8b86c85ddde5443c7ade8f04c459ee42a30'
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.3.6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Next Release
2
2
 
3
+ # 1.14.0 (02/26/2021)
4
+
5
+ * Add AppSignal integration
6
+ * Fix UniformNotifier::Raise.active? when .rails= receives a false value
7
+
8
+ ## 1.13.0 (10/05/2019)
9
+
10
+ * Add Honeybadger class dependecy injection.
11
+ * Allow configuration of Rollbar level.
12
+
13
+ ## 1.12.1 (10/30/2018)
14
+
15
+ * Require Ruby 2.3+
16
+
3
17
  ## 1.12.0 (08/17/2018)
4
18
 
5
19
  * Add [terminal-notifier](https://github.com/julienXX/terminal-notifier) support
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # UniformNotifier
2
2
 
3
3
  [![Build
4
- Status](https://secure.travis-ci.org/flyerhzm/uniform_notifier.png)](http://travis-ci.org/flyerhzm/uniform_notifier)
5
- [![AwesomeCode Status for flyerhzm/uniform_notifier](https://awesomecode.io/projects/3e29a7de-0b37-4ecf-b06d-410ebf815174/status)](https://awesomecode.io/projects/32)
4
+ Status](https://secure.travis-ci.org/flyerhzm/uniform_notifier.svg)](http://travis-ci.org/flyerhzm/uniform_notifier)
5
+ [![AwesomeCode Status for flyerhzm/uniform_notifier](https://awesomecode.io/projects/3e29a7de-0b37-4ecf-b06d-410ebf815174/status)](https://awesomecode.io/repos/flyerhzm/uniform_notifier)
6
6
 
7
- uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp, airbrake and honeybadger.
7
+ uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp, airbrake, honeybadger and AppSignal.
8
8
 
9
9
  ## Install
10
10
 
@@ -40,6 +40,10 @@ if you want to notify by bugsnag, you should install bugsnag first
40
40
 
41
41
  gem install bugsnag
42
42
 
43
+ if you want to notify by AppSignal, you should install AppSignal first
44
+
45
+ gem install appsignal
46
+
43
47
  if you want to notify by slack, you should install slack-notifier first
44
48
 
45
49
  gem install slack-notifier
@@ -62,89 +66,100 @@ the other is <code>out_of_channel_notify</code>, for rails logger, customized lo
62
66
 
63
67
  By default, all notifiers are disabled, you should enable them first.
64
68
 
65
- # javascript alert
66
- UniformNotifier.alert = true
67
- # javascript alert with options
68
- # the attributes key adds custom attributes to the script tag appended to the body
69
- UniformNotifier.alert = { :attributes => { :nonce => 'mySecret-nonce', 'data-key' => 'value' } }
70
-
71
- # javascript console (Safari/Webkit browsers or Firefox w/Firebug installed)
72
- UniformNotifier.console = true
73
- # javascript console with options
74
- # the attributes key adds custom attributes to the script tag appended to the body
75
- UniformNotifier.console = { :attributes => { :nonce => 'mySecret-nonce', 'data-key' => 'value' } }
76
-
77
- # rails logger
78
- UniformNotifier.rails_logger = true
79
-
80
- # airbrake
81
- UniformNotifier.airbrake = true
82
- # airbrake with options
83
- UniformNotifier.airbrake = { :error_class => Exception }
84
-
85
- # Honeybadger
86
- #
87
- # Reporting live data from development is disabled by default. Ensure
88
- # that the `report_data` option is enabled via configuration.
89
- UniformNotifier.honeybadger = true
90
- # Honeybadger with options
91
- UniformNotifier.honeybadger = { :error_class => 'Exception' }
92
-
93
- # rollbar
94
- UniformNotifier.rollbar = true
95
-
96
- # bugsnag
97
- UniformNotifier.bugsnag = true
98
- # bugsnag with options
99
- UniformNotifier.bugsnag = { :api_key => 'something' }
100
-
101
- # slack
102
- UniformNotifier.slack = true
103
- # slack with options
104
- UniformNotifier.slack = { :webhook_url => 'http://some.slack.url', :channel => '#default', :username => 'notifier' }
105
-
106
- # customized logger
107
- logger = File.open('notify.log', 'a+')
108
- logger.sync = true
109
- UniformNotifier.customized_logger = logger
110
-
111
- # growl without password
112
- UniformNotifier.growl = true
113
- # growl with passowrd
114
- UniformNotifier.growl = { :password => 'growl password' }
115
-
116
- # xmpp
117
- UniformNotifier.xmpp = { :account => 'sender_account@jabber.org',
118
- :password => 'password_for_jabber',
119
- :receiver => 'recipient_account@jabber.org',
120
- :show_online_status => true }
121
-
122
- # terminal-notifier
123
- UniformNotifier.terminal_notifier = true
124
-
125
- # raise an error
126
- UniformNotifier.raise = true # raise a generic exception
127
-
128
- class MyExceptionClass < Exception; end
129
- UniformNotifier.raise = MyExceptionClass # raise a custom exception type
130
-
131
- UniformNotifier.raise = false # don't raise errors
69
+ ```ruby
70
+ # javascript alert
71
+ UniformNotifier.alert = true
72
+ # javascript alert with options
73
+ # the attributes key adds custom attributes to the script tag appended to the body
74
+ UniformNotifier.alert = { :attributes => { :nonce => 'mySecret-nonce', 'data-key' => 'value' } }
75
+
76
+ # javascript console (Safari/Webkit browsers or Firefox w/Firebug installed)
77
+ UniformNotifier.console = true
78
+ # javascript console with options
79
+ # the attributes key adds custom attributes to the script tag appended to the body
80
+ UniformNotifier.console = { :attributes => { :nonce => 'mySecret-nonce', 'data-key' => 'value' } }
81
+
82
+ # rails logger
83
+ UniformNotifier.rails_logger = true
84
+
85
+ # airbrake
86
+ UniformNotifier.airbrake = true
87
+ # airbrake with options
88
+ UniformNotifier.airbrake = { :error_class => Exception }
89
+
90
+ # AppSignal
91
+ UniformNotifier.appsignal = true
92
+ # AppSignal with options
93
+ UniformNotifier.appsignal = { :namespace => "Background", :tags => { :hostname => "frontend1" } }
94
+
95
+ # Honeybadger
96
+ #
97
+ # Reporting live data from development is disabled by default. Ensure
98
+ # that the `report_data` option is enabled via configuration.
99
+ UniformNotifier.honeybadger = true
100
+ # Honeybadger with options
101
+ UniformNotifier.honeybadger = { :error_class => 'Exception' }
102
+
103
+ # rollbar
104
+ UniformNotifier.rollbar = true
105
+ # rollbar with options (level can be 'debug', 'info', 'warning', 'error' or 'critical')
106
+ UniformNotifier.rollbar = { :level => 'warning' }
107
+
108
+ # bugsnag
109
+ UniformNotifier.bugsnag = true
110
+ # bugsnag with options
111
+ UniformNotifier.bugsnag = { :api_key => 'something' }
112
+
113
+ # slack
114
+ UniformNotifier.slack = true
115
+ # slack with options
116
+ UniformNotifier.slack = { :webhook_url => 'http://some.slack.url', :channel => '#default', :username => 'notifier' }
117
+
118
+ # customized logger
119
+ logger = File.open('notify.log', 'a+')
120
+ logger.sync = true
121
+ UniformNotifier.customized_logger = logger
122
+
123
+ # growl without password
124
+ UniformNotifier.growl = true
125
+ # growl with passowrd
126
+ UniformNotifier.growl = { :password => 'growl password' }
127
+
128
+ # xmpp
129
+ UniformNotifier.xmpp = { :account => 'sender_account@jabber.org',
130
+ :password => 'password_for_jabber',
131
+ :receiver => 'recipient_account@jabber.org',
132
+ :show_online_status => true }
133
+
134
+ # terminal-notifier
135
+ UniformNotifier.terminal_notifier = true
136
+
137
+ # raise an error
138
+ UniformNotifier.raise = true # raise a generic exception
139
+
140
+ class MyExceptionClass < Exception; end
141
+ UniformNotifier.raise = MyExceptionClass # raise a custom exception type
142
+
143
+ UniformNotifier.raise = false # don't raise errors
144
+ ```
132
145
 
133
146
  After that, you can enjoy the notifiers, that's cool!
134
147
 
135
- # the notify message will be notified to rails logger, customized logger, growl or xmpp.
136
- UniformNotifier.active_notifiers.each do |notifier|
137
- notifier.out_of_channel_notify("customize message")
138
- end
139
-
140
- # the notify message will be wrapped by <script type="text/javascript">...</script>,
141
- # you should append the javascript_str at the bottom of http response body.
142
- # for more information, please check https://github.com/flyerhzm/bullet/blob/master/lib/bullet/rack.rb
143
- responses = []
144
- UniformNotifier.active_notifiers.each do |notifier|
145
- responses << notifier.inline_notify("customize message")
146
- end
147
- javascript_str = responses.join("\n")
148
+ ```ruby
149
+ # the notify message will be notified to rails logger, customized logger, growl or xmpp.
150
+ UniformNotifier.active_notifiers.each do |notifier|
151
+ notifier.out_of_channel_notify("customize message")
152
+ end
153
+
154
+ # the notify message will be wrapped by <script type="text/javascript">...</script>,
155
+ # you should append the javascript_str at the bottom of http response body.
156
+ # for more information, please check https://github.com/flyerhzm/bullet/blob/master/lib/bullet/rack.rb
157
+ responses = []
158
+ UniformNotifier.active_notifiers.each do |notifier|
159
+ responses << notifier.inline_notify("customize message")
160
+ end
161
+ javascript_str = responses.join("\n")
162
+ ```
148
163
 
149
164
  ## Growl Support
150
165
 
@@ -158,10 +173,6 @@ To get Growl support up-and-running, follow the steps below:
158
173
  * Restart Growl ("General" tab -> Stop Growl -> Start Growl)
159
174
  * Boot up your application. UniformNotifier will automatically send a Growl notification when Growl is turned on. If you do not see it when your application loads, make sure it is enabled in your initializer and double-check the steps above.
160
175
 
161
- ### Ruby 1.9 issue
162
-
163
- ruby-growl gem has an issue about md5 in ruby 1.9, if you use growl and ruby 1.9, check this [gist][1]
164
-
165
176
  ## XMPP/Jabber Support
166
177
 
167
178
  To get XMPP support up-and-running, follow the steps below:
@@ -174,4 +185,3 @@ To get XMPP support up-and-running, follow the steps below:
174
185
 
175
186
 
176
187
  [0]: https://github.com/flyerhzm/bullet
177
- [1]: https://gist.github.com/300184
@@ -13,22 +13,51 @@ require 'uniform_notifier/airbrake'
13
13
  require 'uniform_notifier/sentry'
14
14
  require 'uniform_notifier/rollbar'
15
15
  require 'uniform_notifier/bugsnag'
16
+ require 'uniform_notifier/appsignal'
16
17
  require 'uniform_notifier/slack'
17
18
  require 'uniform_notifier/raise'
18
19
  require 'uniform_notifier/terminal_notifier'
19
20
 
20
21
  class UniformNotifier
21
- AVAILABLE_NOTIFIERS = %i[alert console growl honeybadger xmpp rails_logger
22
- customized_logger airbrake rollbar bugsnag slack raise
23
- sentry terminal_notifier].freeze
22
+ AVAILABLE_NOTIFIERS = %i[
23
+ alert
24
+ console
25
+ growl
26
+ honeybadger
27
+ xmpp
28
+ rails_logger
29
+ customized_logger
30
+ airbrake
31
+ rollbar
32
+ bugsnag
33
+ slack
34
+ raise
35
+ sentry
36
+ appsignal
37
+ terminal_notifier
38
+ ].freeze
24
39
 
25
- NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, HoneybadgerNotifier, Xmpp, RailsLogger,
26
- CustomizedLogger, AirbrakeNotifier, RollbarNotifier, BugsnagNotifier, Raise, Slack,
27
- SentryNotifier, TerminalNotifier].freeze
40
+ NOTIFIERS = [
41
+ JavascriptAlert,
42
+ JavascriptConsole,
43
+ Growl,
44
+ HoneybadgerNotifier,
45
+ Xmpp,
46
+ RailsLogger,
47
+ CustomizedLogger,
48
+ AirbrakeNotifier,
49
+ RollbarNotifier,
50
+ BugsnagNotifier,
51
+ Raise,
52
+ Slack,
53
+ SentryNotifier,
54
+ AppsignalNotifier,
55
+ TerminalNotifier
56
+ ].freeze
28
57
 
29
58
  class NotificationError < StandardError; end
30
59
 
31
- class <<self
60
+ class << self
32
61
  attr_accessor(*AVAILABLE_NOTIFIERS)
33
62
 
34
63
  def active_notifiers
@@ -12,9 +12,7 @@ class UniformNotifier
12
12
  message = data.values.compact.join("\n")
13
13
 
14
14
  opt = {}
15
- if UniformNotifier.airbrake.is_a?(Hash)
16
- opt = UniformNotifier.airbrake
17
- end
15
+ opt = UniformNotifier.airbrake if UniformNotifier.airbrake.is_a?(Hash)
18
16
 
19
17
  exception = Exception.new(message)
20
18
  Airbrake.notify(exception, opt)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UniformNotifier
4
+ class AppsignalNotifier < Base
5
+ def self.active?
6
+ !!UniformNotifier.appsignal
7
+ end
8
+
9
+ protected
10
+
11
+ def self._out_of_channel_notify(data)
12
+ opt = UniformNotifier.appsignal.is_a?(Hash) ? UniformNotifier.appsignal : {}
13
+
14
+ exception = Exception.new(data[:title])
15
+ exception.set_backtrace(data[:backtrace]) if data[:backtrace]
16
+
17
+ tags = opt.fetch(:tags, {}).merge(data.fetch(:tags, {}))
18
+ namespace = data[:namespace] || opt[:namespace]
19
+
20
+ Appsignal.send_error(*[exception, tags, namespace].compact)
21
+ end
22
+ end
23
+ end
@@ -10,16 +10,11 @@ class UniformNotifier
10
10
 
11
11
  def self._out_of_channel_notify(data)
12
12
  opt = {}
13
- if UniformNotifier.bugsnag.is_a?(Hash)
14
- opt = UniformNotifier.bugsnag
15
- end
13
+ opt = UniformNotifier.bugsnag if UniformNotifier.bugsnag.is_a?(Hash)
16
14
 
17
15
  exception = Exception.new(data[:title])
18
16
  exception.set_backtrace(data[:backtrace]) if data[:backtrace]
19
- Bugsnag.notify(exception, opt.merge(
20
- grouping_hash: data[:body] || data[:title],
21
- notification: data
22
- ))
17
+ Bugsnag.notify(exception, opt.merge(grouping_hash: data[:body] || data[:title], notification: data))
23
18
  end
24
19
  end
25
20
  end
@@ -15,12 +15,14 @@ class UniformNotifier
15
15
  setup_connection_gntp(growl)
16
16
  rescue LoadError
17
17
  @growl = nil
18
- raise NotificationError, 'You must install the ruby-growl or the ruby_gntp gem to use Growl notification: `gem install ruby-growl` or `gem install ruby_gntp`'
18
+ raise NotificationError,
19
+ 'You must install the ruby-growl or the ruby_gntp gem to use Growl notification: `gem install ruby-growl` or `gem install ruby_gntp`'
19
20
  end
20
21
  end
21
22
 
22
23
  def self.setup_connection_growl(growl)
23
24
  return unless growl
25
+
24
26
  require 'ruby-growl'
25
27
  if growl.instance_of?(Hash)
26
28
  @password = growl.include?(:password) ? growl[:password] : nil
@@ -37,6 +39,7 @@ class UniformNotifier
37
39
 
38
40
  def self.setup_connection_gntp(growl)
39
41
  return unless growl
42
+
40
43
  require 'ruby_gntp'
41
44
  if growl.instance_of?(Hash)
42
45
  @password = growl.include?(:password) ? growl[:password] : nil
@@ -44,11 +47,8 @@ class UniformNotifier
44
47
  end
45
48
  @password ||= nil
46
49
  @host ||= 'localhost'
47
- @growl = GNTP.new('uniform_notifier', @host, @password, 23053)
48
- @growl.register(notifications: [{
49
- name: 'uniform_notifier',
50
- enabled: true,
51
- }])
50
+ @growl = GNTP.new('uniform_notifier', @host, @password, 23_053)
51
+ @growl.register(notifications: [{ name: 'uniform_notifier', enabled: true }])
52
52
 
53
53
  notify 'Uniform Notifier Growl has been turned on (using GNTP)' if !growl.instance_of?(Hash) || !growl[:quiet]
54
54
  end
@@ -67,11 +67,7 @@ class UniformNotifier
67
67
  if defined?(::Growl) && @growl.is_a?(::Growl)
68
68
  @growl.notify('uniform_notifier', 'Uniform Notifier', message)
69
69
  elsif defined?(::GNTP) && @growl.is_a?(::GNTP)
70
- @growl.notify(
71
- name: 'uniform_notifier',
72
- title: 'Uniform Notifier',
73
- text: message
74
- )
70
+ @growl.notify(name: 'uniform_notifier', title: 'Uniform Notifier', text: message)
75
71
  end
76
72
  end
77
73
  end
@@ -12,12 +12,11 @@ class UniformNotifier
12
12
  message = data.values.compact.join("\n")
13
13
 
14
14
  opt = {}
15
- if UniformNotifier.honeybadger.is_a?(Hash)
16
- opt = UniformNotifier.honeybadger
17
- end
15
+ opt = UniformNotifier.honeybadger if UniformNotifier.honeybadger.is_a?(Hash)
18
16
 
19
17
  exception = Exception.new(message)
20
- Honeybadger.notify(exception, opt)
18
+ honeybadger_class = opt[:honeybadger_class] || Honeybadger
19
+ honeybadger_class.notify(exception, opt)
21
20
  end
22
21
  end
23
22
  end
@@ -3,7 +3,7 @@
3
3
  class UniformNotifier
4
4
  class Raise < Base
5
5
  def self.active?
6
- @exception_class
6
+ defined?(@exception_class) ? @exception_class : false
7
7
  end
8
8
 
9
9
  def self.setup_connection(exception_class)
@@ -2,6 +2,8 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class RollbarNotifier < Base
5
+ DEFAULT_LEVEL = 'info'
6
+
5
7
  def self.active?
6
8
  !!UniformNotifier.rollbar
7
9
  end
@@ -12,7 +14,10 @@ class UniformNotifier
12
14
  message = data.values.compact.join("\n")
13
15
 
14
16
  exception = Exception.new(message)
15
- Rollbar.info(exception)
17
+ level = UniformNotifier.rollbar.fetch(:level, DEFAULT_LEVEL) if UniformNotifier.rollbar.is_a?(Hash)
18
+ level ||= DEFAULT_LEVEL
19
+
20
+ Rollbar.log(level, exception)
16
21
  end
17
22
  end
18
23
  end
@@ -12,9 +12,7 @@ class UniformNotifier
12
12
  message = data.values.compact.join("\n")
13
13
 
14
14
  opt = {}
15
- if UniformNotifier.sentry.is_a?(Hash)
16
- opt = UniformNotifier.sentry
17
- end
15
+ opt = UniformNotifier.sentry if UniformNotifier.sentry.is_a?(Hash)
18
16
 
19
17
  exception = Exception.new(message)
20
18
  Raven.capture_exception(exception, opt)
@@ -18,8 +18,7 @@ class UniformNotifier
18
18
  require 'slack-notifier'
19
19
  @slack = ::Slack::Notifier.new webhook_url, options
20
20
  rescue LoadError
21
- fail_connection 'You must install the slack-notifier gem to use Slack notification: '\
22
- '`gem install slack-notifier`'
21
+ fail_connection 'You must install the slack-notifier gem to use Slack notification: `gem install slack-notifier`'
23
22
  end
24
23
 
25
24
  protected
@@ -41,9 +40,7 @@ class UniformNotifier
41
40
  end
42
41
 
43
42
  def parse_config(config)
44
- options = config.select do |name, value|
45
- POSSIBLE_OPTIONS.include?(name) && !value.nil?
46
- end
43
+ options = config.select { |name, value| POSSIBLE_OPTIONS.include?(name) && !value.nil? }
47
44
 
48
45
  [config[:webhook_url], options]
49
46
  end
@@ -13,7 +13,8 @@ class UniformNotifier
13
13
  begin
14
14
  require 'terminal-notifier'
15
15
  rescue LoadError
16
- raise NotificationError, 'You must install the terminal-notifier gem to use terminal_notifier: `gem install terminal-notifier`'
16
+ raise NotificationError,
17
+ 'You must install the terminal-notifier gem to use terminal_notifier: `gem install terminal-notifier`'
17
18
  end
18
19
  end
19
20
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UniformNotifier
4
- VERSION = '1.12.0'
4
+ VERSION = '1.14.0'
5
5
  end
@@ -18,7 +18,7 @@ class UniformNotifier
18
18
  @xmpp = xmpp_information
19
19
  @receiver = xmpp_information[:receiver]
20
20
  @password = xmpp_information[:password]
21
- @account = xmpp_information[:account]
21
+ @account = xmpp_information[:account]
22
22
  @show_online_status = xmpp_information[:show_online_status]
23
23
  @stay_connected = xmpp_information[:stay_connected].nil? ? true : xmpp_information[:stay_connected]
24
24
 
@@ -48,9 +48,7 @@ class UniformNotifier
48
48
 
49
49
  def self.notify(message)
50
50
  connect unless @stay_connected
51
- message = Jabber::Message.new(@receiver, message)
52
- .set_type(:normal)
53
- .set_subject('Uniform Notifier')
51
+ message = Jabber::Message.new(@receiver, message).set_type(:normal).set_subject('Uniform Notifier')
54
52
  @xmpp.send(message)
55
53
  end
56
54
 
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ class Appsignal
6
+ # mock AppSignal
7
+ end
8
+
9
+ RSpec.describe UniformNotifier::AppsignalNotifier do
10
+ it 'should not notify appsignal' do
11
+ expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal')).to be_nil
12
+ end
13
+
14
+ it 'should notify appsignal with keyword title' do
15
+ expect(Appsignal).to receive(:send_error)
16
+ .with(UniformNotifier::Exception.new('notify appsignal'), {})
17
+
18
+ UniformNotifier.appsignal = true
19
+ expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal'))
20
+ end
21
+
22
+ it 'should notify appsignal with first argument title' do
23
+ expect(Appsignal).to receive(:send_error)
24
+ .with(UniformNotifier::Exception.new('notify appsignal'), {})
25
+
26
+ UniformNotifier.appsignal = true
27
+ UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
28
+ end
29
+
30
+ it 'should notify appsignal with tags' do
31
+ expect(Appsignal).to receive(:send_error)
32
+ .with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar })
33
+
34
+ UniformNotifier.appsignal = true
35
+ UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal', tags: { foo: :bar})
36
+ end
37
+
38
+ it 'should notify appsignal with default namespace' do
39
+ expect(Appsignal).to receive(:send_error)
40
+ .with(UniformNotifier::Exception.new('notify appsignal'), {}, 'web')
41
+
42
+ UniformNotifier.appsignal = { namespace: 'web' }
43
+ UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
44
+ end
45
+
46
+ it 'should notify appsignal with overridden namespace' do
47
+ expect(Appsignal).to receive(:send_error)
48
+ .with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar }, 'background')
49
+
50
+ UniformNotifier.appsignal = { namespace: 'web' }
51
+ UniformNotifier::AppsignalNotifier.out_of_channel_notify(
52
+ title: 'notify appsignal',
53
+ tags: { foo: :bar },
54
+ namespace: 'background'
55
+ )
56
+ end
57
+
58
+ it 'should notify appsignal with merged tags' do
59
+ expect(Appsignal).to receive(:send_error)
60
+ .with(UniformNotifier::Exception.new('notify appsignal'), { user: 'Bob', hostname: 'frontend2', site: 'first' }, 'background')
61
+
62
+ UniformNotifier.appsignal = { namespace: 'web', tags: { hostname: 'frontend1', user: 'Bob' } }
63
+ UniformNotifier::AppsignalNotifier.out_of_channel_notify(
64
+ title: 'notify appsignal',
65
+ tags: { hostname: 'frontend2', site: 'first' },
66
+ namespace: 'background'
67
+ )
68
+ end
69
+ end
@@ -4,18 +4,14 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe UniformNotifier::Base do
6
6
  context '#inline_channel_notify' do
7
- before do
8
- allow(UniformNotifier::Base).to receive(:active?).and_return(true)
9
- end
7
+ before { allow(UniformNotifier::Base).to receive(:active?).and_return(true) }
10
8
  it 'should keep the compatibility' do
11
9
  expect(UniformNotifier::Base).to receive(:_inline_notify).once.with(title: 'something')
12
10
  UniformNotifier::Base.inline_notify('something')
13
11
  end
14
12
  end
15
13
  context '#out_of_channel_notify' do
16
- before do
17
- allow(UniformNotifier::Base).to receive(:active?).and_return(true)
18
- end
14
+ before { allow(UniformNotifier::Base).to receive(:active?).and_return(true) }
19
15
  it 'should keep the compatibility' do
20
16
  expect(UniformNotifier::Base).to receive(:_out_of_channel_notify).once.with(title: 'something')
21
17
  UniformNotifier::Base.out_of_channel_notify('something')
@@ -16,14 +16,20 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
16
16
  let(:notification_data) { { user: 'user', title: 'notify bugsnag', url: 'URL', body: 'something' } }
17
17
 
18
18
  it 'should notify bugsnag' do
19
- expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new(notification_data[:title]), grouping_hash: notification_data[:body], notification: notification_data)
19
+ expect(Bugsnag).to receive(:notify).with(
20
+ UniformNotifier::Exception.new(notification_data[:title]),
21
+ grouping_hash: notification_data[:body], notification: notification_data
22
+ )
20
23
 
21
24
  UniformNotifier.bugsnag = true
22
25
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
23
26
  end
24
27
 
25
28
  it 'should notify bugsnag with option' do
26
- expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new(notification_data[:title]), foo: :bar, grouping_hash: notification_data[:body], notification: notification_data)
29
+ expect(Bugsnag).to receive(:notify).with(
30
+ UniformNotifier::Exception.new(notification_data[:title]),
31
+ foo: :bar, grouping_hash: notification_data[:body], notification: notification_data
32
+ )
27
33
 
28
34
  UniformNotifier.bugsnag = { foo: :bar }
29
35
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
@@ -33,14 +39,20 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
33
39
  let(:notification_data) { 'notify bugsnag' }
34
40
 
35
41
  it 'should notify bugsnag' do
36
- expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new('notify bugsnag'), grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' })
42
+ expect(Bugsnag).to receive(:notify).with(
43
+ UniformNotifier::Exception.new('notify bugsnag'),
44
+ grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' }
45
+ )
37
46
 
38
47
  UniformNotifier.bugsnag = true
39
48
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
40
49
  end
41
50
 
42
51
  it 'should notify bugsnag with option' do
43
- expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new('notify bugsnag'), foo: :bar, grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' })
52
+ expect(Bugsnag).to receive(:notify).with(
53
+ UniformNotifier::Exception.new('notify bugsnag'),
54
+ foo: :bar, grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' }
55
+ )
44
56
 
45
57
  UniformNotifier.bugsnag = { foo: :bar }
46
58
  UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
@@ -12,8 +12,13 @@ RSpec.describe UniformNotifier::Growl do
12
12
  expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
13
13
  expect(growl).to receive(:add_notification).with('uniform_notifier')
14
14
  expect(growl).to receive(:password=).with(nil)
15
- expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
16
- expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password').ordered
15
+ expect(growl).to receive(:notify).with(
16
+ 'uniform_notifier',
17
+ 'Uniform Notifier',
18
+ 'Uniform Notifier Growl has been turned on'
19
+ ).ordered
20
+ expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password')
21
+ .ordered
17
22
 
18
23
  UniformNotifier.growl = true
19
24
  UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl without password')
@@ -24,7 +29,11 @@ RSpec.describe UniformNotifier::Growl do
24
29
  expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
25
30
  expect(growl).to receive(:add_notification).with('uniform_notifier')
26
31
  expect(growl).to receive(:password=).with('123456')
27
- expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
32
+ expect(growl).to receive(:notify).with(
33
+ 'uniform_notifier',
34
+ 'Uniform Notifier',
35
+ 'Uniform Notifier Growl has been turned on'
36
+ ).ordered
28
37
  expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
29
38
 
30
39
  UniformNotifier.growl = { password: '123456' }
@@ -36,7 +45,11 @@ RSpec.describe UniformNotifier::Growl do
36
45
  expect(Growl).to receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl)
37
46
  expect(growl).to receive(:add_notification).with('uniform_notifier')
38
47
  expect(growl).to receive(:password=).with('123456')
39
- expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
48
+ expect(growl).to receive(:notify).with(
49
+ 'uniform_notifier',
50
+ 'Uniform Notifier',
51
+ 'Uniform Notifier Growl has been turned on'
52
+ ).ordered
40
53
  expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
41
54
 
42
55
  UniformNotifier.growl = { password: '123456', host: '10.10.156.17' }
@@ -48,7 +61,11 @@ RSpec.describe UniformNotifier::Growl do
48
61
  expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
49
62
  expect(growl).to receive(:add_notification).with('uniform_notifier')
50
63
  expect(growl).to receive(:password=).with('123456')
51
- expect(growl).not_to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
64
+ expect(growl).not_to receive(:notify).with(
65
+ 'uniform_notifier',
66
+ 'Uniform Notifier',
67
+ 'Uniform Notifier Growl has been turned on'
68
+ )
52
69
  expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password')
53
70
 
54
71
  UniformNotifier.growl = { password: '123456', quiet: true }
@@ -9,25 +9,22 @@ RSpec.describe UniformNotifier::Raise do
9
9
 
10
10
  it 'should raise error of the default class' do
11
11
  UniformNotifier.raise = true
12
- expect {
13
- UniformNotifier::Raise.out_of_channel_notify(title: 'notification')
14
- }.to raise_error(UniformNotifier::Exception, 'notification')
12
+ expect { UniformNotifier::Raise.out_of_channel_notify(title: 'notification') }.to raise_error(
13
+ UniformNotifier::Exception,
14
+ 'notification'
15
+ )
15
16
  end
16
17
 
17
18
  it 'allows the user to override the default exception class' do
18
- klass = Class.new(Exception)
19
+ klass = Class.new(RuntimeError)
19
20
  UniformNotifier.raise = klass
20
- expect {
21
- UniformNotifier::Raise.out_of_channel_notify(title: 'notification')
22
- }.to raise_error(klass, 'notification')
21
+ expect { UniformNotifier::Raise.out_of_channel_notify(title: 'notification') }.to raise_error(klass, 'notification')
23
22
  end
24
23
 
25
24
  it 'can be turned from on to off again' do
26
25
  UniformNotifier.raise = true
27
26
  UniformNotifier.raise = false
28
27
 
29
- expect {
30
- UniformNotifier::Raise.out_of_channel_notify(title: 'notification')
31
- }.not_to raise_error
28
+ expect { UniformNotifier::Raise.out_of_channel_notify(title: 'notification') }.not_to raise_error
32
29
  end
33
30
  end
@@ -12,9 +12,16 @@ RSpec.describe UniformNotifier::RollbarNotifier do
12
12
  end
13
13
 
14
14
  it 'should notify rollbar' do
15
- expect(Rollbar).to receive(:info).with(UniformNotifier::Exception.new('notify rollbar'))
15
+ expect(Rollbar).to receive(:log).with('info', UniformNotifier::Exception.new('notify rollbar'))
16
16
 
17
17
  UniformNotifier.rollbar = true
18
18
  UniformNotifier::RollbarNotifier.out_of_channel_notify(title: 'notify rollbar')
19
19
  end
20
+
21
+ it 'should notify rollbar' do
22
+ expect(Rollbar).to receive(:log).with('warning', UniformNotifier::Exception.new('notify rollbar'))
23
+
24
+ UniformNotifier.rollbar = { level: 'warning' }
25
+ UniformNotifier::RollbarNotifier.out_of_channel_notify(title: 'notify rollbar')
26
+ end
20
27
  end
@@ -20,6 +20,7 @@ RSpec.describe UniformNotifier::Slack do
20
20
  begin
21
21
  UniformNotifier.slack = {}
22
22
  rescue UniformNotifier::NotificationError
23
+
23
24
  ensure
24
25
  expect_any_instance_of(Slack::Notifier).to_not receive(:ping)
25
26
  expect(UniformNotifier::Slack.out_of_channel_notify(title: 'notify slack')).to be_nil
@@ -34,7 +35,8 @@ RSpec.describe UniformNotifier::Slack do
34
35
  end
35
36
 
36
37
  it 'should allow username and channel config options' do
37
- expect(Slack::Notifier).to receive(:new).with('http://some.slack.url', username: 'The Dude', channel: '#carpets').and_return(true)
38
+ expect(Slack::Notifier).to receive(:new).with('http://some.slack.url', username: 'The Dude', channel: '#carpets')
39
+ .and_return(true)
38
40
  UniformNotifier.slack = { webhook_url: 'http://some.slack.url', username: 'The Dude', channel: '#carpets' }
39
41
  expect(UniformNotifier::Slack.active?).to eq true
40
42
  end
@@ -9,7 +9,9 @@ RSpec.describe UniformNotifier::TerminalNotifier do
9
9
 
10
10
  it "should raise an exception when terminal-notifier gem isn't available" do
11
11
  UniformNotifier.terminal_notifier = true
12
- expect { UniformNotifier::TerminalNotifier.out_of_channel_notify(body: 'body', title: 'notify terminal') }.to raise_error(UniformNotifier::NotificationError, /terminal-notifier gem/)
12
+ expect {
13
+ UniformNotifier::TerminalNotifier.out_of_channel_notify(body: 'body', title: 'notify terminal')
14
+ }.to raise_error(UniformNotifier::NotificationError, /terminal-notifier gem/)
13
15
  end
14
16
 
15
17
  it 'should notify terminal-notifier when enabled' do
@@ -21,7 +21,9 @@ RSpec.describe UniformNotifier::Xmpp do
21
21
  expect(message).to receive(:set_subject).with('Uniform Notifier').and_return(message)
22
22
  expect(xmpp).to receive(:send).with(message)
23
23
 
24
- UniformNotifier.xmpp = { account: 'from@gmail.com', password: '123456', receiver: 'to@gmail.com', show_online_status: false }
24
+ UniformNotifier.xmpp = {
25
+ account: 'from@gmail.com', password: '123456', receiver: 'to@gmail.com', show_online_status: false
26
+ }
25
27
  UniformNotifier::Xmpp.out_of_channel_notify(title: 'notify xmpp')
26
28
  end
27
29
 
@@ -46,7 +48,9 @@ RSpec.describe UniformNotifier::Xmpp do
46
48
  expect(message).to receive(:set_subject).with('Uniform Notifier').and_return(message)
47
49
  expect(xmpp).to receive(:send).with(message)
48
50
 
49
- UniformNotifier.xmpp = { account: 'from@gmail.com', password: '123456', receiver: 'to@gmail.com', show_online_status: true }
51
+ UniformNotifier.xmpp = {
52
+ account: 'from@gmail.com', password: '123456', receiver: 'to@gmail.com', show_online_status: true
53
+ }
50
54
  UniformNotifier::Xmpp.out_of_channel_notify(title: 'notify xmpp')
51
55
  end
52
56
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
  require 'uniform_notifier/version'
5
5
 
6
6
  Gem::Specification.new do |s|
@@ -14,16 +14,22 @@ Gem::Specification.new do |s|
14
14
  s.description = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp'
15
15
  s.license = 'MIT'
16
16
 
17
- s.rubyforge_project = 'uniform_notifier'
17
+ s.required_ruby_version = '>= 2.3'
18
18
 
19
+ s.add_development_dependency 'rspec', ['> 0']
19
20
  s.add_development_dependency 'ruby-growl', ['= 4.0']
20
21
  s.add_development_dependency 'ruby_gntp', ['= 0.3.4']
21
- s.add_development_dependency 'xmpp4r', ['= 0.5']
22
22
  s.add_development_dependency 'slack-notifier', ['>= 1.0']
23
- s.add_development_dependency 'rspec', ['> 0']
23
+ s.add_development_dependency 'xmpp4r', ['= 0.5']
24
24
 
25
25
  s.files = `git ls-files`.split("\n")
26
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
27
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
28
28
  s.require_paths = ['lib']
29
+
30
+ if s.respond_to?(:metadata)
31
+ s.metadata['changelog_uri'] = 'https://github.com/flyerhzm/uniform_notifier/blob/master/CHANGELOG.md'
32
+ s.metadata['source_code_uri'] = 'https://github.com/flyerhzm/uniform_notifier'
33
+ s.metadata['bug_tracker_uri'] = 'https://github.com/flyerhzm/uniform_notifier/issues'
34
+ end
29
35
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniform_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-17 00:00:00.000000000 Z
11
+ date: 2021-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ruby-growl
14
+ name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby_gntp
28
+ name: ruby-growl
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.4
33
+ version: '4.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.3.4
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: xmpp4r
42
+ name: ruby_gntp
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0.5'
47
+ version: 0.3.4
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0.5'
54
+ version: 0.3.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: slack-notifier
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: xmpp4r
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">"
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.5'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">"
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.5'
83
83
  description: uniform notifier for rails logger, customized logger, javascript alert,
84
84
  javascript console, growl and xmpp
85
85
  email:
@@ -97,6 +97,7 @@ files:
97
97
  - Rakefile
98
98
  - lib/uniform_notifier.rb
99
99
  - lib/uniform_notifier/airbrake.rb
100
+ - lib/uniform_notifier/appsignal.rb
100
101
  - lib/uniform_notifier/base.rb
101
102
  - lib/uniform_notifier/bugsnag.rb
102
103
  - lib/uniform_notifier/customized_logger.rb
@@ -115,6 +116,7 @@ files:
115
116
  - lib/uniform_notifier/xmpp.rb
116
117
  - spec/spec_helper.rb
117
118
  - spec/uniform_notifier/airbrake_spec.rb
119
+ - spec/uniform_notifier/appsignal_spec.rb
118
120
  - spec/uniform_notifier/base_spec.rb
119
121
  - spec/uniform_notifier/bugsnag_spec.rb
120
122
  - spec/uniform_notifier/customized_logger_spec.rb
@@ -133,8 +135,11 @@ files:
133
135
  homepage: http://rubygems.org/gems/uniform_notifier
134
136
  licenses:
135
137
  - MIT
136
- metadata: {}
137
- post_install_message:
138
+ metadata:
139
+ changelog_uri: https://github.com/flyerhzm/uniform_notifier/blob/master/CHANGELOG.md
140
+ source_code_uri: https://github.com/flyerhzm/uniform_notifier
141
+ bug_tracker_uri: https://github.com/flyerhzm/uniform_notifier/issues
142
+ post_install_message:
138
143
  rdoc_options: []
139
144
  require_paths:
140
145
  - lib
@@ -142,22 +147,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
147
  requirements:
143
148
  - - ">="
144
149
  - !ruby/object:Gem::Version
145
- version: '0'
150
+ version: '2.3'
146
151
  required_rubygems_version: !ruby/object:Gem::Requirement
147
152
  requirements:
148
153
  - - ">="
149
154
  - !ruby/object:Gem::Version
150
155
  version: '0'
151
156
  requirements: []
152
- rubyforge_project: uniform_notifier
153
- rubygems_version: 2.6.14
154
- signing_key:
157
+ rubygems_version: 3.1.4
158
+ signing_key:
155
159
  specification_version: 4
156
160
  summary: uniform notifier for rails logger, customized logger, javascript alert, javascript
157
161
  console, growl and xmpp
158
162
  test_files:
159
163
  - spec/spec_helper.rb
160
164
  - spec/uniform_notifier/airbrake_spec.rb
165
+ - spec/uniform_notifier/appsignal_spec.rb
161
166
  - spec/uniform_notifier/base_spec.rb
162
167
  - spec/uniform_notifier/bugsnag_spec.rb
163
168
  - spec/uniform_notifier/customized_logger_spec.rb