notifier 1.0.0 → 1.1.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 +4 -4
- data/lib/notifier/hud.rb +41 -0
- data/lib/notifier/knotify.rb +11 -3
- data/lib/notifier/version.rb +1 -1
- data/lib/notifier.rb +2 -0
- data/notifier.gemspec +1 -0
- data/test/notifier/notifier_test.rb +6 -1
- data/test/test_helper.rb +2 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c842629dcf6da711e4d5979dd03a395e35e4aa752271f80f3fca65f50aff3bf9
|
4
|
+
data.tar.gz: aec07ca38b8a39779dbf9e65383ea26cb140dc46b7069fb79798853ef9b3f611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a274ece6e94cb827c710d249ec9540551a116c2f99dbfa78ff8fe6c0458e9aa0c3fbd36df587cff7bbfdde4b9d1f213d1b07c5c9e3c66c1854f9a5f49e40af8a
|
7
|
+
data.tar.gz: d741722e7fea144a2c920c4add06a7fab380cb9b591c437c095707bab9cbbb21cbfb3a929d2d315c9e19ea468d85b4214bdefb77b1cfbd6a05c3cc7aaf942242
|
data/lib/notifier/hud.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Notifier
|
4
|
+
module Hud
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def supported?
|
8
|
+
Notifier.os?(/darwin/) && hud?
|
9
|
+
end
|
10
|
+
|
11
|
+
def uri
|
12
|
+
URI("http://127.0.0.1:32323/hud")
|
13
|
+
end
|
14
|
+
|
15
|
+
def hud?
|
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
|
26
|
+
end
|
27
|
+
|
28
|
+
def notify(options)
|
29
|
+
Thread.new do
|
30
|
+
Net::HTTP.post_form(
|
31
|
+
uri,
|
32
|
+
{
|
33
|
+
"title" => options[:title].to_s,
|
34
|
+
"message" => options[:message].to_s,
|
35
|
+
"symbolName" => options[:image].to_s
|
36
|
+
}
|
37
|
+
)
|
38
|
+
end.join
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/notifier/knotify.rb
CHANGED
@@ -12,9 +12,17 @@ module Notifier
|
|
12
12
|
|
13
13
|
def notify(options)
|
14
14
|
command = [
|
15
|
-
"dcop",
|
16
|
-
|
17
|
-
"",
|
15
|
+
"dcop",
|
16
|
+
"knotify",
|
17
|
+
"default",
|
18
|
+
"notify",
|
19
|
+
"eventname",
|
20
|
+
options[:title].to_s,
|
21
|
+
options[:message].to_s,
|
22
|
+
"",
|
23
|
+
"",
|
24
|
+
"16",
|
25
|
+
"2"
|
18
26
|
]
|
19
27
|
|
20
28
|
Thread.new { system(*command) }.join
|
data/lib/notifier/version.rb
CHANGED
data/lib/notifier.rb
CHANGED
@@ -6,9 +6,11 @@ require "digest/md5"
|
|
6
6
|
require "timeout"
|
7
7
|
require "rbconfig"
|
8
8
|
require "English"
|
9
|
+
require "net/http"
|
9
10
|
|
10
11
|
module Notifier
|
11
12
|
require "notifier/snarl"
|
13
|
+
require "notifier/hud"
|
12
14
|
require "notifier/osd_cat"
|
13
15
|
require "notifier/knotify"
|
14
16
|
require "notifier/kdialog"
|
data/notifier.gemspec
CHANGED
@@ -13,6 +13,10 @@ class NotifierTest < Minitest::Test
|
|
13
13
|
Notifier.default_notifier = nil
|
14
14
|
end
|
15
15
|
|
16
|
+
teardown do
|
17
|
+
Notifier.default_notifier = :hud
|
18
|
+
end
|
19
|
+
|
16
20
|
test "retrieves list of supported notifiers" do
|
17
21
|
Notifier::Snarl.stubs(:supported?).returns(true)
|
18
22
|
Notifier::Knotify.stubs(:supported?).returns(true)
|
@@ -50,7 +54,7 @@ class NotifierTest < Minitest::Test
|
|
50
54
|
end
|
51
55
|
|
52
56
|
test "retrieves list of all notifiers" do
|
53
|
-
assert_equal
|
57
|
+
assert_equal 8, Notifier.notifiers.size
|
54
58
|
end
|
55
59
|
|
56
60
|
test "considers Placebo as fallback notifier" do
|
@@ -60,6 +64,7 @@ class NotifierTest < Minitest::Test
|
|
60
64
|
test "returns notifier by its name" do
|
61
65
|
assert_equal Notifier::OsdCat, Notifier.from_name(:osd_cat)
|
62
66
|
assert_equal Notifier::NotifySend, Notifier.from_name(:notify_send)
|
67
|
+
assert_equal Notifier::Hud, Notifier.from_name(:hud)
|
63
68
|
end
|
64
69
|
|
65
70
|
test "returns notifier by its name when supported" do
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 1.1.0
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest-utils
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: test_notifier
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Send system notifications on several platforms with a simple and unified
|
98
112
|
API. Currently supports Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
|
99
113
|
email:
|
@@ -109,6 +123,7 @@ files:
|
|
109
123
|
- README.md
|
110
124
|
- Rakefile
|
111
125
|
- lib/notifier.rb
|
126
|
+
- lib/notifier/hud.rb
|
112
127
|
- lib/notifier/kdialog.rb
|
113
128
|
- lib/notifier/knotify.rb
|
114
129
|
- lib/notifier/notify_send.rb
|