terminal-notifier 1.5.0 → 1.6.0

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 +7 -0
  2. data/lib/terminal-notifier.rb +1 -1
  3. data/vendor/terminal-notifier/README.markdown +47 -7
  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 +48 -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/AppDelegate.h +4 -0
  14. data/vendor/terminal-notifier/Terminal Notifier/AppDelegate.m +364 -0
  15. data/vendor/terminal-notifier/Terminal Notifier/Terminal Notifier-Info.plist +36 -0
  16. data/vendor/terminal-notifier/Terminal Notifier/Terminal Notifier-Prefix.pch +7 -0
  17. data/vendor/terminal-notifier/Terminal Notifier/en.lproj/Credits.rtf +29 -0
  18. data/vendor/terminal-notifier/Terminal Notifier/en.lproj/InfoPlist.strings +2 -0
  19. data/vendor/terminal-notifier/Terminal Notifier/en.lproj/MainMenu.xib +3191 -0
  20. data/vendor/terminal-notifier/Terminal Notifier/main.m +6 -0
  21. data/vendor/terminal-notifier/Terminal Notifier.xcodeproj/project.pbxproj +311 -0
  22. data/vendor/terminal-notifier/Terminal Notifier.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  23. data/vendor/terminal-notifier/Terminal Notifier.xcodeproj/xcshareddata/xcschemes/Terminal Notifier.xcscheme +140 -0
  24. data/vendor/terminal-notifier/Terminal.icns +0 -0
  25. data/vendor/terminal-notifier/terminal-notifier.app/Contents/Info.plist +7 -7
  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 +81 -78
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc0d510f599b6936ce8b16fbda223456053c2280
4
+ data.tar.gz: 314e51d3fdb3859e55a6b5500abe8fead4bbb6f6
5
+ SHA512:
6
+ metadata.gz: a21300312cffba5d3d617becb181325a4bdc93c5d6de395343f87c505bed0bfbde2d2c8bca0a288e789d2e723e1cda39d99487952c7ca94ad7cad6b230e0c5b1
7
+ data.tar.gz: 2f54d00f7f18b78aac700484634db6c43531496fcc299a51a8a2f9a9cfca75405d5df4d4f01d6584ea62508019ceb8a2901012e6eeecf9264bca650b5a6a1f9c
@@ -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:
@@ -6,16 +6,23 @@ which are available in Mac OS X 10.8 and higher.
6
6
 
7
7
  ## Caveats
8
8
 
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 bundle identifier instead.
13
-
14
- However, you _can_ use unicode symbols and emojis. See the examples.
9
+ * Under OS X 10.8, the Notification Center _always_ uses the application’s own
10
+ icon, there’s currently no way to specify a custom icon for a notification. The only
11
+ way to 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
+ <br/>Consequently the `-appIcon` & `-contentImage` options aren't doing anything
16
+ under 10.8.
17
+ <br/>However, you _can_ use unicode symbols and emojis. See the examples.
15
18
 
16
19
  * It is currently packaged as an application bundle, because `NSUserNotification`
