terminal-notifier 1.5.1 → 1.5.2

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/terminal-notifier.rb +1 -1
  3. data/vendor/terminal-notifier/README.markdown +53 -12
  4. data/vendor/terminal-notifier/Ruby/Gemfile +2 -0
  5. data/vendor/terminal-notifier/Ruby/Gemfile.lock +23 -0
  6. data/vendor/terminal-notifier/Ruby/LICENSE +23 -0
  7. data/vendor/terminal-notifier/Ruby/README.markdown +48 -0
  8. data/vendor/terminal-notifier/Ruby/Rakefile +44 -0
  9. data/vendor/terminal-notifier/Ruby/bin/terminal-notifier +13 -0
  10. data/vendor/terminal-notifier/Ruby/lib/terminal-notifier.rb +87 -0
  11. data/vendor/terminal-notifier/Ruby/spec/terminal-notifier_spec.rb +72 -0
  12. data/vendor/terminal-notifier/Ruby/terminal-notifier.gemspec +26 -0
  13. data/vendor/terminal-notifier/Terminal Notifier.xcodeproj/project.pbxproj +311 -0
  14. data/vendor/terminal-notifier/Terminal Notifier.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  15. data/vendor/terminal-notifier/Terminal Notifier.xcodeproj/xcshareddata/xcschemes/Terminal Notifier.xcscheme +140 -0
  16. data/vendor/terminal-notifier/Terminal Notifier/AppDelegate.h +4 -0
  17. data/vendor/terminal-notifier/Terminal Notifier/AppDelegate.m +339 -0
  18. data/vendor/terminal-notifier/Terminal Notifier/Terminal Notifier-Info.plist +36 -0
  19. data/vendor/terminal-notifier/Terminal Notifier/Terminal Notifier-Prefix.pch +7 -0
  20. data/vendor/terminal-notifier/Terminal Notifier/en.lproj/Credits.rtf +29 -0
  21. data/vendor/terminal-notifier/Terminal Notifier/en.lproj/InfoPlist.strings +2 -0
  22. data/vendor/terminal-notifier/Terminal Notifier/en.lproj/MainMenu.xib +3191 -0
  23. data/vendor/terminal-notifier/Terminal Notifier/main.m +6 -0
  24. data/vendor/terminal-notifier/Terminal.icns +0 -0
  25. data/vendor/terminal-notifier/terminal-notifier.app/Contents/Info.plist +10 -10
  26. data/vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier +0 -0
  27. data/vendor/terminal-notifier/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
  28. metadata +35 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df54c916daa2fd90c76fa0801d0053f301c70b71
4
- data.tar.gz: 9df4279db02aa1923acb0a2d13c5067fff803259
3
+ metadata.gz: b08bd293cf43906f2a2981022d9437f0a6758210
4
+ data.tar.gz: d64d013c3d638884daace7310cbde29cf618f9a0
5
5
  SHA512:
6
- metadata.gz: 1cb1bd4ad3e9010a7b9e51446658a3a8c71209b08edc0611307959b0c12401fcb3af5c756c57ecbc547bb36ab538353f9af7648e40eb381a05bec80d754c51ca
7
- data.tar.gz: 78090121c50d0fda6dae2187509b2bfc5996b345fc18d23cd7ca6806adb6cdd29b3d1cd67fda1d3eebc4dac2efadbb27f15a1d4f0301750ac009939fab56153e
6
+ metadata.gz: 1209ea24eb31275b6f1d6cc42b67c3ab2d557aa27d049d338f16a9f3fcef08a2cd084f5370501a4f412e587cef86bf9d5d193ba819b232dfbe00cef8dffd2340
7
+ data.tar.gz: 4e0f15e611525579d5117c39df8fdea49a0ffb8488a8bca7a41fbbfbb3aef93285d869739faf807ab5ca2855073ad02439312c6725ac13f579599f273a982c6c
@@ -25,7 +25,7 @@ module TerminalNotifier
25
25
  end
26
26
  end
27
27
 
28
- # Sends a User Notification and returns wether or not it was a success.
28
+ # Sends a User Notification and returns whether or not it was a success.
29
29
  #
30
30
  # The available options are `:title`, `:group`, `:activate`, `:open`,
31
31
  # `:execute`, `:sender`, and `:sound`. For a description of each option see:
@@ -1,24 +1,28 @@
1
1
  # terminal-notifier
