notifier 1.1.0 → 1.2.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 +4 -4
- data/README.md +8 -1
- data/lib/notifier/hud.rb +17 -26
- data/lib/notifier/version.rb +2 -2
- data/lib/notifier.rb +2 -1
- data/test/notifier/notifier_test.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11e00e55117bf997579f4d0cd0ba9acb4242d5e5045c519c36f938f637235d8
|
4
|
+
data.tar.gz: f4091e3ef9660c00ad6620dc45d648adb686174549eda5ecc33cf7e4e654da41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 155c248f28980870789ac3a679ce2a8a89434be67d91164ad19444b9f7ce7de2c4b1796f007f417bb14f01ae0ba26f7c0aa20fcf599ed800b67bd054932feb0f
|
7
|
+
data.tar.gz: 6ed42de3b14e5de5de1ce707f528203be37344afeb2c25ce394d36e28a959afa07cc6ec2957c601732e7ff1a94c69b5225f3283a3313e127e10ec332a3bfabe7
|
data/README.md
CHANGED
@@ -7,7 +7,6 @@ Send system notifications on several platforms with a simple and unified API.
|
|
7
7
|
Currently supports:
|
8
8
|
|
9
9
|
- terminal-notifier (Notification Center wrapper for Mac OS X)
|
10
|
-
- GNTP Protocol (Growl, with Vagrant support)
|
11
10
|
- Kdialog (Linux/KDE)
|
12
11
|
- Knotify (Linux/KDE)
|
13
12
|
- OSD Cat (Linux)
|
@@ -68,6 +67,14 @@ prefer:
|
|
68
67
|
Notifier.default_notifier = :notify_send
|
69
68
|
```
|
70
69
|
|
70
|
+
Alternatively, you can set the default notifier by using the `NOTIFIER` env var.
|
71
|
+
The following example assumes `test_notifier` is configured on this Rails
|
72
|
+
project. The env var has precedence of `Notifier.default_notifier`.
|
73
|
+
|
74
|
+
```console
|
75
|
+
$ NOTIFIER=hud rails test
|
76
|
+
```
|
77
|
+
|
71
78
|
The available names are `terminal_notifier`, `kdialog`, `knotify`,
|
72
79
|
`notify_send`, `osd_cat`, and `snarl`.
|
73
80
|
|
data/lib/notifier/hud.rb
CHANGED
@@ -5,37 +5,28 @@ module Notifier
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def supported?
|
8
|
-
Notifier.os?(/darwin/) &&
|
8
|
+
Notifier.os?(/darwin/) && hud_bin
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
return @hud unless @hud.nil?
|
17
|
-
|
18
|
-
@hud = begin
|
19
|
-
response = Net::HTTP.get_response(uri)
|
20
|
-
response.code == "200"
|
21
|
-
rescue StandardError
|
22
|
-
false
|
23
|
-
end
|
24
|
-
|
25
|
-
@hud
|
11
|
+
def hud_bin
|
12
|
+
@hud_bin ||= [
|
13
|
+
"/Applications/hud.app/Contents/MacOS/cli",
|
14
|
+
"~/Applications/hud.app/Contents/MacOS/cli"
|
15
|
+
].first {|path| File.expand_path(path) }
|
26
16
|
end
|
27
17
|
|
28
18
|
def notify(options)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
19
|
+
command = [
|
20
|
+
hud_bin,
|
21
|
+
"--title",
|
22
|
+
options[:title].to_s,
|
23
|
+
"--message",
|
24
|
+
options[:message].to_s,
|
25
|
+
"--symbol-name",
|
26
|
+
options[:image].to_s
|
27
|
+
]
|
28
|
+
|
29
|
+
Thread.new { system(*command) }.join
|
39
30
|
end
|
40
31
|
end
|
41
32
|
end
|
data/lib/notifier/version.rb
CHANGED
data/lib/notifier.rb
CHANGED
@@ -30,7 +30,8 @@ module Notifier
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def notifier
|
33
|
-
supported_notifier_from_name(default_notifier) ||
|
33
|
+
supported_notifier_from_name(ENV.fetch("NOTIFIER", default_notifier)) ||
|
34
|
+
supported_notifiers.first
|
34
35
|
end
|
35
36
|
|
36
37
|
def notify(options)
|
@@ -11,6 +11,7 @@ class NotifierTest < Minitest::Test
|
|
11
11
|
end
|
12
12
|
|
13
13
|
Notifier.default_notifier = nil
|
14
|
+
ENV.delete("NOTIFIER")
|
14
15
|
end
|
15
16
|
|
16
17
|
teardown do
|
@@ -40,6 +41,17 @@ class NotifierTest < Minitest::Test
|
|
40
41
|
assert_equal Notifier::Knotify, Notifier.notifier
|
41
42
|
end
|
42
43
|
|
44
|
+
test "prefers default notifier using env var" do
|
45
|
+
ENV["NOTIFIER"] = "knotify"
|
46
|
+
|
47
|
+
Notifier::Snarl.stubs(:supported?).returns(true)
|
48
|
+
Notifier::Knotify.stubs(:supported?).returns(true)
|
49
|
+
|
50
|
+
Notifier.default_notifier = :snarl
|
51
|
+
|
52
|
+
assert_equal Notifier::Knotify, Notifier.notifier
|
53
|
+
end
|
54
|
+
|
43
55
|
test "sends notification" do
|
44
56
|
params = {
|
45
57
|
title: "Some title",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest-utils
|