uniform_notifier 1.15.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +26 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -1
- data/README.md +5 -31
- data/lib/uniform_notifier/version.rb +1 -1
- data/lib/uniform_notifier.rb +0 -8
- data/spec/spec_helper.rb +0 -1
- data/spec/uniform_notifier/airbrake_spec.rb +1 -1
- data/spec/uniform_notifier/base_spec.rb +2 -2
- data/spec/uniform_notifier/bugsnag_spec.rb +3 -3
- data/spec/uniform_notifier/honeybadger_spec.rb +1 -1
- data/spec/uniform_notifier/slack_spec.rb +1 -1
- data/uniform_notifier.gemspec +2 -4
- metadata +5 -36
- data/.travis.yml +0 -3
- data/lib/uniform_notifier/growl.rb +0 -76
- data/spec/uniform_notifier/growl_spec.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 345526c76633d08822fec4f5aae85d96ddae55f7ad72182fac5da280063278fa
|
4
|
+
data.tar.gz: 3847746070513a8e12a89853821a300579f416be6e9d1f1cc80e2492c5cf7f33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87a4ad5a16f0f9fe28426318a3c7979dfa6d3c0ae4381f5971a4d31cec48863af9e5474f093fd9e00690cd05e610cba10e79f6a444092a623428637a1b06fc2
|
7
|
+
data.tar.gz: 8e4a5d81b898650f16eb1bc296c75b36f38d596fb82e94f2cb6f8615cdde94ed4f31c424a89b99db1f07cd8524faede84e115ea616bfa191a0e21f19fd5ca04f
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby:
|
14
|
+
- 2.7
|
15
|
+
- 3.0
|
16
|
+
- 3.1
|
17
|
+
steps:
|
18
|
+
- name: Checkout code
|
19
|
+
uses: actions/checkout@v3
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# UniformNotifier
|
2
2
|
|
3
|
-
[![
|
4
|
-
Status](https://secure.travis-ci.org/flyerhzm/uniform_notifier.svg)](http://travis-ci.org/flyerhzm/uniform_notifier)
|
3
|
+
[![CI](https://github.com/flyerhzm/uniform_notifier/actions/workflows/ci.yml/badge.svg)](https://github.com/flyerhzm/uniform_notifier/actions/workflows/ci.yml)
|
5
4
|
[![AwesomeCode Status for flyerhzm/uniform_notifier](https://awesomecode.io/projects/3e29a7de-0b37-4ecf-b06d-410ebf815174/status)](https://awesomecode.io/repos/flyerhzm/uniform_notifier)
|
6
5
|
|
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,
|
6
|
+
uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, xmpp, airbrake, honeybadger and AppSignal.
|
8
7
|
|
9
8
|
## Install
|
10
9
|
|
@@ -12,14 +11,6 @@ uniform_notifier is extracted from [bullet][0], it gives you the ability to send
|
|
12
11
|
|
13
12
|
gem install uniform_notifier
|
14
13
|
|
15
|
-
if you want to notify by growl < v1.3, you should install ruby-growl first
|
16
|
-
|
17
|
-
gem install ruby-growl
|
18
|
-
|
19
|
-
if you want to notify by growl v1.3+, you should install ruby_gntp first
|
20
|
-
|
21
|
-
gem install ruby_gntp
|
22
|
-
|
23
14
|
if you want to notify by xmpp, you should install xmpp4r first
|
24
15
|
|
25
16
|
gem install xmpp4r
|
@@ -56,13 +47,13 @@ if you want to notify by terminal-notifier, you must install it first
|
|
56
47
|
|
57
48
|
gem "uniform_notifier"
|
58
49
|
|
59
|
-
you should add
|
50
|
+
you should add xmpp4r, airbrake, bugsnag, honeybadger, slack-notifier, terminal-notifier gem if you want.
|
60
51
|
|
61
52
|
## Usage
|
62
53
|
|
63
54
|
There are two types of notifications,
|
64
55
|
one is <code>inline_notify</code>, for javascript alert and javascript console notifiers, which returns a string and will be combined,
|
65
|
-
the other is <code>out_of_channel_notify</code>, for rails logger, customized logger,
|
56
|
+
the other is <code>out_of_channel_notify</code>, for rails logger, customized logger, xmpp, which doesn't return anything, just send the message to the notifiers.
|
66
57
|
|
67
58
|
By default, all notifiers are disabled, you should enable them first.
|
68
59
|
|
@@ -120,11 +111,6 @@ logger = File.open('notify.log', 'a+')
|
|
120
111
|
logger.sync = true
|
121
112
|
UniformNotifier.customized_logger = logger
|
122
113
|
|
123
|
-
# growl without password
|
124
|
-
UniformNotifier.growl = true
|
125
|
-
# growl with passowrd
|
126
|
-
UniformNotifier.growl = { :password => 'growl password' }
|
127
|
-
|
128
114
|
# xmpp
|
129
115
|
UniformNotifier.xmpp = { :account => 'sender_account@jabber.org',
|
130
116
|
:password => 'password_for_jabber',
|
@@ -146,7 +132,7 @@ UniformNotifier.raise = false # don't raise errors
|
|
146
132
|
After that, you can enjoy the notifiers, that's cool!
|
147
133
|
|
148
134
|
```ruby
|
149
|
-
# the notify message will be notified to rails logger, customized logger
|
135
|
+
# the notify message will be notified to rails logger, customized logger or xmpp.
|
150
136
|
UniformNotifier.active_notifiers.each do |notifier|
|
151
137
|
notifier.out_of_channel_notify("customize message")
|
152
138
|
end
|
@@ -161,18 +147,6 @@ end
|
|
161
147
|
javascript_str = responses.join("\n")
|
162
148
|
```
|
163
149
|
|
164
|
-
## Growl Support
|
165
|
-
|
166
|
-
To get Growl support up-and-running, follow the steps below:
|
167
|
-
|
168
|
-
* For Growl < v1.3, install the ruby-growl gem: <code>gem install ruby-growl</code>
|
169
|
-
* For Growl v1.3+, install the ruby_gntp gem: <code>gem install ruby_gntp</code>
|
170
|
-
* Open the Growl preference pane in Systems Preferences
|
171
|
-
* Click the "Network" tab
|
172
|
-
* Make sure both "Listen for incoming notifications" and "Allow remote application registration" are checked. *Note*: If you set a password, you will need to set <code>UniformNotifier.growl_password = { :password => 'growl password' }</code> in the config file.
|
173
|
-
* Restart Growl ("General" tab -> Stop Growl -> Start Growl)
|
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.
|
175
|
-
|
176
150
|
## XMPP/Jabber Support
|
177
151
|
|
178
152
|
To get XMPP support up-and-running, follow the steps below:
|
data/lib/uniform_notifier.rb
CHANGED
@@ -4,7 +4,6 @@ require 'uniform_notifier/base'
|
|
4
4
|
require 'uniform_notifier/errors'
|
5
5
|
require 'uniform_notifier/javascript_alert'
|
6
6
|
require 'uniform_notifier/javascript_console'
|
7
|
-
require 'uniform_notifier/growl'
|
8
7
|
require 'uniform_notifier/honeybadger'
|
9
8
|
require 'uniform_notifier/xmpp'
|
10
9
|
require 'uniform_notifier/rails_logger'
|
@@ -22,7 +21,6 @@ class UniformNotifier
|
|
22
21
|
AVAILABLE_NOTIFIERS = %i[
|
23
22
|
alert
|
24
23
|
console
|
25
|
-
growl
|
26
24
|
honeybadger
|
27
25
|
xmpp
|
28
26
|
rails_logger
|
@@ -40,7 +38,6 @@ class UniformNotifier
|
|
40
38
|
NOTIFIERS = [
|
41
39
|
JavascriptAlert,
|
42
40
|
JavascriptConsole,
|
43
|
-
Growl,
|
44
41
|
HoneybadgerNotifier,
|
45
42
|
Xmpp,
|
46
43
|
RailsLogger,
|
@@ -65,11 +62,6 @@ class UniformNotifier
|
|
65
62
|
NOTIFIERS.select(&:active?)
|
66
63
|
end
|
67
64
|
|
68
|
-
undef growl=
|
69
|
-
def growl=(growl)
|
70
|
-
UniformNotifier::Growl.setup_connection(growl)
|
71
|
-
end
|
72
|
-
|
73
65
|
undef xmpp=
|
74
66
|
def xmpp=(xmpp)
|
75
67
|
UniformNotifier::Xmpp.setup_connection(xmpp)
|
data/spec/spec_helper.rb
CHANGED
@@ -19,7 +19,7 @@ RSpec.describe UniformNotifier::AirbrakeNotifier do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should notify airbrake' do
|
22
|
-
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new('notify airbrake'), foo: :bar)
|
22
|
+
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new('notify airbrake'), { foo: :bar })
|
23
23
|
|
24
24
|
UniformNotifier.airbrake = { foo: :bar }
|
25
25
|
UniformNotifier::AirbrakeNotifier.out_of_channel_notify('notify airbrake')
|
@@ -6,14 +6,14 @@ RSpec.describe UniformNotifier::Base do
|
|
6
6
|
context '#inline_channel_notify' do
|
7
7
|
before { allow(UniformNotifier::Base).to receive(:active?).and_return(true) }
|
8
8
|
it 'should keep the compatibility' do
|
9
|
-
expect(UniformNotifier::Base).to receive(:_inline_notify).once.with(title: 'something')
|
9
|
+
expect(UniformNotifier::Base).to receive(:_inline_notify).once.with({ title: 'something' })
|
10
10
|
UniformNotifier::Base.inline_notify('something')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
context '#out_of_channel_notify' do
|
14
14
|
before { allow(UniformNotifier::Base).to receive(:active?).and_return(true) }
|
15
15
|
it 'should keep the compatibility' do
|
16
|
-
expect(UniformNotifier::Base).to receive(:_out_of_channel_notify).once.with(title: 'something')
|
16
|
+
expect(UniformNotifier::Base).to receive(:_out_of_channel_notify).once.with({ title: 'something' })
|
17
17
|
UniformNotifier::Base.out_of_channel_notify('something')
|
18
18
|
end
|
19
19
|
end
|
@@ -26,7 +26,7 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
|
|
26
26
|
UniformNotifier::Exception.new(notification_data)
|
27
27
|
).and_yield(report)
|
28
28
|
expect(report).to receive(:severity=).with('warning')
|
29
|
-
expect(report).to receive(:add_tab).with(:bullet, title: notification_data)
|
29
|
+
expect(report).to receive(:add_tab).with(:bullet, { title: notification_data })
|
30
30
|
expect(report).to receive(:grouping_hash=).with(notification_data)
|
31
31
|
|
32
32
|
UniformNotifier.bugsnag = true
|
@@ -37,7 +37,7 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
|
|
37
37
|
expect(Bugsnag).to receive(:notify).with(
|
38
38
|
UniformNotifier::Exception.new(notification_data)
|
39
39
|
).and_yield(report)
|
40
|
-
expect(report).to receive(:meta_data=).with(foo: :bar)
|
40
|
+
expect(report).to receive(:meta_data=).with({ foo: :bar })
|
41
41
|
|
42
42
|
UniformNotifier.bugsnag = ->(report) { report.meta_data = { foo: :bar } }
|
43
43
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
@@ -62,7 +62,7 @@ RSpec.describe UniformNotifier::BugsnagNotifier do
|
|
62
62
|
expect(Bugsnag).to receive(:notify).with(
|
63
63
|
UniformNotifier::Exception.new(notification_data[:title])
|
64
64
|
).and_yield(report)
|
65
|
-
expect(report).to receive(:meta_data=).with(foo: :bar)
|
65
|
+
expect(report).to receive(:meta_data=).with({ foo: :bar })
|
66
66
|
|
67
67
|
UniformNotifier.bugsnag = ->(report) { report.meta_data = { foo: :bar } }
|
68
68
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
@@ -19,7 +19,7 @@ RSpec.describe UniformNotifier::HoneybadgerNotifier do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should notify honeybadger' do
|
22
|
-
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new('notify honeybadger'), foo: :bar)
|
22
|
+
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new('notify honeybadger'), { foo: :bar })
|
23
23
|
|
24
24
|
UniformNotifier.honeybadger = { foo: :bar }
|
25
25
|
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify('notify honeybadger')
|
@@ -35,7 +35,7 @@ RSpec.describe UniformNotifier::Slack do
|
|
35
35
|
|
36
36
|
it 'should allow username and channel config options' do
|
37
37
|
expect(Slack::Notifier).to receive(:new)
|
38
|
-
.with('http://some.slack.url', username: 'The Dude', channel: '#carpets')
|
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
|
data/uniform_notifier.gemspec
CHANGED
@@ -10,15 +10,13 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ['Richard Huang']
|
11
11
|
s.email = ['flyerhzm@gmail.com']
|
12
12
|
s.homepage = 'http://rubygems.org/gems/uniform_notifier'
|
13
|
-
s.summary = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console
|
14
|
-
s.description = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console
|
13
|
+
s.summary = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console and xmpp'
|
14
|
+
s.description = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console and xmpp'
|
15
15
|
s.license = 'MIT'
|
16
16
|
|
17
17
|
s.required_ruby_version = '>= 2.3'
|
18
18
|
|
19
19
|
s.add_development_dependency 'rspec', ['> 0']
|
20
|
-
s.add_development_dependency 'ruby_gntp', ['= 0.3.4']
|
21
|
-
s.add_development_dependency 'ruby-growl', ['= 4.0']
|
22
20
|
s.add_development_dependency 'slack-notifier', ['>= 1.0']
|
23
21
|
s.add_development_dependency 'xmpp4r', ['= 0.5']
|
24
22
|
|
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.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ruby_gntp
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.3.4
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.3.4
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: ruby-growl
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '4.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '4.0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: slack-notifier
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,15 +53,15 @@ dependencies:
|
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0.5'
|
83
55
|
description: uniform notifier for rails logger, customized logger, javascript alert,
|
84
|
-
javascript console
|
56
|
+
javascript console and xmpp
|
85
57
|
email:
|
86
58
|
- flyerhzm@gmail.com
|
87
59
|
executables: []
|
88
60
|
extensions: []
|
89
61
|
extra_rdoc_files: []
|
90
62
|
files:
|
63
|
+
- ".github/workflows/ci.yml"
|
91
64
|
- ".gitignore"
|
92
|
-
- ".travis.yml"
|
93
65
|
- CHANGELOG.md
|
94
66
|
- Gemfile
|
95
67
|
- LICENSE
|
@@ -102,7 +74,6 @@ files:
|
|
102
74
|
- lib/uniform_notifier/bugsnag.rb
|
103
75
|
- lib/uniform_notifier/customized_logger.rb
|
104
76
|
- lib/uniform_notifier/errors.rb
|
105
|
-
- lib/uniform_notifier/growl.rb
|
106
77
|
- lib/uniform_notifier/honeybadger.rb
|
107
78
|
- lib/uniform_notifier/javascript_alert.rb
|
108
79
|
- lib/uniform_notifier/javascript_console.rb
|
@@ -120,7 +91,6 @@ files:
|
|
120
91
|
- spec/uniform_notifier/base_spec.rb
|
121
92
|
- spec/uniform_notifier/bugsnag_spec.rb
|
122
93
|
- spec/uniform_notifier/customized_logger_spec.rb
|
123
|
-
- spec/uniform_notifier/growl_spec.rb
|
124
94
|
- spec/uniform_notifier/honeybadger_spec.rb
|
125
95
|
- spec/uniform_notifier/javascript_alert_spec.rb
|
126
96
|
- spec/uniform_notifier/javascript_console_spec.rb
|
@@ -158,7 +128,7 @@ rubygems_version: 3.3.7
|
|
158
128
|
signing_key:
|
159
129
|
specification_version: 4
|
160
130
|
summary: uniform notifier for rails logger, customized logger, javascript alert, javascript
|
161
|
-
console
|
131
|
+
console and xmpp
|
162
132
|
test_files:
|
163
133
|
- spec/spec_helper.rb
|
164
134
|
- spec/uniform_notifier/airbrake_spec.rb
|
@@ -166,7 +136,6 @@ test_files:
|
|
166
136
|
- spec/uniform_notifier/base_spec.rb
|
167
137
|
- spec/uniform_notifier/bugsnag_spec.rb
|
168
138
|
- spec/uniform_notifier/customized_logger_spec.rb
|
169
|
-
- spec/uniform_notifier/growl_spec.rb
|
170
139
|
- spec/uniform_notifier/honeybadger_spec.rb
|
171
140
|
- spec/uniform_notifier/javascript_alert_spec.rb
|
172
141
|
- spec/uniform_notifier/javascript_console_spec.rb
|
data/.travis.yml
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class UniformNotifier
|
4
|
-
class Growl < Base
|
5
|
-
class << self
|
6
|
-
@growl = nil
|
7
|
-
|
8
|
-
def active?
|
9
|
-
@growl
|
10
|
-
end
|
11
|
-
|
12
|
-
def setup_connection(growl)
|
13
|
-
setup_connection_growl(growl)
|
14
|
-
rescue LoadError
|
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
|
22
|
-
end
|
23
|
-
|
24
|
-
def setup_connection_growl(growl)
|
25
|
-
return unless growl
|
26
|
-
|
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]
|
39
|
-
end
|
40
|
-
|
41
|
-
def setup_connection_gntp(growl)
|
42
|
-
return unless growl
|
43
|
-
|
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 }])
|
53
|
-
|
54
|
-
notify 'Uniform Notifier Growl has been turned on (using GNTP)' if !growl.instance_of?(Hash) || !growl[:quiet]
|
55
|
-
end
|
56
|
-
|
57
|
-
protected
|
58
|
-
|
59
|
-
def _out_of_channel_notify(data)
|
60
|
-
message = data.values.compact.join("\n")
|
61
|
-
|
62
|
-
notify(message)
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
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
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe UniformNotifier::Growl do
|
6
|
-
it 'should not notify growl' do
|
7
|
-
expect(UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl')).to be_nil
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should notify growl without password' do
|
11
|
-
growl = double('growl', is_a?: true)
|
12
|
-
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
13
|
-
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
14
|
-
expect(growl).to receive(:password=).with(nil)
|
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')
|
20
|
-
.ordered
|
21
|
-
|
22
|
-
UniformNotifier.growl = true
|
23
|
-
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl without password')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should notify growl with password' do
|
27
|
-
growl = double('growl', is_a?: true)
|
28
|
-
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
29
|
-
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
30
|
-
expect(growl).to receive(:password=).with('123456')
|
31
|
-
expect(growl).to receive(:notify)
|
32
|
-
.with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
|
33
|
-
.ordered
|
34
|
-
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
35
|
-
|
36
|
-
UniformNotifier.growl = { password: '123456' }
|
37
|
-
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should notify growl with host' do
|
41
|
-
growl = double('growl', is_a?: true)
|
42
|
-
expect(Growl).to receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl)
|
43
|
-
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
44
|
-
expect(growl).to receive(:password=).with('123456')
|
45
|
-
expect(growl).to receive(:notify)
|
46
|
-
.with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
|
47
|
-
.ordered
|
48
|
-
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
49
|
-
|
50
|
-
UniformNotifier.growl = { password: '123456', host: '10.10.156.17' }
|
51
|
-
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should notify growl with quiet' do
|
55
|
-
growl = double('growl', is_a?: true)
|
56
|
-
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
57
|
-
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
58
|
-
expect(growl).to receive(:password=).with('123456')
|
59
|
-
expect(growl).not_to receive(:notify).with(
|
60
|
-
'uniform_notifier',
|
61
|
-
'Uniform Notifier',
|
62
|
-
'Uniform Notifier Growl has been turned on'
|
63
|
-
)
|
64
|
-
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password')
|
65
|
-
|
66
|
-
UniformNotifier.growl = { password: '123456', quiet: true }
|
67
|
-
UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password')
|
68
|
-
end
|
69
|
-
end
|