uniform_notifier 1.14.0 → 1.14.1

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
  SHA256:
3
- metadata.gz: 2e0dc90eb392f340e5bcb87c74e7f5ff5abdfe056c2f9a477349ed21806c981c
4
- data.tar.gz: da95631ac719cf684e878f377cd93ab1678ed6d5d18ba63c22b3f04d77224386
3
+ metadata.gz: b9fa5744a54e1bff245ab1f1b03974250a6a0880d63ba05b6594ada564bf4c87
4
+ data.tar.gz: ae4f6c59d2377f88f50419bcc1abe9215987a9b9c1d549b1323919d9f2d5841a
5
5
  SHA512:
6
- metadata.gz: 73a4d1e31f1604646b28f703ab865b6644413e42d41096c5e983d7fbbb0ae8a6ea1b2d14c88ffea7c15007d431aebedefd948d4365e265a3f074efd166ccc3a6
7
- data.tar.gz: '08c69d23ee80f460409ab2edd5949a7beff96799afc5aa5ea8adb89536969fb9c1defa096ac24a652551280ff0b1a8b86c85ddde5443c7ade8f04c459ee42a30'
6
+ metadata.gz: d739e807172146c2647ab96b122825efc3c033bc27dc3a27cf05c7d7e1c07bc2a273a15df6dd1f8574273663b30143b82cb997756c65a61c69c051c332c81dee
7
+ data.tar.gz: 785945370f105bacf35cc12b2d769a6d3038d4520df5f376e9d42cf055ea0959777431058c0f9f0f05bd1a2a823dcf2aaa929201d07122ab3aef3128732cda56
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Next Release
2
2
 
3
+ # 1.14.1 (02/28/2021)
4
+
5
+ * Fix uninitialized constant ``UniformNotifier::SentryNotifier::Raven`` error
6
+
3
7
  # 1.14.0 (02/26/2021)
4
8
 
5
9
  * Add AppSignal integration
@@ -55,7 +55,8 @@ class UniformNotifier
55
55
  TerminalNotifier
56
56
  ].freeze
57
57
 
58
- class NotificationError < StandardError; end
58
+ class NotificationError < StandardError
59
+ end
59
60
 
60
61
  class << self
61
62
  attr_accessor(*AVAILABLE_NOTIFIERS)
@@ -64,27 +65,27 @@ class UniformNotifier
64
65
  NOTIFIERS.select(&:active?)
65
66
  end
66
67
 
67
- undef :growl=
68
+ undef growl=
68
69
  def growl=(growl)
69
70
  UniformNotifier::Growl.setup_connection(growl)
70
71
  end
71
72
 
72
- undef :xmpp=
73
+ undef xmpp=
73
74
  def xmpp=(xmpp)
74
75
  UniformNotifier::Xmpp.setup_connection(xmpp)
75
76
  end
76
77
 
77
- undef :customized_logger=
78
+ undef customized_logger=
78
79
  def customized_logger=(logdev)
79
80
  UniformNotifier::CustomizedLogger.setup(logdev)
80
81
  end
81
82
 
82
- undef :slack=
83
+ undef slack=
83
84
  def slack=(slack)
84
85
  UniformNotifier::Slack.setup_connection(slack)
85
86
  end
86
87
 
87
- undef :raise=
88
+ undef raise=
88
89
  def raise=(exception_class)
89
90
  UniformNotifier::Raise.setup_connection(exception_class)
90
91
  end
@@ -2,20 +2,22 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class AirbrakeNotifier < Base
5
- def self.active?
6
- !!UniformNotifier.airbrake
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.airbrake
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- message = data.values.compact.join("\n")
12
+ def _out_of_channel_notify(data)
13
+ message = data.values.compact.join("\n")
13
14
 
14
- opt = {}
15
- opt = UniformNotifier.airbrake if UniformNotifier.airbrake.is_a?(Hash)
15
+ opt = {}
16
+ opt = UniformNotifier.airbrake if UniformNotifier.airbrake.is_a?(Hash)
16
17
 
17
- exception = Exception.new(message)
18
- Airbrake.notify(exception, opt)
18
+ exception = Exception.new(message)
19
+ Airbrake.notify(exception, opt)
20
+ end
19
21
  end
20
22
  end
21
23
  end
@@ -2,22 +2,24 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class AppsignalNotifier < Base
5
- def self.active?
6
- !!UniformNotifier.appsignal
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.appsignal
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- opt = UniformNotifier.appsignal.is_a?(Hash) ? UniformNotifier.appsignal : {}
12
+ def _out_of_channel_notify(data)
13
+ opt = UniformNotifier.appsignal.is_a?(Hash) ? UniformNotifier.appsignal : {}
13
14
 
14
- exception = Exception.new(data[:title])
15
- exception.set_backtrace(data[:backtrace]) if data[:backtrace]
15
+ exception = Exception.new(data[:title])
16
+ exception.set_backtrace(data[:backtrace]) if data[:backtrace]
16
17
 
