notifier 0.5.2 → 1.0.0

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
- SHA1:
3
- metadata.gz: ae5afe2f3c9c49b9f8e29be682424de92908dd35
4
- data.tar.gz: 7b5c443d285fd023fb001b48ebe43ac695944d7c
2
+ SHA256:
3
+ metadata.gz: 4e8f22ae020099416927c4342232f8e37631292454b51036ee75a80227da2152
4
+ data.tar.gz: bed78ad310c8577665578bc763e1e3f20f100e368d66c9f13fd460b38486bb2a
5
5
  SHA512:
6
- metadata.gz: 56c4fbc80d2c33cb22990600f977d031335c6e4cc4df42ce3f8bd9d0da452d183df75127dcd405ea36121d23bd6aab1cd8f5200e5b7de8bafde03a768563d2af
7
- data.tar.gz: a9a64939c8a7db0f0040baec682e6d078621b2a8328036d016469cb8e534a9d1faba0a56a64c1586c2c2eb378493e8fed57178de964bba7965539bc8e7d97ccf
6
+ metadata.gz: 2bca083c02fb0ee73772a8f3604ca2749b6e9cee6e6f75bff623afc948b0032aee87af722b3e071391731043749a0f1d9470b472c23f405e719b78df62183b9c
7
+ data.tar.gz: a082e4f102062da75d76e21253848bf1cf56a08780a3fac4c7f2e032310e5c9c45cf7005700e84ce7d336632aa7b7ace9dd8c5493196074350c4bc6fa9dfb79e
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pkg/*
3
3
  .bundle
4
4
  .DS_Store
5
5
  *.lock
6
+ /coverage
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ inherit_gem:
3
+ rubocop-fnando: .rubocop.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ NewCops: enable
8
+ Exclude:
9
+ - vendor/**/*
10
+ - gemfiles/**/*
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "http://rubygems.org"
2
4
  gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ (The MIT License)
