terminal-notifier 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -2
- data/bin/terminal-notifier +1 -1
- data/lib/terminal-notifier.rb +44 -28
- data/vendor/terminal-notifier/README.markdown +18 -3
- data/vendor/terminal-notifier/terminal-notifier.app/Contents/Info.plist +2 -2
- data/vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier +0 -0
- metadata +4 -4
data/README.markdown
CHANGED
@@ -20,12 +20,16 @@ Examples are:
|
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
TerminalNotifier.notify('Hello World')
|
23
|
-
TerminalNotifier.notify('Hello World', :title => 'Ruby')
|
23
|
+
TerminalNotifier.notify('Hello World', :title => 'Ruby', :subtitle => 'Programming Language')
|
24
24
|
TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
|
25
25
|
TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
|
26
26
|
TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
|
27
27
|
TerminalNotifier.notify('Hello World', :group => Process.pid)
|
28
|
-
|
28
|
+
|
29
|
+
TerminalNotifier.remove(Process.pid)
|
30
|
+
|
31
|
+
TerminalNotifier.list(Process.pid)
|
32
|
+
TerminalNotifier.list
|
29
33
|
```
|
30
34
|
|
31
35
|
|
data/bin/terminal-notifier
CHANGED
data/lib/terminal-notifier.rb
CHANGED
@@ -9,21 +9,20 @@ module TerminalNotifier
|
|
9
9
|
@available
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
13
|
-
stdout = STDOUT.clone
|
14
|
-
STDOUT.reopen(File.new('/dev/null', 'w'))
|
15
|
-
yield
|
16
|
-
ensure
|
17
|
-
STDOUT.reopen(stdout)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.execute_with_options(options)
|
21
|
-
execute(options.map { |k,v| ["-#{k}", v.to_s] }.flatten)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.execute(argv)
|
12
|
+
def self.execute(verbose, options)
|
25
13
|
if available?
|
26
|
-
|
14
|
+
command = [BIN_PATH, *options.map { |k,v| ["-#{k}", v.to_s] }.flatten]
|
15
|
+
if RUBY_VERSION < '1.9'
|
16
|
+
require 'shellwords'
|
17
|
+
command = Shellwords.shelljoin(command)
|
18
|
+
end
|
19
|
+
result = ''
|
20
|
+
IO.popen(*command) do |stdout|
|
21
|
+
output = stdout.read
|
22
|
+
STDOUT.print output if verbose
|
23
|
+
result << output
|
24
|
+
end
|
25
|
+
result
|
27
26
|
else
|
28
27
|
raise "terminal-notifier is only supported on Mac OS X 10.8, or higher."
|
29
28
|
end
|
@@ -46,27 +45,44 @@ module TerminalNotifier
|
|
46
45
|
# TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
|
47
46
|
#
|
48
47
|
# Raises if not supported on the current platform.
|
49
|
-
def notify(message, options = {})
|
50
|
-
TerminalNotifier.
|
48
|
+
def notify(message, options = {}, verbose = false)
|
49
|
+
TerminalNotifier.execute(verbose, options.merge(:message => message))
|
50
|
+
$?.success?
|
51
51
|
end
|
52
52
|
module_function :notify
|
53
53
|
|
54
|
-
# The same as `verbose`, but sends the output from the tool to STDOUT.
|
55
|
-
def verbose_notify(message, options = {})
|
56
|
-
TerminalNotifier.execute_with_options(options.merge(:message => message))
|
57
|
-
end
|
58
|
-
module_function :verbose_notify
|
59
|
-
|
60
54
|
# Removes a notification that was previously sent with the specified
|
61
55
|
# ‘group’ ID, if one exists.
|
62
|
-
|
63
|
-
|
56
|
+
#
|
57
|
+
# If no ‘group’ ID is given, all notifications are removed.
|
58
|
+
def remove(group = 'ALL', verbose = false)
|
59
|
+
TerminalNotifier.execute(verbose, :remove => group)
|
60
|
+
$?.success?
|
64
61
|
end
|
65
62
|
module_function :remove
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
LIST_FIELDS = [:group, :title, :subtitle, :message, :delivered_at].freeze
|
65
|
+
|
66
|
+
# If a ‘group’ ID is given, and a notification for that group exists,
|
67
|
+
# returns a hash with details about the notification.
|
68
|
+
#
|
69
|
+
# If no ‘group’ ID is given, an array of hashes describing all
|
70
|
+
# notifications.
|
71
|
+
#
|
72
|
+
# If no information is available this will return `nil`.
|
73
|
+
def list(group = 'ALL', verbose = false)
|
74
|
+
output = TerminalNotifier.execute(verbose, :list => group)
|
75
|
+
return if output.strip.empty?
|
76
|
+
|
77
|
+
require 'time'
|
78
|
+
notifications = output.split("\n")[1..-1].map do |line|
|
79
|
+
LIST_FIELDS.zip(line.split("\t")).inject({}) do |hash, (key, value)|
|
80
|
+
hash[key] = key == :delivered_at ? Time.parse(value) : (value unless value == '(null)')
|
81
|
+
hash
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
group == 'ALL' ? notifications : notifications.first
|
70
86
|
end
|
71
|
-
module_function :
|
87
|
+
module_function :list
|
72
88
|
end
|
@@ -50,8 +50,8 @@ This will obviously be a bit slower than using the tool without the wrapper.
|
|
50
50
|
|
51
51
|
#### Options
|
52
52
|
|
53
|
-
At a minimum, you have to specify either the `-message`
|
54
|
-
option.
|
53
|
+
At a minimum, you have to specify either the `-message` , the `-remove`
|
54
|
+
option or the `-list` option.
|
55
55
|
|
56
56
|
-------------------------------------------------------------------------------
|
57
57
|
|
@@ -67,6 +67,12 @@ The title of the notification. This defaults to ‘Terminal’.
|
|
67
67
|
|
68
68
|
-------------------------------------------------------------------------------
|
69
69
|
|
70
|
+
`-subtitle VALUE`
|
71
|
+
|
72
|
+
The subtitle of the notification.
|
73
|
+
|
74
|
+
-------------------------------------------------------------------------------
|
75
|
+
|
70
76
|
`-group ID`
|
71
77
|
|
72
78
|
Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
|
@@ -86,7 +92,16 @@ Examples are:
|
|
86
92
|
`-remove ID` **[required]**
|
87
93
|
|
88
94
|
Removes a notification that was previously sent with the specified ‘group’ ID,
|
89
|
-
if one exists.
|
95
|
+
if one exists. If used with the special group "ALL", all message are removed.
|
96
|
+
|
97
|
+
-------------------------------------------------------------------------------
|
98
|
+
|
99
|
+
`-list ID` **[required]**
|
100
|
+
|
101
|
+
Lists details about the specified ‘group’ ID. If used with the special group
|
102
|
+
"ALL", details about all currently active messages are displayed.
|
103
|
+
|
104
|
+
The output of this command is tab-separated, which makes it easy to parse.
|
90
105
|
|
91
106
|
-------------------------------------------------------------------------------
|
92
107
|
|
@@ -19,11 +19,11 @@
|
|
19
19
|
<key>CFBundlePackageType</key>
|
20
20
|
<string>APPL</string>
|
21
21
|
<key>CFBundleShortVersionString</key>
|
22
|
-
<string>1.
|
22
|
+
<string>1.4.0</string>
|
23
23
|
<key>CFBundleSignature</key>
|
24
24
|
<string>????</string>
|
25
25
|
<key>CFBundleVersion</key>
|
26
|
-
<string>
|
26
|
+
<string>5</string>
|
27
27
|
<key>DTCompiler</key>
|
28
28
|
<string></string>
|
29
29
|
<key>DTPlatformBuild</key>
|
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eloy Duran
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-08-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bacon
|