17
20
  does not work from a ‘Foundation tool’. [radar://11956694](radar://11956694)
18
21
 
22
+ * If you intend to package terminal-notifier with your app to distribute it on the
23
+ MAS, please use 1.5.2 since 1.6.0+ uses a private method override which is not
24
+ allowed in the AppStore guidelines.
25
+
19
26
 
20
27
  ## Download
21
28
 
@@ -30,6 +37,10 @@ install it through RubyGems:
30
37
  $ [sudo] gem install terminal-notifier
31
38
  ```
32
39
 
40
+ You can also install it via [Homebrew](https://github.com/mxcl/homebrew):
41
+ ```
42
+ $ brew install terminal-notifier
43
+ ```
33
44
 
34
45
  ## Usage
35
46
 
@@ -61,7 +72,7 @@ $ terminal-notifier -group 'address-book-sync' -title 'Address Book Sync' -subti
61
72
  #### Options
62
73
 
63
74
  At a minimum, you have to specify either the `-message` , the `-remove`
64
- option or the `-list` option.
75
+ or the `-list` option.
65
76
 
66
77
  -------------------------------------------------------------------------------
67
78
 
@@ -86,6 +97,13 @@ The subtitle of the notification.
86
97
 
87
98
  -------------------------------------------------------------------------------
88
99
 
100
+ `-sound NAME`
101
+
102
+ The name of a sound to play when the notification appears. The names are listed
103
+ in Sound Preferences. Use 'default' for the default notification sound.
104
+
105
+ -------------------------------------------------------------------------------
106
+
89
107
  `-group ID`
90
108
 
91
109
  Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
@@ -138,10 +156,32 @@ Examples are:
138
156
  Specifying this will make it appear as if the notification was send by that
139
157
  application instead, including using its icon.
140
158
 
159
+ Using this option fakes the sender application, so that the notification system
160
+ will launch that application when the notification is clicked. Because of this
161
+ it is important to note that you cannot combine this with options like
162
+ `-execute` and `-activate` which depend on the sender of the notification to be
163
+ ‘terminal-notifier’ to perform its work.
164
+
141
165
  For information on the `ID` see the `-activate` option.
142
166
 
143
167
  -------------------------------------------------------------------------------
144
168
 
169
+ `-appIcon URL` **[10.9+ only]**
170
+
171
+ Specifies The URL of an image to display instead of the application icon.
172
+
173
+ **WARNING: This option is subject to change since it relies on a private method.**
174
+
175
+ -------------------------------------------------------------------------------
176
+
177
+ `-contentImage URL` **[10.9+ only]**
178
+
179
+ Specifies The URL of an image to display attached inside the notification.
180
+
181
+ **WARNING: This option is subject to change since it relies on a private method.**
182
+
183
+ -------------------------------------------------------------------------------
184
+
145
185
  `-open URL`
146
186
 
147
187
  Specifies a resource to be opened when the user clicks the notification. This
@@ -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,48 @@
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
+ "#{version}.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/archive/#{zipfile}'"
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
+
33
+ %x(xcodebuild -project '../Terminal\ Notifier.xcodeproj' -target terminal-notifier SYMROOT=build -verbose)
34
+ mv '../build/Release/terminal-notifier.app', 'vendor/terminal-notifier/'
35
+ chmod 0755, 'vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier'
36
+ end
37
+
38
+ desc "Build gem"
39
+ task :gem => :update_build do
40
+ sh "gem build terminal-notifier.gemspec"
41
+ end
42
+
43
+ desc "Run specs"
44
+ task :spec do
45
+ sh "bundle exec ruby spec/terminal-notifier_spec.rb"
46
+ end
47
+
48
+ 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
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ plist = File.expand_path('../../Terminal Notifier/Terminal Notifier-Info.plist', __FILE__)
3
+ # Also run on non-OSX machines, otherwise bundle installs directly from the repo will fail.
4
+ # version = `/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' '#{plist}'`.strip
5
+ version = File.read(plist).match(%r{<string>(\d+\.\d+\.\d+)</string>})[1]
6
+
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = "terminal-notifier"
10
+ gem.version = version
11
+ gem.summary = 'Send User Notifications on Mac OS X 10.8 or higher.'
12
+ gem.authors = ["Eloy Duran"]
13
+ gem.email = ["eloy.de.enige@gmail.com"]
14
+ gem.homepage = 'https://github.com/alloy/terminal-notifier'
15
+ gem.license = 'MIT'
16
+
17
+ gem.executables = ['terminal-notifier']
18
+ gem.files = ['bin/terminal-notifier', 'lib/terminal-notifier.rb'] + Dir.glob('vendor/terminal-notifier/**/*')
19
+ gem.require_paths = ['lib']
20
+
21
+ gem.extra_rdoc_files = ['README.markdown']
22
+
23
+ gem.add_development_dependency 'bacon'
24
+ gem.add_development_dependency 'mocha'
25
+ gem.add_development_dependency 'mocha-on-bacon'
26
+ end
@@ -0,0 +1,4 @@
1
+ #import <Cocoa/Cocoa.h>
2
+
3
+ @interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate>
4
+ @end