2
+
3
+ Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the 'Software'), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,21 +1,18 @@
1
1
  # Notifier
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/notifier.png)](https://travis-ci.org/fnando/notifier)
4
- [![Code Climate](https://codeclimate.com/github/fnando/notifier/badges/gpa.svg)](https://codeclimate.com/github/fnando/notifier)
5
- [![Test Coverage](https://codeclimate.com/github/fnando/notifier/badges/coverage.svg)](https://codeclimate.com/github/fnando/notifier/coverage)
6
3
  [![Gem](https://img.shields.io/gem/v/notifier.svg)](https://rubygems.org/gems/notifier)
7
4
  [![Gem](https://img.shields.io/gem/dt/notifier.svg)](https://rubygems.org/gems/notifier)
8
5
 
9
- Send system notifications on several platforms with a simple and unified API. Currently supports:
6
+ Send system notifications on several platforms with a simple and unified API.
7
+ Currently supports:
10
8
 
11
- * Growl (Mac OS X)
12
- * terminal-notifier (Notification Center wrapper for Mac OS X)
13
- * GNTP Protocol (Growl, with Vagrant support)
14
- * Kdialog (Linux/KDE)
15
- * Knotify (Linux/KDE)
16
- * OSD Cat (Linux)
17
- * Libnotify (Linux)
18
- * Snarl (Windows)
9
+ - terminal-notifier (Notification Center wrapper for Mac OS X)
10
+ - GNTP Protocol (Growl, with Vagrant support)
11
+ - Kdialog (Linux/KDE)
12
+ - Knotify (Linux/KDE)
13
+ - OSD Cat (Linux)
14
+ - Libnotify (Linux)
15
+ - Snarl (Windows)
19
16
 
20
17
  ## Installation
21
18
 
@@ -23,20 +20,14 @@ Send system notifications on several platforms with a simple and unified API. Cu
23
20
 
24
21
  ### Mac OS X
25
22
 
26
- #### Growl
27
-
28
- * Install Growl - http://growl.info/
29
- * Install the growlnotify script located on the "Extras" directory
30
- * Open the Growl Preference Panel (System > Growl) and activate "Listen for incoming notifications" and "Allow remote application registration" options on the Network tab.
31
-
32
23
  #### terminal-notifier
33
24
 
34
- * Install terminal-notifier - https://github.com/alloy/terminal-notifier
25
+ - Install terminal-notifier - https://github.com/alloy/terminal-notifier
35
26
 
36
27
  terminal-notifier also supports two additional flags:
37
28
 
38
- * `subtitle`
39
- * `sound`
29
+ - `subtitle`
30
+ - `sound`
40
31
 
41
32
  See terminal-notifier's help for additional information.
42
33
 
@@ -44,18 +35,21 @@ See terminal-notifier's help for additional information.
44
35
 
45
36
  If you're a linux guy, you can choose one of these methods:
46
37
 
47
- * Install libnotify-bin and its dependencies: `sudo aptitude install libnotify-bin`
48
- * Install xosd-bin: `sudo aptitude install xosd-bin`
49
- * KDE users don't need to install anything: Test Notifier will use +knotify+ or +kdialog+.
38
+ - Install libnotify-bin and its dependencies:
39
+ `sudo aptitude install libnotify-bin`
40
+ - Install xosd-bin: `sudo aptitude install xosd-bin`
41
+ - KDE users don't need to install anything: Test Notifier will use +knotify+ or
42
+ +kdialog+.
50
43
 
51
44
  ### Windows
52
45
 
53
- * Install Snarl: download from http://www.fullphat.net
54
- * Install ruby-snarl: `gem install ruby-snarl`
46
+ - Install Snarl: download from http://www.fullphat.net
47
+ - Install ruby-snarl: `gem install ruby-snarl`
55
48
 
56
49
  ## Usage
57
50
 
58
- Notifier will try to detect which notifiers are available in your system. So you can just send a message:
51
+ Notifier will try to detect which notifiers are available in your system. So you
52
+ can just send a message:
59
53
 
60
54
  ```ruby
61
55
  Notifier.notify(
@@ -67,25 +61,30 @@ Notifier.notify(
67
61
 
68
62
  Not all notifiers support the image option, therefore it will be ignored.
69
63
 
70
- If your system support more than one notifier, you can specify which one you prefer:
64
+ If your system support more than one notifier, you can specify which one you
65
+ prefer:
71
66
 
72
67
  ```ruby
73
68
  Notifier.default_notifier = :notify_send
74
69
  ```
75
70
 
76
- The available names are `growl`, `terminal_notifier`, `kdialog`, `knotify`, `notify_send`, `osd_cat`, and `snarl`.
71
+ The available names are `terminal_notifier`, `kdialog`, `knotify`,
72
+ `notify_send`, `osd_cat`, and `snarl`.
77
73
 
78
- There are several helper methods that you can use in order to retrieve notifiers.
74
+ There are several helper methods that you can use in order to retrieve
75
+ notifiers.
79
76
 
80
- * `Notifier.notifier`: return the first supported notifier
81
- * `Notifier.notifiers`: return all notifiers
82
- * `Notifier.supported_notifiers`: return only supported notifiers
83
- * `Notifier.from_name(name)`: find notifier by its name
84
- * `Notifier.supported_notifier_from_name(name)`: find a supported notifier by its name
77
+ - `Notifier.notifier`: return the first supported notifier
78
+ - `Notifier.notifiers`: return all notifiers
79
+ - `Notifier.supported_notifiers`: return only supported notifiers
80
+ - `Notifier.from_name(name)`: find notifier by its name
81
+ - `Notifier.supported_notifier_from_name(name)`: find a supported notifier by
82
+ its name
85
83
 
86
84
  ## Creating custom notifiers
87
85
 
88
- To create a new notifier, just create a module on `Notifier` namespace that implements the following interface:
86
+ To create a new notifier, just create a module on `Notifier` namespace that
87
+ implements the following interface:
89
88
 
90
89
  ```ruby
91
90
  module Notifier
@@ -101,7 +100,7 @@ end
101
100
 
102
101
  ## Maintainer
103
102
 
104
- * Nando Vieira - http://nandovieira.com
103
+ - Nando Vieira - https://nandovieira.com
105
104
 
106
105
  ## Contributors
107
106
 
@@ -111,21 +110,19 @@ https://github.com/fnando/notifier/graphs/contributors
111
110
 
112
111
  (The MIT License)
113
112
 
114
- Permission is hereby granted, free of charge, to any person obtaining
115
- a copy of this software and associated documentation files (the
116
- 'Software'), to deal in the Software without restriction, including
117
- without limitation the rights to use, copy, modify, merge, publish,
118
- distribute, sublicense, and/or sell copies of the Software, and to
119
- permit persons to whom the Software is furnished to do so, subject to
120
- the following conditions:
121
-
122
- The above copyright notice and this permission notice shall be
123
- included in all copies or substantial portions of the Software.
124
-
125
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
126
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
127
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
128
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
129
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
130
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
131
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
113
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
114
+ this software and associated documentation files (the 'Software'), to deal in
115
+ the Software without restriction, including without limitation the rights to
116
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
117
+ the Software, and to permit persons to whom the Software is furnished to do so,
118
+ subject to the following conditions:
119
+
120
+ The above copyright notice and this permission notice shall be included in all
121
+ copies or substantial portions of the Software.
122
+
123
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
124
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
125
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
126
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
127
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
128
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
5
+ require "rubocop/rake_task"
3
6
 
4
7
  Rake::TestTask.new(:test) do |t|
5
8
  t.libs << "test"
@@ -7,4 +10,6 @@ Rake::TestTask.new(:test) do |t|
7
10
  t.warning = false
8
11
  end
9
12
 
10
- task default: :test
13
+ RuboCop::RakeTask.new
14
+
15
+ task default: %i[test rubocop]
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module Kdialog
3
5
  extend self
4
6
 
5
7
  def supported?
6
- Notifier.os?(/(linux|freebsd)/) && `which kdialog > /dev/null` && $? == 0
8
+ Notifier.os?(/(linux|freebsd)/) &&
9
+ `which kdialog > /dev/null` &&
10
+ $CHILD_STATUS == 0
7
11
  end
8
12
 
9
13
  def notify(options)
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module Knotify
3
5
  extend self
4
6
 
5
7
  def supported?
6
- Notifier.os?(/(linux|freebsd)/) && `ps -Al | grep dcop` && $? == 0
8
+ Notifier.os?(/(linux|freebsd)/) &&
9
+ `ps -Al | grep dcop` &&
10
+ $CHILD_STATUS == 0
7
11
  end
8
12
 
9
13
  def notify(options)
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module NotifySend
3
5
  extend self
4
6
 
5
7
  def supported?
6
- Notifier.os?(/(linux|freebsd)/) && `which notify-send > /dev/null` && $? == 0
8
+ Notifier.os?(/(linux|freebsd)/) &&
9
+ `which notify-send > /dev/null` &&
10
+ $CHILD_STATUS == 0
7
11
  end
8
12
 
9
13
  def notify(options)
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module OsdCat
3
5
  extend self
4
6
 
5
7
  def supported?
6
- Notifier.os?(/(linux|freebsd)/) && `which osd_cat > /dev/null` && $? == 0
8
+ Notifier.os?(/(linux|freebsd)/) &&
9
+ `which osd_cat > /dev/null` &&
10
+ $CHILD_STATUS == 0
7
11
  end
8
12
 
9
13
  def notify(options)
@@ -18,11 +22,11 @@ module Notifier
18
22
  "--align", "center",
19
23
  "--font", "-bitstream-bitstream charter-bold-r-*-*-*-350-*-*-*-*-*-*",
20
24
  "--delay", "5",
21
- "--outline", "4",
25
+ "--outline", "4"
22
26
  ]
23
27
 
24
28
  Thread.new do
25
- Open3.popen3(*command) do |stdin, stdout, stderr|
29
+ Open3.popen3(*command) do |stdin, _stdout, _stderr|
26
30
  stdin.puts options[:message]
27
31
  stdin.close
28
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module Placebo
3
5
  extend self
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module Snarl
3
5
  extend self
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module TerminalNotifier
3
5
  extend self
4
6
 
5
7
  def supported?
6
- Notifier.os?(/darwin/) && `which terminal-notifier` && $? == 0
8
+ Notifier.os?(/darwin/) && `which terminal-notifier` && $CHILD_STATUS == 0
7
9
  end
8
10
 
9
11
  def notify(options)
@@ -18,9 +20,18 @@ module Notifier
18
20
 
19
21
  # -sound with an empty string (e.g., "") will trigger the
20
22
  # default sound so we need to check for it.
21
- command.concat(["-sound", options.fetch(:sound, "default").to_s] ) if options[:sound]
23
+ if options[:sound]
24
+ command.concat([
25
+ "-sound",
26
+ options.fetch(:sound, "default").to_s
27
+ ])
28
+ end
22
29
 
23
- Thread.new { system(*command) }.join
30
+ Thread.new do
31
+ Open3.popen3(*command) do |_stdin, _stdout, _stderr|
32
+ # noop
33
+ end
34
+ end.join
24
35
  end
25
36
  end
26
37
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Notifier
2
4
  module Version
3
- MAJOR = 0
4
- MINOR = 5
5
- PATCH = 2
5
+ MAJOR = 1
6
+ MINOR = 0
7
+ PATCH = 0
6
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
9
  end
8
10
  end
data/lib/notifier.rb CHANGED
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "open3"
2
4
  require "socket"
3
5
  require "digest/md5"
4
6
  require "timeout"
5
7
  require "rbconfig"
8
+ require "English"
6
9
 
7
10
  module Notifier
8
- require "notifier/growl"
9
- require "notifier/gntp"
10
11
  require "notifier/snarl"
11
12
  require "notifier/osd_cat"
12
13
  require "notifier/knotify"
@@ -15,7 +16,6 @@ module Notifier
15
16
  require "notifier/placebo"
16
17
  require "notifier/terminal_notifier"
17
18
  require "notifier/version"
18
- require "notifier/adapters"
19
19
 
20
20
  extend self
21
21
 
@@ -23,6 +23,10 @@ module Notifier
23
23
  attr_accessor :default_notifier
24
24
  end
25
25
 
26
+ def skip_constants
27
+ @skip_constants ||= %w[Placebo Adapters Version]
28
+ end
29
+
26
30
  def notifier
27
31
  supported_notifier_from_name(default_notifier) || supported_notifiers.first
28
32
  end
@@ -32,34 +36,32 @@ module Notifier
32
36
  end
33
37
 
34
38
  def notifiers
35
- constants.map do |name|
36
- const_get(name) unless %w[Placebo Adapters Version].include?(name.to_s)
37
- end.compact + [Placebo]
39
+ constants.filter_map do |name|
40
+ const_get(name) unless skip_constants.include?(name.to_s)
41
+ end + [Placebo]
38
42
  end
39
43
 
40
44
  def supported_notifiers
41
- notifiers.select {|notifier| notifier.supported? }
45
+ notifiers.select(&:supported?)
42
46
  end
43
47
 
44
48
  def from_name(name)
45
49
  const_get(classify(name.to_s))
46
- rescue Exception
50
+ rescue StandardError
47
51
  nil
48
52
  end
49
53
 
50
54
  def supported_notifier_from_name(name)
51
55
  notifier = from_name(name)
52
- notifier && notifier.supported? ? notifier : nil
56
+ notifier&.supported? ? notifier : nil
53
57
  end
54
58
 
55
59
  def os?(regex)
56
60
  RUBY_PLATFORM =~ regex || RbConfig::CONFIG["host_os"] =~ regex
57
61
  end
58
62
 
59
- private
60
-
61
- def classify(string)
62
- string.gsub(/_(.)/sm) { "#{$1.upcase}" }
63
- .gsub(/^(.)/) { "#{$1.upcase}" }
63
+ private def classify(string)
64
+ string.gsub(/_(.)/sm) { Regexp.last_match(1).upcase.to_s }
65
+ .gsub(/^(.)/) { Regexp.last_match(1).upcase.to_s }
64
66
  end
65
67
  end
data/notifier.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "./lib/notifier/version"
2
4
 
3
5
  Gem::Specification.new do |s|
@@ -5,20 +7,29 @@ Gem::Specification.new do |s|
5
7
  s.version = Notifier::Version::STRING
6
8
  s.platform = Gem::Platform::RUBY
7
9
  s.authors = ["Nando Vieira"]
8
- s.email = ["fnando.vieira@gmail.com"]
10
+ s.email = ["me@fnando.com"]
9
11
  s.homepage = "http://rubygems.org/gems/notifier"
10
- s.summary = "Send system notifications on several platforms with a simple and unified API. Currently supports Growl, Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl"
12
+ s.summary = "Send system notifications on several platforms with a " \
13
+ "simple and unified API. Currently supports Libnotify, " \
14
+ "OSD, KDE (Knotify and Kdialog) and Snarl"
11
15
  s.description = s.summary
16
+ s.required_ruby_version = ">= 2.7"
17
+ s.metadata["rubygems_mfa_required"] = "true"
12
18
 
13
19
  s.files = `git ls-files`.split("\n")
14
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
22
+ File.basename(f)
23
+ end
16
24
  s.require_paths = ["lib"]
17
25
 
18
- s.requirements << "Growl, terminal-notifier, Libnotify, OSD, KDE (Knotify and Kdialog) or Snarl"
26
+ s.requirements << "terminal-notifier, Libnotify, OSD, KDE (Knotify and " \
27
+ "Kdialog) or Snarl"
19
28
 
20
29
  s.add_development_dependency "minitest-utils"
21
- s.add_development_dependency "rake"
22
30
  s.add_development_dependency "mocha"
23
- s.add_development_dependency "codeclimate-test-reporter"
31
+ s.add_development_dependency "rake"
32
+ s.add_development_dependency "rubocop"
33
+ s.add_development_dependency "rubocop-fnando"
34
+ s.add_development_dependency "simplecov"
24
35
  end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class NotifierTest < Minitest::Test
4
6
  setup do
5
7
  Notifier.notifiers.each do |notifier|
6
- notifier.stubs(:supported?).returns(false) unless notifier == Notifier::Placebo
8
+ unless notifier == Notifier::Placebo
9
+ notifier.stubs(:supported?).returns(false)
10
+ end
7
11
  end
8
12
 
9
13
  Notifier.default_notifier = nil
@@ -46,7 +50,7 @@ class NotifierTest < Minitest::Test
46
50
  end
47
51
 
48
52
  test "retrieves list of all notifiers" do
49
- assert_equal 9, Notifier.notifiers.size
53
+ assert_equal 7, Notifier.notifiers.size
50
54
  end
51
55
 
52
56
  test "considers Placebo as fallback notifier" do
@@ -56,7 +60,6 @@ class NotifierTest < Minitest::Test
56
60
  test "returns notifier by its name" do
57
61
  assert_equal Notifier::OsdCat, Notifier.from_name(:osd_cat)
58
62
  assert_equal Notifier::NotifySend, Notifier.from_name(:notify_send)
59
- assert_equal Notifier::Growl, Notifier.from_name(:growl)
60
63
  end
61
64
 
62
65
  test "returns notifier by its name when supported" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class SnarlTest < Minitest::Test
data/test/test_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+ SimpleCov.start
3
5
 
4
6
  require "bundler/setup"
5
7
  require "notifier"
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: 0.5.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2022-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-utils
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mocha
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: mocha
56
+ name: rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,21 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: codeclimate-test-reporter
70
+ name: rubocop-fnando
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -67,23 +95,20 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  description: Send system notifications on several platforms with a simple and unified
70
- API. Currently supports Growl, Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
98
+ API. Currently supports Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
71
99
  email:
72
- - fnando.vieira@gmail.com
100
+ - me@fnando.com
73
101
  executables: []
74
102
  extensions: []
75
103
  extra_rdoc_files: []
76
104
  files:
77
105
  - ".gitignore"
78
- - ".travis.yml"
106
+ - ".rubocop.yml"
79
107
  - Gemfile
108
+ - LICENSE.md
80
109
  - README.md
81
110
  - Rakefile
82
111
  - lib/notifier.rb
83
- - lib/notifier/adapters.rb
84
- - lib/notifier/adapters/gntp.rb
85
- - lib/notifier/gntp.rb
86
- - lib/notifier/growl.rb
87
112
  - lib/notifier/kdialog.rb
88
113
  - lib/notifier/knotify.rb
89
114
  - lib/notifier/notify_send.rb
@@ -93,14 +118,14 @@ files:
93
118
  - lib/notifier/terminal_notifier.rb
94
119
  - lib/notifier/version.rb
95
120
  - notifier.gemspec
96
- - resources/register-growl.scpt
97
121
  - test/notifier/notifier_test.rb
98
122
  - test/notifier/snarl_test.rb
99
123
  - test/test_helper.rb
100
124
  homepage: http://rubygems.org/gems/notifier
101
125
  licenses: []
102
- metadata: {}
103
- post_install_message:
126
+ metadata:
127
+ rubygems_mfa_required: 'true'
128
+ post_install_message:
104
129
  rdoc_options: []
105
130
  require_paths:
106
131
  - lib
@@ -108,20 +133,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
133
  requirements:
109
134
  - - ">="
110
135
  - !ruby/object:Gem::Version
111
- version: '0'
136
+ version: '2.7'
112
137
  required_rubygems_version: !ruby/object:Gem::Requirement
113
138
  requirements:
114
139
  - - ">="
115
140
  - !ruby/object:Gem::Version
116
141
  version: '0'
117
142
  requirements:
118
- - Growl, terminal-notifier, Libnotify, OSD, KDE (Knotify and Kdialog) or Snarl
119
- rubyforge_project:
120
- rubygems_version: 2.5.1
121
- signing_key:
143
+ - terminal-notifier, Libnotify, OSD, KDE (Knotify and Kdialog) or Snarl
144
+ rubygems_version: 3.3.7
145
+ signing_key:
122
146
  specification_version: 4
123
147
  summary: Send system notifications on several platforms with a simple and unified
124
- API. Currently supports Growl, Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
148
+ API. Currently supports Libnotify, OSD, KDE (Knotify and Kdialog) and Snarl
125
149
  test_files:
126
150
  - test/notifier/notifier_test.rb
127
151
  - test/notifier/snarl_test.rb
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- notifications:
5
- email: false
6
- rvm:
7
- - 2.3.0
8
- - '2.2'
9
- - '2.1'
10
- env:
11
- global:
12
- secure: mYd3r1SEZJcirOFNjNe75vMNjYJ/UHDLZAsEeCQQcI4Na03au53Pr02waJKPdXXV8JnakaYMDNBc4kOXnk3v0ytgINnvNXnObjPT2KUPvQKLUhXq2Q/BrWS4CFihihznZHAQFgeTVbDm/brLWH61+JwDlQ2kEo6OGSAZ8ZV/PV8=
@@ -1,87 +0,0 @@
1
- module Notifier
2
- module Adapters
3
- class GNTP
4
- attr_accessor :application_name
5
- attr_accessor :host
6
- attr_accessor :port
7
- attr_accessor :password
8
-
9
- def initialize(options = {})
10
- if options.kind_of?(String)
11
- options = {name: options}
12
- end
13
-
14
- @application_name = options.fetch(:name, "GNTP/Ruby")
15
- @host = options.fetch(:host, "127.0.0.1")
16
- @port = options.fetch(:port, 23053)
17
- @password = options.fetch(:password, nil)
18
- end
19
-
20
- def line_break(number = 1)
21
- "\r\n" * number
22
- end
23
-
24
- def write(*contents)
25
- contents.map! do |content|
26
- content.force_encoding("utf-8") rescue content
27
- end
28
-
29
- socket = TCPSocket.open(host, port)
30
- message = [*contents, line_break(2)].join(line_break)
31
- socket.write(message)
32
-
33
- "".tap do |response|
34
- while chunk = socket.gets
35
- break if chunk == line_break
36
- response << chunk
37
- end
38
-
39
- socket.close
40
- end
41
- end
42
-
43
- def notify(options)
44
- name = options.fetch(:name, "notification")
45
- register(name)
46
-
47
- icon = fetch_icon(options[:icon])
48
-
49
- write "GNTP/1.0 NOTIFY NONE",
50
- "Application-Name: #{application_name}",
51
- "Notification-Name: #{name}",
52
- "Notification-Title: #{options[:title]}",
53
- "Notification-Text: #{options[:message]}",
54
- "Notification-Icon: x-growl-resource://#{icon[:identifier]}",
55
- "Notification-Sticky: #{bool options[:sticky]}",
56
- nil,
57
- "Identifier: #{icon[:identifier]}",
58
- "Length: #{icon[:size]}",
59
- nil,
60
- icon[:contents]
61
- end
62
-
63
- def fetch_icon(path)
64
- contents = File.open(path, "rb") {|f| f.read }
65
-
66
- {
67
- identifier: Digest::MD5.hexdigest(contents),
68
- contents: contents,
69
- size: contents.bytesize
70
- }
71
- end
72
-
73
- def bool(boolean)
74
- {true => "Yes", false => "No"}[boolean]
75
- end
76
-
77
- def register(name)
78
- write "GNTP/1.0 REGISTER NONE",
79
- "Application-Name: #{application_name}",
80
- "Notifications-count: 1",
81
- nil,
82
- "Notification-Name: #{name}",
83
- "Notification-Enabled: True"
84
- end
85
- end
86
- end
87
- end
@@ -1,5 +0,0 @@
1
- module Notifier
2
- module Adapters
3
- require "notifier/adapters/gntp"
4
- end
5
- end
data/lib/notifier/gntp.rb DELETED
@@ -1,37 +0,0 @@
1
- module Notifier
2
- module GNTP extend self
3
- def supported?
4
- Timeout.timeout(1) { TCPSocket.new(host, port).close }
5
- true
6
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Timeout::Error
7
- false
8
- end
9
-
10
- def port
11
- ENV.fetch("GNTP_PORT", 23053)
12
- end
13
-
14
- def host
15
- ENV["GNTP_HOST"] || ssh_connection || "127.0.0.1"
16
- end
17
-
18
- def ssh_connection
19
- ENV["SSH_CONNECTION"][/^([^ ]+)/, 1] if ENV["SSH_CONNECTION"]
20
- end
21
-
22
- def notify(options)
23
- gntp = Adapters::GNTP.new({
24
- name: "test_notifier",
25
- host: host,
26
- port: port
27
- })
28
-
29
- gntp.notify({
30
- name: "status",
31
- title: options[:title],
32
- message: options[:message],
33
- icon: options[:image]
34
- })
35
- end
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- module Notifier
2
- module Growl
3
- extend self
4
-
5
- SCRIPT = File.dirname(__FILE__) + "/../../resources/register-growl.scpt"
6
- FILE = File.expand_path("~/.test_notifier-growl")
7
-
8
- def supported?
9
- Notifier.os?(/darwin/) && `which growlnotify` && $? == 0
10
- end
11
-
12
- def notify(options)
13
- register
14
- command = [
15
- "growlnotify",
16
- "--name", "test_notifier",
17
- "--image", options.fetch(:image, "").to_s,
18
- "--priority", "2",
19
- "--message", options[:message].to_s,
20
- options[:title].to_s
21
- ]
22
-
23
- Thread.new { system(*command) }.join
24
- end
25
-
26
- def register
27
- return if File.file?(FILE)
28
- system "osascript #{SCRIPT} > #{FILE}"
29
- end
30
- end
31
- end
Binary file