notifier 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c842629dcf6da711e4d5979dd03a395e35e4aa752271f80f3fca65f50aff3bf9
4
- data.tar.gz: aec07ca38b8a39779dbf9e65383ea26cb140dc46b7069fb79798853ef9b3f611
3
+ metadata.gz: f11e00e55117bf997579f4d0cd0ba9acb4242d5e5045c519c36f938f637235d8
4
+ data.tar.gz: f4091e3ef9660c00ad6620dc45d648adb686174549eda5ecc33cf7e4e654da41
5
5
  SHA512:
6
- metadata.gz: a274ece6e94cb827c710d249ec9540551a116c2f99dbfa78ff8fe6c0458e9aa0c3fbd36df587cff7bbfdde4b9d1f213d1b07c5c9e3c66c1854f9a5f49e40af8a
7
- data.tar.gz: d741722e7fea144a2c920c4add06a7fab380cb9b591c437c095707bab9cbbb21cbfb3a929d2d315c9e19ea468d85b4214bdefb77b1cfbd6a05c3cc7aaf942242
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/) && hud?
8
+ Notifier.os?(/darwin/) && hud_bin
9
9
  end
10
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
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
- 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
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
@@ -3,8 +3,8 @@
3
3
  module Notifier
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 1
7
- PATCH = 0
6
+ MINOR = 2
7
+ PATCH = 1
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
10
10
  end
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) || supported_notifiers.first
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.0
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-22 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-utils