terminal-notifier-guard 1.6.0 → 1.6.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
  SHA1:
3
- metadata.gz: d8cef1ebe06e3689a8a28f0e9b1d1961f8a55043
4
- data.tar.gz: 4fd5e78f3d7e0b3a36873f24a9cdb97f3d65fa47
3
+ metadata.gz: 8ae13fa13ff54e5b948035e9c41e0fd5b5bda057
4
+ data.tar.gz: f5dbeb151daa73937ad14d38ddbeab8b1b5c9fa2
5
5
  SHA512:
6
- metadata.gz: 9501b1a9843391d89f89a49ac5ae56124d88e45f74b364d9c37f9ead3b124d6b6688e9bb74dc8e157c98bc2093e7b06603004359f3e0cf799214af9f42d1e53f
7
- data.tar.gz: 33e42c534864e955825030f855674e31aefcc0425ba29e607415eeed708ecfcc2d396ed99be25e9b7c7068e3793c4132b16bbd324ef3e46a4255b9d451acfdf3
6
+ metadata.gz: 553858a9ab227318be15aac89fc178b030dfd10a651a1f0776f49d2d042abb4605c82879746242e445b88a503f80e653d79d052b5c8746f8d6d261e2d5a995f2
7
+ data.tar.gz: ce7341119a38f58b9e8f10e2f0c3f0021799ad5218acc8b8683a09886aa99bab2948c4034f91af190edf9c1cbfdf4d8ce4a59a0dce5250b737ca4c650c9ab0b9
@@ -4,7 +4,7 @@ A simple Ruby wrapper around the [`terminal-notifier`][HOMEPAGE] command-line
4
4
  tool, which allows you to send User Notifications to the Notification Center on
5
5
  Mac OS X 10.8, or higher.
6
6
 
7
- This version has 4 different `terminal-notifiers` included for each status that
7
+ This version has 4 different icons included for each status that
8
8
  [Guard][GUARD] supports:
9
9
 
10
10
  1. Failed
@@ -12,8 +12,6 @@ This version has 4 different `terminal-notifiers` included for each status that
12
12
  3. Pending
13
13
  4. Success
14
14
 
15
- And each one with their own icon representing it's status.
16
-
17
15
 
18
16
  ## Installation
19
17
 
@@ -21,10 +19,15 @@ And each one with their own icon representing it's status.
21
19
  $ gem install terminal-notifier-guard