17
- tags = opt.fetch(:tags, {}).merge(data.fetch(:tags, {}))
18
- namespace = data[:namespace] || opt[:namespace]
18
+ tags = opt.fetch(:tags, {}).merge(data.fetch(:tags, {}))
19
+ namespace = data[:namespace] || opt[:namespace]
19
20
 
20
- Appsignal.send_error(*[exception, tags, namespace].compact)
21
+ Appsignal.send_error(*[exception, tags, namespace].compact)
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -2,43 +2,45 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class Base
5
- def self.active?
6
- false
7
- end
5
+ class << self
6
+ def active?
7
+ false
8
+ end
8
9
 
9
- def self.inline_notify(data)
10
- return unless active?
10
+ def inline_notify(data)
11
+ return unless active?
11
12
 
12
- # For compatibility to the old protocol
13
- data = { title: data } if data.is_a?(String)
13
+ # For compatibility to the old protocol
14
+ data = { title: data } if data.is_a?(String)
14
15
 
15
- _inline_notify(data)
16
- end
16
+ _inline_notify(data)
17
+ end
17
18
 
18
- def self.out_of_channel_notify(data)
19
- return unless active?
19
+ def out_of_channel_notify(data)
20
+ return unless active?
20
21
 
21
- # For compatibility to the old protocol
22
- data = { title: data } if data.is_a?(String)
22
+ # For compatibility to the old protocol
23
+ data = { title: data } if data.is_a?(String)
23
24
 
24
- _out_of_channel_notify(data)
25
- end
25
+ _out_of_channel_notify(data)
26
+ end
26
27
 
27
- protected
28
+ protected
28
29
 
29
- def self._inline_notify(data); end
30
+ def _inline_notify(data); end
30
31
 
31
- def self._out_of_channel_notify(data); end
32
+ def _out_of_channel_notify(data); end
32
33
 
33
- def self.wrap_js_association(code, attributes = {})
34
- attributes = { type: 'text/javascript' }.merge(attributes || {})
35
- attributes_string = attributes.map { |k, v| "#{k}=#{v.to_s.inspect}" }.join(' ')
34
+ def wrap_js_association(code, attributes = {})
35
+ attributes = { type: 'text/javascript' }.merge(attributes || {})
36
+ attributes_string = attributes.map { |k, v| "#{k}=#{v.to_s.inspect}" }.join(' ')
36
37
 
37
- <<~CODE
38
- <script #{attributes_string}>/*<![CDATA[*/
39
- #{code}
40
- /*]]>*/</script>
41
- CODE
38
+ <<~CODE
39
+ <script #{attributes_string}>/*<![CDATA[*/
40
+ #{code}
41
+ /*]]>*/</script>
42
+ CODE
43
+ end
42
44
  end
43
45
  end
44
46
  end
@@ -2,19 +2,21 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class BugsnagNotifier < Base
5
- def self.active?
6
- !!UniformNotifier.bugsnag
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.bugsnag
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- opt = {}
13
- opt = UniformNotifier.bugsnag if UniformNotifier.bugsnag.is_a?(Hash)
12
+ def _out_of_channel_notify(data)
13
+ opt = {}
14
+ opt = UniformNotifier.bugsnag if UniformNotifier.bugsnag.is_a?(Hash)
14
15
 
15
- exception = Exception.new(data[:title])
16
- exception.set_backtrace(data[:backtrace]) if data[:backtrace]
17
- Bugsnag.notify(exception, opt.merge(grouping_hash: data[:body] || data[:title], notification: data))
16
+ exception = Exception.new(data[:title])
17
+ exception.set_backtrace(data[:backtrace]) if data[:backtrace]
18
+ Bugsnag.notify(exception, opt.merge(grouping_hash: data[:body] || data[:title], notification: data))
19
+ end
18
20
  end
19
21
  end
20
22
  end
@@ -2,24 +2,26 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class CustomizedLogger < Base
5
- @logger = nil
5
+ class << self
6
+ @logger = nil
6
7
 
7
- def self.active?
8
- @logger
9
- end
8
+ def active?
9
+ @logger
10
+ end
10
11
 
11
- def self._out_of_channel_notify(data)
12
- message = data.values.compact.join("\n")
13
- @logger.warn message
14
- end
12
+ def _out_of_channel_notify(data)
13
+ message = data.values.compact.join("\n")
14
+ @logger.warn message
15
+ end
15
16
 
16
- def self.setup(logdev)
17
- require 'logger'
17
+ def setup(logdev)
18
+ require 'logger'
18
19
 
19
- @logger = Logger.new(logdev)
20
+ @logger = Logger.new(logdev)
20
21
 
21
- def @logger.format_message(severity, timestamp, _progname, msg)
22
- "#{timestamp.strftime('%Y-%m-%d %H:%M:%S')}[#{severity}] #{msg}"
22
+ def @logger.format_message(severity, timestamp, _progname, msg)
23
+ "#{timestamp.strftime('%Y-%m-%d %H:%M:%S')}[#{severity}] #{msg}"
24
+ end
23
25
  end
24
26
  end
