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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e8f22ae020099416927c4342232f8e37631292454b51036ee75a80227da2152
4
- data.tar.gz: bed78ad310c8577665578bc763e1e3f20f100e368d66c9f13fd460b38486bb2a
3
+ metadata.gz: c842629dcf6da711e4d5979dd03a395e35e4aa752271f80f3fca65f50aff3bf9
4
+ data.tar.gz: aec07ca38b8a39779dbf9e65383ea26cb140dc46b7069fb79798853ef9b3f611
5
5
  SHA512:
6
- metadata.gz: 2bca083c02fb0ee73772a8f3604ca2749b6e9cee6e6f75bff623afc948b0032aee87af722b3e071391731043749a0f1d9470b472c23f405e719b78df62183b9c
7
- data.tar.gz: a082e4f102062da75d76e21253848bf1cf56a08780a3fac4c7f2e032310e5c9c45cf7005700e84ce7d336632aa7b7ace9dd8c5493196074350c4bc6fa9dfb79e
6
+ metadata.gz: a274ece6e94cb827c710d249ec9540551a116c2f99dbfa78ff8fe6c0458e9aa0c3fbd36df587cff7bbfdde4b9d1f213d1b07c5c9e3c66c1854f9a5f49e40af8a
7
+ data.tar.gz: d741722e7fea144a2c920c4add06a7fab380cb9b591c437c095707bab9cbbb21cbfb3a929d2d315c9e19ea468d85b4214bdefb77b1cfbd6a05c3cc7aaf942242
@@ -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
@@ -12,9 +12,17 @@ module Notifier
12
12
 
13
13
  def notify(options)
14
14
  command = [
15
- "dcop", "knotify", "default", "notify", "eventname",
16
- options[:title].to_s, options[:message].to_s,
17
- "", "", "16", "2"
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
@@ -3,7 +3,7 @@
3
3
  module Notifier
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 0
6
+ MINOR = 1
7
7
  PATCH = 0
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
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
@@ -32,4 +32,5 @@ Gem::Specification.new do |s|
32
32
  s.add_development_dependency "rubocop"
33
33
  s.add_development_dependency "rubocop-fnando"
34
34
  s.add_development_dependency "simplecov"
35
+ s.add_development_dependency "test_notifier"
35
36
  end
@@ -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 7, Notifier.notifiers.size
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
@@ -8,6 +8,8 @@ require "notifier"
8
8
  require "minitest/utils"
9
9
  require "minitest/autorun"
10
10
 
11
+ Notifier.default_notifier = :hud
12
+
11
13
  module Snarl
12
14
  def self.show_message(*)
13
15
  end
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.0.0
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-20 00:00:00.000000000 Z
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