2
2
 
3
3
  terminal-notifier is a command-line tool to send Mac OS X User Notifications,
4
- which are available in Mac OS X 10.8.
4
+ which are available in Mac OS X 10.8 and higher.
5
5
 
6
- It is currently packaged as an application bundle, because `NSUserNotification`
7
- does not work from a ‘Foundation tool’. [radar://11956694](radar://11956694)
8
6
 
9
- The Notification Center _always_ uses the application’s own icon, there’s
10
- currently no way to specify a custom icon for a notification. The only way to
11
- use this tool with your own icon is to include a build of terminal-notifier
12
- with your icon instead.
7
+ ## Caveats
13
8
 
14
- This tool will be used by [Kicker](https://github.com/alloy/kicker) to show the
15
- status of commands which are executed due to filesystem changes. (v3.0.0)
9
+ * The Notification Center _always_ uses the application’s own icon, there’s
10
+ currently no way to specify a custom icon for a notification. The only way to
11
+ use this tool with your own icon is to use the `-sender` option or include a
12
+ build of terminal-notifier with your icon and **a different bundle identifier**
13
+ instead. (If you do not change the bundle identifier, launch services will use
14
+ a cached version of the icon.)
15
+
16
+ However, you _can_ use unicode symbols and emojis. See the examples.
17
+
18
+ * It is currently packaged as an application bundle, because `NSUserNotification`
19
+ does not work from a ‘Foundation tool’. [radar://11956694](radar://11956694)
16
20
 
17
21
 
18
22
  ## Download
19
23
 
20
- Prebuilt binaries, which are code-signed and ready to use, are available from
21
- the [downloads section](https://github.com/alloy/terminal-notifier/downloads).
24
+ Prebuilt binaries are available from the
25
+ [releases section](https://github.com/alloy/terminal-notifier/releases).
22
26
 
23
27
  Or if you want to use this from
24
28
  [Ruby](https://github.com/alloy/terminal-notifier/tree/master/Ruby), you can
@@ -28,6 +32,10 @@ install it through RubyGems:
28
32
  $ [sudo] gem install terminal-notifier
29
33
  ```
30
34
 
35
+ You can also install it via [Homebrew](https://github.com/mxcl/homebrew):
36
+ ```
37
+ $ brew install terminal-notifier
38
+ ```
31
39
 
32
40
  ## Usage
33
41
 
@@ -47,6 +55,14 @@ $ terminal-notifier -[message|group|list] [VALUE|ID|ID] [options]
47
55
 
48
56
  This will obviously be a bit slower than using the tool without the wrapper.
49
57
 
58
+ Some examples are:
59
+
60
+ ```
61
+ $ echo 'Piped Message Data!' | terminal-notifier -sound default
62
+ $ terminal-notifier -title '💰' -message 'Check your Apple stock!' -open 'http://finance.yahoo.com/q?s=AAPL'
63
+ $ terminal-notifier -group 'address-book-sync' -title 'Address Book Sync' -subtitle 'Finished' -message 'Imported 42 contacts.' -activate 'com.apple.AddressBook'
64
+ ```
65
+
50
66
 
51
67
  #### Options
52
68
 
@@ -59,6 +75,9 @@ option or the `-list` option.
59
75
 
60
76
  The message body of the notification.
61
77
 
78
+ Note that if this option is omitted and data is piped to the application, that
79
+ data will be used instead.
80
+
62
81
  -------------------------------------------------------------------------------
63
82
 
64
83
  `-title VALUE`
@@ -73,6 +92,13 @@ The subtitle of the notification.
73
92
 
74
93
  -------------------------------------------------------------------------------
75
94
 
95
+ `-sound NAME`
96
+
97
+ The name of a sound to play when the notification appears. The names are listed
98
+ in Sound Preferences. Use 'default' for the default notification sound.
99
+
100
+ -------------------------------------------------------------------------------
101
+
76
102
  `-group ID`
77
103
 
78
104
  Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
@@ -120,6 +146,21 @@ Examples are:
120
146
 
121
147
  -------------------------------------------------------------------------------
122
148
 
149
+ `-sender ID`
150
+
151
+ Specifying this will make it appear as if the notification was send by that
152
+ application instead, including using its icon.
153
+
154
+ Using this option fakes the sender application, so that the notification system
155
+ will launch that application when the notification is clicked. Because of this
156
+ it is important to note that you cannot combine this with options like
157
+ `-execute` and `-activate` which depend on the sender of the notification to be
158
+ ‘terminal-notifier’ to perform its work.
159
+
160
+ For information on the `ID` see the `-activate` option.
161
+
162
+ -------------------------------------------------------------------------------
163
+
123
164
  `-open URL`
124
165
 
125
166
  Specifies a resource to be opened when the user clicks the notification. This
@@ -138,7 +179,7 @@ All the works are available under the MIT license. **Except** for
138
179
  ‘Terminal.icns’, which is a copy of Apple’s Terminal.app icon and as such is
139
180
  copyright of Apple.
140
181
 
141
- Copyright (C) 2012 Eloy Durán <eloy.de.enige@gmail.com>
182
+ Copyright (C) 2012-2013 Eloy Durán <eloy.de.enige@gmail.com>
142
183
 
143
184
  Permission is hereby granted, free of charge, to any person obtaining a copy of
144
185
  this software and associated documentation files (the "Software"), to deal in
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ terminal-notifier (1.5.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ bacon (1.1.0)
10
+ metaclass (0.0.1)
11
+ mocha (0.11.4)
12
+ metaclass (~> 0.0.1)
13
+ mocha-on-bacon (0.2.0)
14
+ mocha (>= 0.9.8)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bacon
21
+ mocha
22
+ mocha-on-bacon
23
+ terminal-notifier!
@@ -0,0 +1,23 @@
1
+ All the works are available under the MIT license. **Except** for
2
+ ‘Terminal.icns’, which is a copy of Apple’s Terminal.app icon and as such is
3
+ copyright of Apple.
4
+
5
+ Copyright (C) 2012-2013 Eloy Durán <eloy.de.enige@gmail.com>
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
+ of the Software, and to permit persons to whom the Software is furnished to do
12
+ so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # TerminalNotifier
2
+
3
+ A simple Ruby wrapper around the [`terminal-notifier`][HOMEPAGE] command-line
4
+ tool, which allows you to send User Notifications to the Notification Center on
5
+ Mac OS X 10.8, or higher.
6
+
7
+
8
+ ## Installation
9
+
10
+ ```
11
+ $ gem install terminal-notifier
12
+ ```
13
+
14
+
15
+ ## Usage
16
+
17
+ For full information on all the options, see the tool’s [README][README].
18
+
19
+ Examples are:
20
+
21
+ ```ruby
22
+ TerminalNotifier.notify('Hello World')
23
+ TerminalNotifier.notify('Hello World', :title => 'Ruby', :subtitle => 'Programming Language')
24
+ TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
25
+ TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
26
+ TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
27
+ TerminalNotifier.notify('Hello World', :group => Process.pid)
28
+ TerminalNotifier.notify('Hello World', :sender => 'com.apple.Safari')
29
+ TerminalNotifier.notify('Hello World', :sound => 'default')
30
+
31
+ TerminalNotifier.remove(Process.pid)
32
+
33
+ TerminalNotifier.list(Process.pid)
34
+ TerminalNotifier.list
35
+ ```
36
+
37
+
38
+ ## License
39
+
40
+ All the works are available under the MIT license. **Except** for
41
+ ‘Terminal.icns’, which is a copy of Apple’s Terminal.app icon and as such is
42
+ copyright of Apple.
43
+
44
+ See [LICENSE][LICENSE] for details.
45
+
46
+ [HOMEPAGE]: https://github.com/alloy/terminal-notifier
47
+ [README]: https://github.com/alloy/terminal-notifier/blob/master/README.markdown
48
+ [LICENSE]: https://github.com/alloy/terminal-notifier/blob/master/Ruby/LICENSE
@@ -0,0 +1,44 @@
1
+ def version
2
+ @version ||= begin
3
+ plist = File.expand_path('../../Terminal Notifier/Terminal Notifier-Info.plist', __FILE__)
4
+ `/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' '#{plist}'`.strip
5
+ end
6
+ end
7
+
8
+ def filename
9
+ "terminal-notifier-#{version}"
10
+ end
11
+
12
+ def zipfile
13
+ "#{filename}.zip"
14
+ end
15
+
16
+ task :clean do
17
+ rm zipfile
18
+ rm_rf "vendor"
19
+ end
20
+
21
+ desc "Fetch latest build from the GitHub releases"
22
+ task :update_build do
23
+ unless File.exist?(zipfile)
24
+ sh "curl -L -O 'https://github.com/alloy/terminal-notifier/releases/download/#{version}/terminal-notifier-#{version}.zip'"
25
+ end
26
+
27
+ rm_rf "vendor"
28
+ mkdir "vendor"
29
+
30
+ sh "unzip -o -d vendor #{zipfile}"
31
+ mv "vendor/#{filename}", "vendor/terminal-notifier"
32
+ end
33
+
34
+ desc "Build gem"
35
+ task :gem => :update_build do
36
+ sh "gem build terminal-notifier.gemspec"
37
+ end
38
+
39
+ desc "Run specs"
40
+ task :spec do
41
+ sh "bundle exec ruby spec/terminal-notifier_spec.rb"
42
+ end
43
+
44
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if $0 == __FILE__
4
+ $:.unshift File.expand_path('../../lib', __FILE__)
5
+ end
6
+
7
+ require 'terminal-notifier'
8
+
9
+ if !ARGV.include?("-message") && !STDIN.tty?
10
+ ARGV.push(*["-message", STDIN.read.chomp])
11
+ end
12
+
13
+ exec TerminalNotifier::BIN_PATH, *ARGV
@@ -0,0 +1,87 @@
1
+ require 'shellwords'
2
+
3
+ module TerminalNotifier
4
+ BIN_PATH = File.expand_path('../../vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier', __FILE__)
5
+
6
+ class UnsupportedPlatformError < StandardError; end
7
+ # Returns wether or not the current platform is Mac OS X 10.8, or higher.
8
+ def self.available?
9
+ @available ||= `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
10
+ end
11
+
12
+ def self.execute(verbose, options)
13
+ if available?
14
+ command = [BIN_PATH, *options.map { |k,v| v = v.to_s; ["-#{k}", "#{Shellwords.escape(v[0,1])}#{v[1..-1]}"] }.flatten]
15
+ command = Shellwords.join(command) if RUBY_VERSION < '1.9'
16
+ result = ''
17
+ IO.popen(command) do |stdout|
18
+ output = stdout.read
19
+ STDOUT.print output if verbose
20
+ result << output
21
+ end
22
+ result
23
+ else
24
+ raise UnsupportedPlatformError, "terminal-notifier is only supported on Mac OS X 10.8, or higher."
25
+ end
26
+ end
27
+
28
+ # Sends a User Notification and returns whether or not it was a success.
29
+ #
30
+ # The available options are `:title`, `:group`, `:activate`, `:open`,
31
+ # `:execute`, `:sender`, and `:sound`. For a description of each option see:
32
+ #
33
+ # https://github.com/alloy/terminal-notifier/blob/master/README.markdown
34
+ #
35
+ # Examples are:
36
+ #
37
+ # TerminalNotifier.notify('Hello World')
38
+ # TerminalNotifier.notify('Hello World', :title => 'Ruby')
39
+ # TerminalNotifier.notify('Hello World', :group => Process.pid)
40
+ # TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
41
+ # TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
42
+ # TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
43
+ # TerminalNotifier.notify('Hello World', :sender => 'com.apple.Safari')
44
+ # TerminalNotifier.notify('Hello World', :sound => 'default')
45
+ #
46
+ # Raises if not supported on the current platform.
47
+ def notify(message, options = {}, verbose = false)
48
+ TerminalNotifier.execute(verbose, options.merge(:message => message))
49
+ $?.success?
50
+ end
51
+ module_function :notify
52
+
53
+ # Removes a notification that was previously sent with the specified
54
+ # ‘group’ ID, if one exists.
55
+ #
56
+ # If no ‘group’ ID is given, all notifications are removed.
57
+ def remove(group = 'ALL', verbose = false)
58
+ TerminalNotifier.execute(verbose, :remove => group)
59
+ $?.success?
60
+ end
61
+ module_function :remove
62
+
63
+ LIST_FIELDS = [:group, :title, :subtitle, :message, :delivered_at].freeze
64
+
65
+ # If a ‘group’ ID is given, and a notification for that group exists,
66
+ # returns a hash with details about the notification.
67
+ #
68
+ # If no ‘group’ ID is given, an array of hashes describing all
69
+ # notifications.
70
+ #
71
+ # If no information is available this will return `nil`.
72
+ def list(group = 'ALL', verbose = false)
73
+ output = TerminalNotifier.execute(verbose, :list => group)
74
+ return if output.strip.empty?
75
+
76
+ require 'time'
77
+ notifications = output.split("\n")[1..-1].map do |line|
78
+ LIST_FIELDS.zip(line.split("\t")).inject({}) do |hash, (key, value)|
79
+ hash[key] = key == :delivered_at ? Time.parse(value) : (value unless value == '(null)')
80
+ hash
81
+ end
82
+ end
83
+
84
+ group == 'ALL' ? notifications : notifications.first
85
+ end
86
+ module_function :list
87
+ end
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'bacon'
3
+ require 'mocha'
4
+ require 'mocha-on-bacon'
5
+
6
+ Bacon.summary_at_exit
7
+
8
+ $:.unshift File.expand_path('../../lib', __FILE__)
9
+ require 'terminal-notifier'
10
+
11
+ describe "TerminalNotifier" do
12
+ it "executes the tool with the given options and properly escapes the message" do
13
+ command = [TerminalNotifier::BIN_PATH, '-message', '\[ZOMG] "OH YEAH"']
14
+ command = Shellwords.join(command) if RUBY_VERSION < '1.9'
15
+ IO.expects(:popen).with(command).yields(StringIO.new('output'))
16
+ TerminalNotifier.execute(false, :message => '[ZOMG] "OH YEAH"')
17
+ end
18
+
19
+ it "returns the result output of the command" do
20
+ TerminalNotifier.execute(false, 'help' => '').should == `'#{TerminalNotifier::BIN_PATH}' -help`
21
+ end
22
+
23
+ it "sends a notification" do
24
+ TerminalNotifier.expects(:execute).with(false, :message => 'ZOMG', :group => 'important stuff')
25
+ TerminalNotifier.notify('ZOMG', :group => 'important stuff')
26
+ end
27
+
28
+ it "removes a notification" do
29
+ TerminalNotifier.expects(:execute).with(false, :remove => 'important stuff')
30
+ TerminalNotifier.remove('important stuff')
31
+ end
32
+
33
+ it "by default removes all the notifications" do
34
+ TerminalNotifier.expects(:execute).with(false, :remove => 'ALL')
35
+ TerminalNotifier.remove
36
+ end
37
+
38
+ it "returns `nil` if no notification was found to list info for" do
39
+ TerminalNotifier.expects(:execute).with(false, :list => 'important stuff').returns('')
40
+ TerminalNotifier.list('important stuff').should == nil
41
+ end
42
+
43
+ it "returns info about a notification posted in a specific group" do
44
+ TerminalNotifier.expects(:execute).with(false, :list => 'important stuff').
45
+ returns("GroupID\tTitle\tSubtitle\tMessage\tDelivered At\n" \
46
+ "important stuff\tTerminal\t(null)\tExecute: rake spec\t2012-08-06 19:45:30 +0000")
47
+ TerminalNotifier.list('important stuff').should == {
48
+ :group => 'important stuff',
49
+ :title => 'Terminal', :subtitle => nil, :message => 'Execute: rake spec',
50
+ :delivered_at => Time.parse('2012-08-06 19:45:30 +0000')
51
+ }
52
+ end
53
+
54
+ it "by default returns a list of all notification" do
55
+ TerminalNotifier.expects(:execute).with(false, :list => 'ALL').
56
+ returns("GroupID\tTitle\tSubtitle\tMessage\tDelivered At\n" \
57
+ "important stuff\tTerminal\t(null)\tExecute: rake spec\t2012-08-06 19:45:30 +0000\n" \
58
+ "(null)\t(null)\tSubtle\tBe subtle!\t2012-08-07 19:45:30 +0000")
59
+ TerminalNotifier.list.should == [
60
+ {
61
+ :group => 'important stuff',
62
+ :title => 'Terminal', :subtitle => nil, :message => 'Execute: rake spec',
63
+ :delivered_at => Time.parse('2012-08-06 19:45:30 +0000')
64
+ },
65
+ {
66
+ :group => nil,
67
+ :title => nil, :subtitle => 'Subtle', :message => 'Be subtle!',
68
+ :delivered_at => Time.parse('2012-08-07 19:45:30 +0000')
69
+ }
70
+ ]
71
+ end
72
+ end