25
27
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UniformNotifier
4
- class Exception < RuntimeError; end
4
+ class Exception < RuntimeError
5
+ end
5
6
  end
@@ -2,72 +2,74 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class Growl < Base
5
- @growl = nil
5
+ class << self
6
+ @growl = nil
6
7
 
7
- def self.active?
8
- @growl
9
- end
8
+ def active?
9
+ @growl
10
+ end
10
11
 
11
- def self.setup_connection(growl)
12
- setup_connection_growl(growl)
13
- rescue LoadError
14
- begin
15
- setup_connection_gntp(growl)
12
+ def setup_connection(growl)
13
+ setup_connection_growl(growl)
16
14
  rescue LoadError
17
- @growl = nil
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`'
15
+ begin
16
+ setup_connection_gntp(growl)
17
+ rescue LoadError
18
+ @growl = nil
19
+ raise NotificationError,
20
+ 'You must install the ruby-growl or the ruby_gntp gem to use Growl notification: `gem install ruby-growl` or `gem install ruby_gntp`'
21
+ end
20
22
  end
21
- end
22
23
 
23
- def self.setup_connection_growl(growl)
24
- return unless growl
24
+ def setup_connection_growl(growl)
25
+ return unless growl
25
26
 
26
- require 'ruby-growl'
27
- if growl.instance_of?(Hash)
28
- @password = growl.include?(:password) ? growl[:password] : nil
29
- @host = growl.include?(:host) ? growl[:host] : 'localhost'
27
+ require 'ruby-growl'
28
+ if growl.instance_of?(Hash)
29
+ @password = growl.include?(:password) ? growl[:password] : nil
30
+ @host = growl.include?(:host) ? growl[:host] : 'localhost'
31
+ end
32
+ @password ||= nil
33
+ @host ||= 'localhost'
34
+ @growl = ::Growl.new @host, 'uniform_notifier'
35
+ @growl.add_notification 'uniform_notifier'
36
+ @growl.password = @password
37
+
38
+ notify 'Uniform Notifier Growl has been turned on' if !growl.instance_of?(Hash) || !growl[:quiet]
30
39
  end
31
- @password ||= nil
32
- @host ||= 'localhost'
33
- @growl = ::Growl.new @host, 'uniform_notifier'
34
- @growl.add_notification 'uniform_notifier'
35
- @growl.password = @password
36
40
 
37
- notify 'Uniform Notifier Growl has been turned on' if !growl.instance_of?(Hash) || !growl[:quiet]
38
- end
41
+ def setup_connection_gntp(growl)
42
+ return unless growl
39
43
 
40
- def self.setup_connection_gntp(growl)
41
- return unless growl
44
+ require 'ruby_gntp'
45
+ if growl.instance_of?(Hash)
46
+ @password = growl.include?(:password) ? growl[:password] : nil
47
+ @host = growl.include?(:host) ? growl[:host] : 'localhost'
48
+ end
49
+ @password ||= nil
50
+ @host ||= 'localhost'
51
+ @growl = GNTP.new('uniform_notifier', @host, @password, 23_053)
52
+ @growl.register(notifications: [{ name: 'uniform_notifier', enabled: true }])
42
53
 
43
- require 'ruby_gntp'
44
- if growl.instance_of?(Hash)
45
- @password = growl.include?(:password) ? growl[:password] : nil
46
- @host = growl.include?(:host) ? growl[:host] : 'localhost'
54
+ notify 'Uniform Notifier Growl has been turned on (using GNTP)' if !growl.instance_of?(Hash) || !growl[:quiet]
47
55
  end
48
- @password ||= nil
49
- @host ||= 'localhost'
50
- @growl = GNTP.new('uniform_notifier', @host, @password, 23_053)
51
- @growl.register(notifications: [{ name: 'uniform_notifier', enabled: true }])
52
56
 
53
- notify 'Uniform Notifier Growl has been turned on (using GNTP)' if !growl.instance_of?(Hash) || !growl[:quiet]
54
- end
55
-
56
- protected
57
+ protected
57
58
 
58
- def self._out_of_channel_notify(data)
59
- message = data.values.compact.join("\n")
59
+ def _out_of_channel_notify(data)
60
+ message = data.values.compact.join("\n")
60
61
 
61
- notify(message)
62
- end
62
+ notify(message)
63
+ end
63
64
 
64
- private
65
+ private
65
66
 
66
- def self.notify(message)
67
- if defined?(::Growl) && @growl.is_a?(::Growl)
68
- @growl.notify('uniform_notifier', 'Uniform Notifier', message)
69
- elsif defined?(::GNTP) && @growl.is_a?(::GNTP)
70
- @growl.notify(name: 'uniform_notifier', title: 'Uniform Notifier', text: message)
67
+ def notify(message)
68
+ if defined?(::Growl) && @growl.is_a?(::Growl)
69
+ @growl.notify('uniform_notifier', 'Uniform Notifier', message)
70
+ elsif defined?(::GNTP) && @growl.is_a?(::GNTP)
71
+ @growl.notify(name: 'uniform_notifier', title: 'Uniform Notifier', text: message)
72
+ end
71
73
  end
72
74
  end
73
75
  end
@@ -2,21 +2,23 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class HoneybadgerNotifier < Base
5
- def self.active?
6
- !!UniformNotifier.honeybadger
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.honeybadger
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- message = data.values.compact.join("\n")
12
+ def _out_of_channel_notify(data)
13
+ message = data.values.compact.join("\n")
13
14
 
14
- opt = {}
15
- opt = UniformNotifier.honeybadger if UniformNotifier.honeybadger.is_a?(Hash)
15
+ opt = {}
16
+ opt = UniformNotifier.honeybadger if UniformNotifier.honeybadger.is_a?(Hash)
16
17
 
17
- exception = Exception.new(message)
18
- honeybadger_class = opt[:honeybadger_class] || Honeybadger
19
- honeybadger_class.notify(exception, opt)
18
+ exception = Exception.new(message)
19
+ honeybadger_class = opt[:honeybadger_class] || Honeybadger
20
+ honeybadger_class.notify(exception, opt)
21
+ end
20
22
  end
21
23
  end
22
24
  end
@@ -2,18 +2,20 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class JavascriptAlert < Base
5
- def self.active?
6
- !!UniformNotifier.alert
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.alert
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._inline_notify(data)
12
- message = data.values.compact.join("\n")
13
- options = UniformNotifier.alert.is_a?(Hash) ? UniformNotifier.alert : {}
14
- script_attributes = options[:attributes] || {}
12
+ def _inline_notify(data)
13
+ message = data.values.compact.join("\n")
14
+ options = UniformNotifier.alert.is_a?(Hash) ? UniformNotifier.alert : {}
15
+ script_attributes = options[:attributes] || {}
15
16
 
16
- wrap_js_association "alert( #{message.inspect} );", script_attributes
17
+ wrap_js_association "alert( #{message.inspect} );", script_attributes
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -2,30 +2,32 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class JavascriptConsole < Base
5
- def self.active?
6
- !!UniformNotifier.console
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.console
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._inline_notify(data)
12
- message = data.values.compact.join("\n")
13
- options = UniformNotifier.console.is_a?(Hash) ? UniformNotifier.console : {}
14
- script_attributes = options[:attributes] || {}
12
+ def _inline_notify(data)
13
+ message = data.values.compact.join("\n")
14
+ options = UniformNotifier.console.is_a?(Hash) ? UniformNotifier.console : {}
15
+ script_attributes = options[:attributes] || {}
15
16
 
16
- code = <<~CODE
17
- if (typeof(console) !== 'undefined' && console.log) {
18
- if (console.groupCollapsed && console.groupEnd) {
19
- console.groupCollapsed(#{'Uniform Notifier'.inspect});
20
- console.log(#{message.inspect});
21
- console.groupEnd();
22
- } else {
23
- console.log(#{message.inspect});
17
+ code = <<~CODE
18
+ if (typeof(console) !== 'undefined' && console.log) {
19
+ if (console.groupCollapsed && console.groupEnd) {
20
+ console.groupCollapsed(#{'Uniform Notifier'.inspect});
21
+ console.log(#{message.inspect});
22
+ console.groupEnd();
23
+ } else {
24
+ console.log(#{message.inspect});
25
+ }
24
26
  }
25
- }
26
- CODE
27
+ CODE
27
28
 
28
- wrap_js_association code, script_attributes
29
+ wrap_js_association code, script_attributes
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -2,16 +2,18 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class RailsLogger < Base
5
- def self.active?
6
- UniformNotifier.rails_logger
7
- end
5
+ class << self
6
+ def active?
7
+ UniformNotifier.rails_logger
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- message = data.values.compact.join("\n")
12
+ def _out_of_channel_notify(data)
13
+ message = data.values.compact.join("\n")
13
14
 
14
- Rails.logger.warn message
15
+ Rails.logger.warn message
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -2,20 +2,22 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class Raise < Base
5
- def self.active?
6
- defined?(@exception_class) ? @exception_class : false
7
- end
5
+ class << self
6
+ def active?
7
+ defined?(@exception_class) ? @exception_class : false
8
+ end
8
9
 
9
- def self.setup_connection(exception_class)
10
- @exception_class = exception_class == true ? Exception : exception_class
11
- end
10
+ def setup_connection(exception_class)
11
+ @exception_class = exception_class == true ? Exception : exception_class
12
+ end
12
13
 
13
- protected
14
+ protected
14
15
 
15
- def self._out_of_channel_notify(data)
16
- message = data.values.compact.join("\n")
16
+ def _out_of_channel_notify(data)
17
+ message = data.values.compact.join("\n")
17
18
 
18
- raise @exception_class, message
19
+ raise @exception_class, message
20
+ end
19
21
  end
20
22
  end
21
23
  end
@@ -4,20 +4,22 @@ class UniformNotifier
4
4
  class RollbarNotifier < Base
5
5
  DEFAULT_LEVEL = 'info'
6
6
 
7
- def self.active?
8
- !!UniformNotifier.rollbar
9
- end
7
+ class << self
8
+ def active?
9
+ !!UniformNotifier.rollbar
10
+ end
10
11
 
11
- protected
12
+ protected
12
13
 
13
- def self._out_of_channel_notify(data)
14
- message = data.values.compact.join("\n")
14
+ def _out_of_channel_notify(data)
15
+ message = data.values.compact.join("\n")
15
16
 
16
- exception = Exception.new(message)
17
- level = UniformNotifier.rollbar.fetch(:level, DEFAULT_LEVEL) if UniformNotifier.rollbar.is_a?(Hash)
18
- level ||= DEFAULT_LEVEL
17
+ exception = Exception.new(message)
18
+ level = UniformNotifier.rollbar.fetch(:level, DEFAULT_LEVEL) if UniformNotifier.rollbar.is_a?(Hash)
19
+ level ||= DEFAULT_LEVEL
19
20
 
20
- Rollbar.log(level, exception)
21
+ Rollbar.log(level, exception)
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -2,20 +2,22 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class SentryNotifier < Base
5
- def self.active?
6
- !!UniformNotifier.sentry
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.sentry
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- message = data.values.compact.join("\n")
12
+ def _out_of_channel_notify(data)
13
+ message = data.values.compact.join("\n")
13
14
 
14
- opt = {}
15
- opt = UniformNotifier.sentry if UniformNotifier.sentry.is_a?(Hash)
15
+ opt = {}
16
+ opt = UniformNotifier.sentry if UniformNotifier.sentry.is_a?(Hash)
16
17
 
17
- exception = Exception.new(message)
18
- Raven.capture_exception(exception, opt)
18
+ exception = Exception.new(message)
19
+ Sentry.capture_exception(exception, opt)
20
+ end
19
21
  end
20
22
  end
21
23
  end
@@ -4,9 +4,9 @@ class UniformNotifier
4
4
  class Slack < Base
5
5
  POSSIBLE_OPTIONS = %i[username channel].freeze
6
6
 
7
- @slack = nil
8
-
9
7
  class << self
8
+ @slack = nil
9
+
10
10
  def active?
11
11
  @slack
12
12
  end
@@ -2,23 +2,25 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class TerminalNotifier < Base
5
- def self.active?
6
- !!UniformNotifier.terminal_notifier
7
- end
5
+ class << self
6
+ def active?
7
+ !!UniformNotifier.terminal_notifier
8
+ end
8
9
 
9
- protected
10
+ protected
10
11
 
11
- def self._out_of_channel_notify(data)
12
- unless defined?(::TerminalNotifier)
13
- begin
14
- require 'terminal-notifier'
15
- rescue LoadError
16
- raise NotificationError,
17
- 'You must install the terminal-notifier gem to use terminal_notifier: `gem install terminal-notifier`'
12
+ def _out_of_channel_notify(data)
13
+ unless defined?(::TerminalNotifier)
14
+ begin
15
+ require 'terminal-notifier'
16
+ rescue LoadError
17
+ raise NotificationError,
18
+ 'You must install the terminal-notifier gem to use terminal_notifier: `gem install terminal-notifier`'
19
+ end
18
20
  end
19
- end
20
21
 
21
- ::TerminalNotifier.notify(data[:body], title: data[:title])
22
+ ::TerminalNotifier.notify(data[:body], title: data[:title])
23
+ end
22
24
  end
23
25
  end
24
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UniformNotifier
4
- VERSION = '1.14.0'
4
+ VERSION = '1.14.1'
5
5
  end
@@ -2,58 +2,60 @@
2
2
 
3
3
  class UniformNotifier
4
4
  class Xmpp < Base
5
- @receiver = nil
6
- @xmpp = nil
7
- @password = nil
5
+ class << self
6
+ @receiver = nil
7
+ @xmpp = nil
8
+ @password = nil
8
9
 
9
- def self.active?
10
- @xmpp
11
- end
10
+ def active?
11
+ @xmpp
12
+ end
12
13
 
13
- def self.setup_connection(xmpp_information)
14
- return unless xmpp_information
14
+ def setup_connection(xmpp_information)
15
+ return unless xmpp_information
15
16
 
16
- require 'xmpp4r'
17
+ require 'xmpp4r'
17
18
 
18
- @xmpp = xmpp_information
19
- @receiver = xmpp_information[:receiver]
20
- @password = xmpp_information[:password]
21
- @account = xmpp_information[:account]
22
- @show_online_status = xmpp_information[:show_online_status]
23
- @stay_connected = xmpp_information[:stay_connected].nil? ? true : xmpp_information[:stay_connected]
19
+ @xmpp = xmpp_information
20
+ @receiver = xmpp_information[:receiver]
21
+ @password = xmpp_information[:password]
22
+ @account = xmpp_information[:account]
23
+ @show_online_status = xmpp_information[:show_online_status]
24
+ @stay_connected = xmpp_information[:stay_connected].nil? ? true : xmpp_information[:stay_connected]
24
25
 
25
- connect if @stay_connected
26
- rescue LoadError
27
- @xmpp = nil
28
- raise NotificationError, 'You must install the xmpp4r gem to use XMPP notification: `gem install xmpp4r`'
29
- end
26
+ connect if @stay_connected
27
+ rescue LoadError
28
+ @xmpp = nil
29
+ raise NotificationError, 'You must install the xmpp4r gem to use XMPP notification: `gem install xmpp4r`'
30
+ end
30
31
 
31
- protected
32
+ protected
32
33
 
33
- def self._out_of_channel_notify(data)
34
- message = data.values.compact.join("\n")
34
+ def _out_of_channel_notify(data)
35
+ message = data.values.compact.join("\n")
35
36
 
36
- notify(message)
37
- end
37
+ notify(message)
38
+ end
38
39
 
39
- private
40
+ private
40
41
 
41
- def self.connect
42
- jid = Jabber::JID.new(@account)
43
- @xmpp = Jabber::Client.new(jid)
44
- @xmpp.connect
45
- @xmpp.auth(@password)
46
- @xmpp.send(presence_status) if @show_online_status
47
- end
42
+ def connect
43
+ jid = Jabber::JID.new(@account)
44
+ @xmpp = Jabber::Client.new(jid)
45
+ @xmpp.connect
46
+ @xmpp.auth(@password)
47
+ @xmpp.send(presence_status) if @show_online_status
48
+ end
48
49
 
49
- def self.notify(message)
50
- connect unless @stay_connected
51
- message = Jabber::Message.new(@receiver, message).set_type(:normal).set_subject('Uniform Notifier')
52
- @xmpp.send(message)
53
- end
50
+ def notify(message)
51
+ connect unless @stay_connected
52
+ message = Jabber::Message.new(@receiver, message).set_type(:normal).set_subject('Uniform Notifier')
53
+ @xmpp.send(message)
54
+ end
54
55
 
55
- def self.presence_status
56
- Jabber::Presence.new.set_status("Uniform Notifier started on #{Time.now}")
56
+ def presence_status
57
+ Jabber::Presence.new.set_status("Uniform Notifier started on #{Time.now}")
58
+ end
57
59
  end
58
60
  end
59
61
  end
@@ -12,57 +12,64 @@ RSpec.describe UniformNotifier::AppsignalNotifier do
12
12
  end
13
13
 
14
14
  it 'should notify appsignal with keyword title' do
15
- expect(Appsignal).to receive(:send_error)
16
- .with(UniformNotifier::Exception.new('notify appsignal'), {})
15
+ expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), {})
17
16
 
18
17
  UniformNotifier.appsignal = true
19
18
  expect(UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal'))
20
19
  end
21
20
 
22
21
  it 'should notify appsignal with first argument title' do
23
- expect(Appsignal).to receive(:send_error)
24
- .with(UniformNotifier::Exception.new('notify appsignal'), {})
22
+ expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), {})
25
23
 
26
24
  UniformNotifier.appsignal = true
27
25
  UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
28
26
  end
29
27
 
30
28
  it 'should notify appsignal with tags' do
31
- expect(Appsignal).to receive(:send_error)
32
- .with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar })
29
+ expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), { foo: :bar })
33
30
 
34
31
  UniformNotifier.appsignal = true
35
- UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal', tags: { foo: :bar})
32
+ UniformNotifier::AppsignalNotifier.out_of_channel_notify(title: 'notify appsignal', tags: { foo: :bar })
36
33
  end
37
34
 
38
35
  it 'should notify appsignal with default namespace' do
39
- expect(Appsignal).to receive(:send_error)
40
- .with(UniformNotifier::Exception.new('notify appsignal'), {}, 'web')
36
+ expect(Appsignal).to receive(:send_error).with(UniformNotifier::Exception.new('notify appsignal'), {}, 'web')
41
37
 
42
38
  UniformNotifier.appsignal = { namespace: 'web' }
43
39
  UniformNotifier::AppsignalNotifier.out_of_channel_notify('notify appsignal')
44
40
  end
45
41
 
46
42
  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')
43
+ expect(Appsignal).to receive(:send_error).with(
44
+ UniformNotifier::Exception.new('notify appsignal'),
45
+ { foo: :bar },
46
+ 'background'
47
+ )
49
48
 
50
49
  UniformNotifier.appsignal = { namespace: 'web' }
51
50
  UniformNotifier::AppsignalNotifier.out_of_channel_notify(
52
51
  title: 'notify appsignal',
53
- tags: { foo: :bar },
52
+ tags: {
53
+ foo: :bar
54
+ },
54
55
  namespace: 'background'
55
56
  )
56
57
  end
57
58
 
58
59
  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')
60
+ expect(Appsignal).to receive(:send_error).with(
61
+ UniformNotifier::Exception.new('notify appsignal'),
62
+ { user: 'Bob', hostname: 'frontend2', site: 'first' },
63
+ 'background'
64
+ )
61
65
 
62
66
  UniformNotifier.appsignal = { namespace: 'web', tags: { hostname: 'frontend1', user: 'Bob' } }
63
67
  UniformNotifier::AppsignalNotifier.out_of_channel_notify(
64
68
  title: 'notify appsignal',
65
- tags: { hostname: 'frontend2', site: 'first' },
69
+ tags: {
70
+ hostname: 'frontend2',
71
+ site: 'first'
72
+ },
66
73
  namespace: 'background'
67
74
  )
68
75
  end
@@ -18,7 +18,8 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
18
18
  it 'should notify bugsnag' do
19
19
  expect(Bugsnag).to receive(:notify).with(
20
20
  UniformNotifier::Exception.new(notification_data[:title]),
21
- grouping_hash: notification_data[:body], notification: notification_data
21
+ grouping_hash: notification_data[:body],
22
+ notification: notification_data
22
23
  )
23
24
 
24
25
  UniformNotifier.bugsnag = true
@@ -28,7 +29,9 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
28
29
  it 'should notify bugsnag with option' do
29
30
  expect(Bugsnag).to receive(:notify).with(
30
31
  UniformNotifier::Exception.new(notification_data[:title]),
31
- foo: :bar, grouping_hash: notification_data[:body], notification: notification_data
32
+ foo: :bar,
33
+ grouping_hash: notification_data[:body],
34
+ notification: notification_data
32
35
  )
33
36
 
34
37
  UniformNotifier.bugsnag = { foo: :bar }
@@ -41,7 +44,10 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
41
44
  it 'should notify bugsnag' do
42
45
  expect(Bugsnag).to receive(:notify).with(
43
46
  UniformNotifier::Exception.new('notify bugsnag'),
44
- grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' }
47
+ grouping_hash: 'notify bugsnag',
48
+ notification: {
49
+ title: 'notify bugsnag'
50
+ }
45
51
  )
46
52
 
47
53
  UniformNotifier.bugsnag = true
@@ -51,7 +57,11 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
51
57
  it 'should notify bugsnag with option' do
52
58
  expect(Bugsnag).to receive(:notify).with(
53
59
  UniformNotifier::Exception.new('notify bugsnag'),
54
- foo: :bar, grouping_hash: 'notify bugsnag', notification: { title: 'notify bugsnag' }
60
+ foo: :bar,
61
+ grouping_hash: 'notify bugsnag',
62
+ notification: {
63
+ title: 'notify bugsnag'
64
+ }
55
65
  )
56
66
 
57
67
  UniformNotifier.bugsnag = { foo: :bar }
@@ -12,12 +12,11 @@ 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(
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')
15
+ expect(growl).to receive(:notify)
16
+ .with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
17
+ .ordered
18
+ expect(growl).to receive(:notify)
19
+ .with('uniform_notifier', 'Uniform Notifier', 'notify growl without password')
21
20
  .ordered
22
21
 
23
22
  UniformNotifier.growl = true
@@ -29,11 +28,9 @@ RSpec.describe UniformNotifier::Growl do
29
28
  expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
30
29
  expect(growl).to receive(:add_notification).with('uniform_notifier')
31
30
  expect(growl).to receive(:password=).with('123456')
32
- expect(growl).to receive(:notify).with(
33
- 'uniform_notifier',
34
- 'Uniform Notifier',
35
- 'Uniform Notifier Growl has been turned on'
36
- ).ordered
31
+ expect(growl).to receive(:notify)
32
+ .with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
33
+ .ordered
37
34
  expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
38
35
 
39
36
  UniformNotifier.growl = { password: '123456' }
@@ -45,11 +42,9 @@ RSpec.describe UniformNotifier::Growl do
45
42
  expect(Growl).to receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl)
46
43
  expect(growl).to receive(:add_notification).with('uniform_notifier')
47
44
  expect(growl).to receive(:password=).with('123456')
48
- expect(growl).to receive(:notify).with(
49
- 'uniform_notifier',
50
- 'Uniform Notifier',
51
- 'Uniform Notifier Growl has been turned on'
52
- ).ordered
45
+ expect(growl).to receive(:notify)
46
+ .with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
47
+ .ordered
53
48
  expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
54
49
 
55
50
  UniformNotifier.growl = { password: '123456', host: '10.10.156.17' }
@@ -17,7 +17,7 @@ RSpec.describe UniformNotifier::JavascriptAlert do
17
17
  end
18
18
 
19
19
  it 'should accept custom attributes' do
20
- UniformNotifier.alert = { attributes: { nonce: 'my-nonce', 'data-key' => :value } }
20
+ UniformNotifier.alert = { attributes: { :nonce => 'my-nonce', 'data-key' => :value } }
21
21
  expect(UniformNotifier::JavascriptAlert.inline_notify(title: 'javascript alert!')).to eq <<~CODE
22
22
  <script type="text/javascript" nonce="my-nonce" data-key="value">/*<![CDATA[*/
23
23
  alert( "javascript alert!" );
@@ -26,7 +26,7 @@ RSpec.describe UniformNotifier::JavascriptConsole do
26
26
  end
27
27
 
28
28
  it 'should accept custom attributes' do
29
- UniformNotifier.console = { attributes: { nonce: 'my-nonce', 'data-key' => :value } }
29
+ UniformNotifier.console = { attributes: { :nonce => 'my-nonce', 'data-key' => :value } }
30
30
  expect(UniformNotifier::JavascriptConsole.inline_notify(title: 'javascript console!')).to eq <<~CODE
31
31
  <script type="text/javascript" nonce="my-nonce" data-key="value">/*<![CDATA[*/
32
32
  if (typeof(console) !== 'undefined' && console.log) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- class Raven
5
+ class Sentry
6
6
  # mock Sentry
7
7
  end
8
8
 
@@ -12,14 +12,14 @@ RSpec.describe UniformNotifier::SentryNotifier do
12
12
  end
13
13
 
14
14
  it 'should notify sentry' do
15
- expect(Raven).to receive(:capture_exception).with(UniformNotifier::Exception.new('notify sentry'), {})
15
+ expect(Sentry).to receive(:capture_exception).with(UniformNotifier::Exception.new('notify sentry'), {})
16
16
 
17
17
  UniformNotifier.sentry = true
18
18
  UniformNotifier::SentryNotifier.out_of_channel_notify(title: 'notify sentry')
19
19
  end
20
20
 
21
21
  it 'should notify sentry' do
22
- expect(Raven).to receive(:capture_exception).with(UniformNotifier::Exception.new('notify sentry'), foo: :bar)
22
+ expect(Sentry).to receive(:capture_exception).with(UniformNotifier::Exception.new('notify sentry'), foo: :bar)
23
23
 
24
24
  UniformNotifier.sentry = { foo: :bar }
25
25
  UniformNotifier::SentryNotifier.out_of_channel_notify('notify sentry')
@@ -20,7 +20,6 @@ RSpec.describe UniformNotifier::Slack do
20
20
  begin
21
21
  UniformNotifier.slack = {}
22
22
  rescue UniformNotifier::NotificationError
23
-
24
23
  ensure
25
24
  expect_any_instance_of(Slack::Notifier).to_not receive(:ping)
26
25
  expect(UniformNotifier::Slack.out_of_channel_notify(title: 'notify slack')).to be_nil
@@ -35,7 +34,8 @@ RSpec.describe UniformNotifier::Slack do
35
34
  end
36
35
 
37
36
  it 'should allow username and channel config options' do
38
- expect(Slack::Notifier).to receive(:new).with('http://some.slack.url', username: 'The Dude', channel: '#carpets')
37
+ expect(Slack::Notifier).to receive(:new)
38
+ .with('http://some.slack.url', username: 'The Dude', channel: '#carpets')
39
39
  .and_return(true)
40
40
  UniformNotifier.slack = { webhook_url: 'http://some.slack.url', username: 'The Dude', channel: '#carpets' }
41
41
  expect(UniformNotifier::Slack.active?).to eq true
@@ -22,7 +22,10 @@ RSpec.describe UniformNotifier::Xmpp do
22
22
  expect(xmpp).to receive(:send).with(message)
23
23
 
24
24
  UniformNotifier.xmpp = {
25
- account: 'from@gmail.com', password: '123456', receiver: 'to@gmail.com', show_online_status: false
25
+ account: 'from@gmail.com',
26
+ password: '123456',
27
+ receiver: 'to@gmail.com',
28
+ show_online_status: false
26
29
  }
27
30
  UniformNotifier::Xmpp.out_of_channel_notify(title: 'notify xmpp')
28
31
  end
@@ -49,7 +52,10 @@ RSpec.describe UniformNotifier::Xmpp do
49
52
  expect(xmpp).to receive(:send).with(message)
50
53
 
51
54
  UniformNotifier.xmpp = {
52
- account: 'from@gmail.com', password: '123456', receiver: 'to@gmail.com', show_online_status: true
55
+ account: 'from@gmail.com',
56
+ password: '123456',
57
+ receiver: 'to@gmail.com',
58
+ show_online_status: true
53
59
  }
54
60
  UniformNotifier::Xmpp.out_of_channel_notify(title: 'notify xmpp')
55
61
  end
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.required_ruby_version = '>= 2.3'
18
18
 
19
19
  s.add_development_dependency 'rspec', ['> 0']
20
- s.add_development_dependency 'ruby-growl', ['= 4.0']
21
20
  s.add_development_dependency 'ruby_gntp', ['= 0.3.4']
21
+ s.add_development_dependency 'ruby-growl', ['= 4.0']
22
22
  s.add_development_dependency 'slack-notifier', ['>= 1.0']
23
23
  s.add_development_dependency 'xmpp4r', ['= 0.5']
24
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniform_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-26 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-growl
28
+ name: ruby_gntp
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: 0.3.4
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: '4.0'
40
+ version: 0.3.4
41
41
  - !ruby/object:Gem::Dependency
42
- name: ruby_gntp
42
+ name: ruby-growl
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.4
47
+ version: '4.0'
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.3.4
54
+ version: '4.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: slack-notifier
57
57
  requirement: !ruby/object:Gem::Requirement