22
20
  ```
23
21
 
22
+ ### OSX 10.8 users
23
+
24
+ As of version `1.6.1`, we no longer bundle notifiers binaries in this gem. Please revert to
25
+ version `1.5.3` for OSX 10.8 support.
26
+
24
27
 
25
28
  ## Usage
26
29
 
27
- For full information on all the options, see the tool’s [README][README].
30
+ You could also use the notifier directly.
28
31
 
29
32
  Examples are:
30
33
 
@@ -55,5 +58,11 @@ See [LICENSE][LICENSE] for details.
55
58
 
56
59
  [HOMEPAGE]: https://github.com/Springest/terminal-notifier-guard
57
60
  [GUARD]: https://github.com/guard/guard
58
- [README]: https://github.com/Springest/terminal-notifier-guard/blob/master/README.markdown
59
61
  [LICENSE]: https://github.com/Springest/terminal-notifier-guard/blob/master/Ruby/LICENSE
62
+
63
+
64
+ ## Contributors & Thanks to
65
+
66
+ - @alloy (For the terminal-notifier)
67
+ - @railsme (For a clean way to test for OSX version #15)
68
+ - @jamilbx (For support for local terminal-notifier command #8)
@@ -1,38 +1,40 @@
1
- %w(failed notify pending success).each do |type|
2
- require File.expand_path("../terminal_notifier/guard/#{type}", __FILE__)
3
- end
4
-
5
1
  module TerminalNotifier
6
2
  module Guard
7
- include TerminalNotifier::Guard::Notify
8
- include TerminalNotifier::Guard::Success
9
- include TerminalNotifier::Guard::Failed
10
- include TerminalNotifier::Guard::Pending
3
+ VERSION = "1.6.1"
4
+ BIN_PATH = "/usr/local/Cellar/terminal-notifier/1.6.1/terminal-notifier.app/Contents/MacOS/terminal-notifier"
5
+ ICONS_PATH = File.expand_path("../../icons", __FILE__)
6
+ GUARD_ICON = File.join(ICONS_PATH, 'guard.png')
7
+
8
+ def self.osx_version
9
+ Gem::Version.new(`sw_vers -productVersion`.strip)
10
+ end
11
+
12
+ def self.deprecation_check
13
+ if osx_version <= Gem::Version.new('10.8')
14
+ raise "OSX 10.8 is no longer supported by this gem. Please revert to version <= 1.5.3."
15
+ end
16
+ end
11
17
 
12
18
  # Returns wether or not the current platform is Mac OS X 10.8, or higher.
13
19
  def self.available?
20
+ deprecation_check
14
21
  if @available.nil?
15
22
  @available = `uname`.strip == 'Darwin' &&
16
- Gem::Version.new(`sw_vers -productVersion`.strip) >= Gem::Version.new('10.8')
23
+ osx_version >= Gem::Version.new('10.9')
17
24
  end
18
25
  @available
19
26
  end
20
27
 
28
+ # Whether or not the terminal notifier is installed
29
+ def self.installed?
30
+ return true if File.exist? BIN_PATH
31
+ end
32
+
21
33
  def self.execute(verbose, options)
22
- if available?
23
- case options[:type]
24
- when :failed
25
- bin_path = TerminalNotifier::Guard::Failed::BIN_PATH
26
- when :success
27
- bin_path = TerminalNotifier::Guard::Success::BIN_PATH
28
- when :pending
29
- bin_path = TerminalNotifier::Guard::Pending::BIN_PATH
30
- else
31
- bin_path = TerminalNotifier::Guard::Notify::BIN_PATH
32
- end
33
- options.delete(:type) if options[:type]
34
+ if available? && installed?
35
+ options.merge!({ :appIcon => GUARD_ICON, :contentImage => icon(options.delete(:type)) })
34
36
 
35
- command = [bin_path, *options.map { |k,v| ["-#{k}", v.to_s] }.flatten]
37
+ command = [BIN_PATH, *options.map { |k,v| ["-#{k}", v.to_s] }.flatten]
36
38
  if RUBY_VERSION < '1.9'
37
39
  require 'shellwords'
38
40
  command = Shellwords.shelljoin(command)
@@ -45,7 +47,8 @@ module TerminalNotifier
45
47
  end
46
48
  result
47
49
  else
48
- raise "terminal-notifier is only supported on Mac OS X 10.8, or higher."
50
+ raise "terminal-notifier is only supported on Mac OS X 10.8, or higher." if !available?
51
+ raise "TerminalNotifier not installed. Please do so by running `brew install terminal-notifier`" if !installed?
49
52
  end
50
53
  end
51
54
 
@@ -58,12 +61,12 @@ module TerminalNotifier
58
61
  #
59
62
  # Examples are:
60
63
  #
61
- # TerminalNotifier.notify('Hello World')
62
- # TerminalNotifier.notify('Hello World', :title => 'Ruby')
63
- # TerminalNotifier.notify('Hello World', :group => Process.pid)
64
- # TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
65
- # TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
66
- # TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
64
+ # TerminalNotifier::Guard.notify('Hello World')
65
+ # TerminalNotifier::Guard.notify('Hello World', :title => 'Ruby')
66
+ # TerminalNotifier::Guard.notify('Hello World', :group => Process.pid)
67
+ # TerminalNotifier::Guard.notify('Hello World', :activate => 'com.apple.Safari')
68
+ # TerminalNotifier::Guard.notify('Hello World', :open => 'http://twitter.com/alloy')
69
+ # TerminalNotifier::Guard.notify('Hello World', :execute => 'say "OMG"')
67
70
  #
68
71
  # Raises if not supported on the current platform.
69
72
  def notify(message, options = {}, verbose = false)
@@ -90,6 +93,13 @@ module TerminalNotifier
90
93
  end
91
94
  module_function :success
92
95
 
96
+ def icon(type = :notify)
97
+ type ||= :notify
98
+ file_name = "#{type}.icns".capitalize
99
+ File.join(ICONS_PATH, file_name)
100
+ end
101
+ module_function :icon
102
+
93
103
  # Removes a notification that was previously sent with the specified
94
104
  # ‘group’ ID, if one exists.
95
105
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-notifier-guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-22 00:00:00.000000000 Z
12
+ date: 2014-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -67,42 +67,16 @@ dependencies:
67
67
  - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: terminal-notifier
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
70
  description:
85
71
  email:
86
72
  - wouter@springest.com
87
- executables:
88
- - terminal-notifier-notify
89
- - terminal-notifier-success
90
- - terminal-notifier-failed
91
- - terminal-notifier-pending
73
+ executables: []
92
74
  extensions: []
93
75
  extra_rdoc_files:
94
76
  - README.markdown
95
77
  files:
96
78
  - README.markdown
97
- - bin/terminal-notifier-failed
98
- - bin/terminal-notifier-notify
99
- - bin/terminal-notifier-pending
100
- - bin/terminal-notifier-success
101
79
  - lib/terminal-notifier-guard.rb
102
- - lib/terminal_notifier/guard/failed.rb
103
- - lib/terminal_notifier/guard/notify.rb
104
- - lib/terminal_notifier/guard/pending.rb
105
- - lib/terminal_notifier/guard/success.rb
106
80
  homepage: https://github.com/Springest/terminal-notifier-guard
107
81
  licenses: []
108
82
  metadata: {}
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- if $0 == __FILE__
4
- $:.unshift File.expand_path('../../lib', __FILE__)
5
- end
6
-
7
- require 'terminal-notifier-guard'
8
-
9
- exec TerminalNotifier::Guard::Failed::BIN_PATH, *ARGV
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- if $0 == __FILE__
4
- $:.unshift File.expand_path('../../lib', __FILE__)
5
- end
6
-
7
- require 'terminal-notifier-guard'
8
-
9
- exec TerminalNotifier::Guard::Notify::BIN_PATH, *ARGV
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- if $0 == __FILE__
4
- $:.unshift File.expand_path('../../lib', __FILE__)
5
- end
6
-
7
- require 'terminal-notifier-guard'
8
-
9
- exec TerminalNotifier::Guard::Pending::BIN_PATH, *ARGV
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- if $0 == __FILE__
4
- $:.unshift File.expand_path('../../lib', __FILE__)
5
- end
6
-
7
- require 'terminal-notifier-guard'
8
-
9
- exec TerminalNotifier::Guard::Success::BIN_PATH, *ARGV
@@ -1,12 +0,0 @@
1
- module TerminalNotifier
2
- module Guard
3
- module Failed
4
- terminal_notifier_path = `which terminal-notifier`.strip
5
-
6
- BIN_PATH = terminal_notifier_path.empty? ?
7
- File.expand_path('../../../../vendor/terminal-notifier-failed.app/Contents/MacOS/terminal-notifier', __FILE__)
8
- :
9
- terminal_notifier_path
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module TerminalNotifier
2
- module Guard
3
- module Notify
4
- terminal_notifier_path = `which terminal-notifier`.strip
5
-
6
- BIN_PATH = terminal_notifier_path.empty? ?
7
- File.expand_path('../../../../vendor/terminal-notifier-notify.app/Contents/MacOS/terminal-notifier', __FILE__)
8
- :
9
- terminal_notifier_path
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module TerminalNotifier
2
- module Guard
3
- module Pending
4
- terminal_notifier_path = `which terminal-notifier`.strip
5
-
6
- BIN_PATH = terminal_notifier_path.empty? ?
7
- File.expand_path('../../../../vendor/terminal-notifier-pending.app/Contents/MacOS/terminal-notifier', __FILE__)
8
- :
9
- terminal_notifier_path
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module TerminalNotifier
2
- module Guard
3
- module Success
4
- terminal_notifier_path = `which terminal-notifier`.strip
5
-
6
- BIN_PATH = terminal_notifier_path.empty? ?
7
- File.expand_path('../../../../vendor/terminal-notifier-success.app/Contents/MacOS/terminal-notifier', __FILE__)
8
- :
9
- terminal_notifier_path
10
- end
11
- end
12
- end