kicker 2.6.1 → 3.0.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kicker.rb +1 -4
- data/lib/kicker/callback_chain.rb +1 -1
- data/lib/kicker/notification.rb +42 -0
- data/lib/kicker/options.rb +6 -10
- data/lib/kicker/utils.rb +4 -3
- data/lib/kicker/version.rb +1 -1
- data/vendor/terminal-notifier_v1.0/README.markdown +70 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Info.plist +52 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/MacOS/terminal-notifier +0 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/PkgInfo +1 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/Terminal.icns +0 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/Credits.rtf +29 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/InfoPlist.strings +0 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
- data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/_CodeSignature/CodeResources +61 -0
- metadata +15 -9
- data/lib/kicker/growl.rb +0 -74
- data/vendor/growlnotifier/growl.rb +0 -170
- data/vendor/growlnotifier/growl_helpers.rb +0 -25
data/lib/kicker.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
$:.unshift File.expand_path('../../vendor', __FILE__)
|
2
|
-
|
3
1
|
require 'kicker/version'
|
4
2
|
require 'kicker/fsevents'
|
5
3
|
require 'kicker/callback_chain'
|
6
4
|
require 'kicker/core_ext'
|
7
|
-
require 'kicker/
|
5
|
+
require 'kicker/notification'
|
8
6
|
require 'kicker/options'
|
9
7
|
require 'kicker/utils'
|
10
8
|
require 'kicker/recipes'
|
@@ -31,7 +29,6 @@ class Kicker #:nodoc:
|
|
31
29
|
log "Watching for changes on: #{paths.join(', ')}"
|
32
30
|
log ''
|
33
31
|
|
34
|
-
Kicker::Growl.start! if Kicker::Growl.usable? && Kicker::Growl.use?
|
35
32
|
run_startup_chain
|
36
33
|
run_watch_dog!
|
37
34
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Kicker
|
2
|
+
module Notification #:nodoc:
|
3
|
+
vendor = File.expand_path('../../../vendor', __FILE__)
|
4
|
+
TERMINAL_NOTIFICATION_BIN = File.join(vendor, 'terminal-notifier_v1.0/terminal-notifier.app/Contents/MacOS/terminal-notifier')
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :use, :app_bundle_identifier
|
8
|
+
alias_method :use?, :use
|
9
|
+
|
10
|
+
def usable?
|
11
|
+
@usable ||= `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
|
12
|
+
end
|
13
|
+
|
14
|
+
def change_occured(status)
|
15
|
+
notify('Kicker: Executing', status.command)
|
16
|
+
end
|
17
|
+
|
18
|
+
def result(status)
|
19
|
+
status.success? ? succeeded(status) : failed(status)
|
20
|
+
end
|
21
|
+
|
22
|
+
def succeeded(status)
|
23
|
+
body = Kicker.silent? ? '' : status.output
|
24
|
+
notify('Kicker: Success', body)
|
25
|
+
end
|
26
|
+
|
27
|
+
def failed(status)
|
28
|
+
message = "Kicker: Failed (#{status.exit_code})"
|
29
|
+
body = Kicker.silent? ? '' : status.output
|
30
|
+
notify(message, body)
|
31
|
+
end
|
32
|
+
|
33
|
+
def notify(title, message)
|
34
|
+
`'#{TERMINAL_NOTIFICATION_BIN}' #{Dir.pwd} '#{title}' '#{message}' '#{app_bundle_identifier}'`
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Notification.use = true
|
40
|
+
Notification.app_bundle_identifier = 'com.apple.Terminal'
|
41
|
+
end
|
42
|
+
|
data/lib/kicker/options.rb
CHANGED
@@ -15,10 +15,6 @@ class Kicker
|
|
15
15
|
def clear_console?
|
16
16
|
@clear_console
|
17
17
|
end
|
18
|
-
|
19
|
-
def has_growl?
|
20
|
-
Kicker.const_defined?(:Growl)
|
21
|
-
end
|
22
18
|
end
|
23
19
|
|
24
20
|
self.latency = 1
|
@@ -58,16 +54,16 @@ class Kicker
|
|
58
54
|
Kicker.clear_console = true
|
59
55
|
end
|
60
56
|
|
61
|
-
if
|
62
|
-
opt.on('--[no-]
|
63
|
-
|
57
|
+
if Notification.usable?
|
58
|
+
opt.on('--[no-]notification', 'Whether or not to send user notifications (on Mac OS X). Defaults to enabled.') do |notifications|
|
59
|
+
Notification.use = notifications
|
64
60
|
end
|
65
61
|
|
66
|
-
opt.on('--
|
67
|
-
Kicker::
|
62
|
+
opt.on('--activate-app [BUNDLE ID]', "The application to activate when a notification is clicked. Defaults to `com.apple.Terminal'.") do |bundle_id|
|
63
|
+
Kicker::Notification.app_bundle_identifier = bundle_id
|
68
64
|
end
|
69
65
|
else
|
70
|
-
Kicker::
|
66
|
+
Kicker::Notification.use = false
|
71
67
|
end
|
72
68
|
|
73
69
|
opt.on('-l', '--latency [FLOAT]', "The time to collect file change events before acting on them. Defaults to #{Kicker.latency} second.") do |latency|
|
data/lib/kicker/utils.rb
CHANGED
@@ -96,13 +96,13 @@ class Kicker
|
|
96
96
|
@should_clear_screen = false
|
97
97
|
|
98
98
|
log "Executing: #{status.command}"
|
99
|
-
|
99
|
+
Notification.change_occured(status) if Notification.use? && !Kicker.silent?
|
100
100
|
end
|
101
101
|
|
102
102
|
def did_execute_command(status)
|
103
103
|
puts("\n#{status.output}\n\n") if Kicker.silent? && !status.success?
|
104
104
|
log(status.success? ? "Success" : "Failed (#{status.exit_code})")
|
105
|
-
|
105
|
+
Notification.result(status) if Notification.use?
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
@@ -120,7 +120,8 @@ module Kernel
|
|
120
120
|
Kicker::Utils.perform_work(command, &block)
|
121
121
|
end
|
122
122
|
|
123
|
-
# Executes the +command+, logs the output, and optionally
|
123
|
+
# Executes the +command+, logs the output, and optionally sends user
|
124
|
+
# notifications on Mac OS X (10.8 or higher).
|
124
125
|
def execute(command, &block)
|
125
126
|
Kicker::Utils.execute(command, &block)
|
126
127
|
end
|
data/lib/kicker/version.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
# terminal-notifier
|
2
|
+
|
3
|
+
terminal-notifier is a command-line tool to send OS X User Notifications, which
|
4
|
+
are available starting Mac OS X 10.8.
|
5
|
+
|
6
|
+
It is currently packaged as an application bundle, because `NSUserNotification`
|
7
|
+
does not work from a ‘Foundation tool’. If you figure out a way to make this
|
8
|
+
work, please send a pull-request.
|
9
|
+
|
10
|
+
This tool is used by [Kicker](https://github.com/alloy/kicker) to show the
|
11
|
+
status of commands being executed due to filesystem changes.
|
12
|
+
|
13
|
+
|
14
|
+
## Download
|
15
|
+
|
16
|
+
Prebuilt binaries, which are code-signed and ready to use, are available from
|
17
|
+
the [downloads section](https://github.com/alloy/terminal-notifier/downloads).
|
18
|
+
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
In order to use terminal-notifier, you have to call the binary _inside_ the app
|
23
|
+
bundle. E.g.:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ ./terminal-notifier.app/Contents/MacOS/terminal-notifier
|
27
|
+
```
|
28
|
+
|
29
|
+
The arguments required are shown by the tool. Here is a copy of the output:
|
30
|
+
|
31
|
+
```
|
32
|
+
Usage: terminal-notifier sender-ID sender-name message [bundle-ID]
|
33
|
+
|
34
|
+
sender-ID A string which identifies the group the notifications belong to.
|
35
|
+
Old notifications with the same ID will be removed.
|
36
|
+
sender-name The name of the application which is used as the notification’s title.
|
37
|
+
message The message that is shown in the notification.
|
38
|
+
bundle-ID The bundle identifier of the application to activate when the user
|
39
|
+
activates (clicks) a notification. Defaults to `com.apple.Terminal'.
|
40
|
+
|
41
|
+
When the user activates a notification, the results are logged to the system logs.
|
42
|
+
Use Console.app to view these logs.
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
All the works are available under the MIT license.
|
49
|
+
|
50
|
+
**Except** for `Terminal.icns`, which is a copy of Apple’s Terminal.app icon.
|
51
|
+
|
52
|
+
Copyright (C) 2012 Eloy Durán <eloy.de.enige@gmail.com>
|
53
|
+
|
54
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
55
|
+
this software and associated documentation files (the "Software"), to deal in
|
56
|
+
the Software without restriction, including without limitation the rights to
|
57
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
58
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
59
|
+
so, subject to the following conditions:
|
60
|
+
|
61
|
+
The above copyright notice and this permission notice shall be included in all
|
62
|
+
copies or substantial portions of the Software.
|
63
|
+
|
64
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
65
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
66
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
67
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
68
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
69
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
70
|
+
SOFTWARE.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>BuildMachineOSBuild</key>
|
6
|
+
<string>12A269</string>
|
7
|
+
<key>CFBundleDevelopmentRegion</key>
|
8
|
+
<string>en</string>
|
9
|
+
<key>CFBundleExecutable</key>
|
10
|
+
<string>terminal-notifier</string>
|
11
|
+
<key>CFBundleIconFile</key>
|
12
|
+
<string>Terminal</string>
|
13
|
+
<key>CFBundleIdentifier</key>
|
14
|
+
<string>nl.superalloy.oss.terminal-notifier</string>
|
15
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
16
|
+
<string>6.0</string>
|
17
|
+
<key>CFBundleName</key>
|
18
|
+
<string>terminal-notifier</string>
|
19
|
+
<key>CFBundlePackageType</key>
|
20
|
+
<string>APPL</string>
|
21
|
+
<key>CFBundleShortVersionString</key>
|
22
|
+
<string>1.0</string>
|
23
|
+
<key>CFBundleSignature</key>
|
24
|
+
<string>????</string>
|
25
|
+
<key>CFBundleVersion</key>
|
26
|
+
<string>1</string>
|
27
|
+
<key>DTCompiler</key>
|
28
|
+
<string></string>
|
29
|
+
<key>DTPlatformBuild</key>
|
30
|
+
<string>4F243</string>
|
31
|
+
<key>DTPlatformVersion</key>
|
32
|
+
<string>GM</string>
|
33
|
+
<key>DTSDKBuild</key>
|
34
|
+
<string>12A264</string>
|
35
|
+
<key>DTSDKName</key>
|
36
|
+
<string>macosx10.8</string>
|
37
|
+
<key>DTXcode</key>
|
38
|
+
<string>0440</string>
|
39
|
+
<key>DTXcodeBuild</key>
|
40
|
+
<string>4F243</string>
|
41
|
+
<key>LSMinimumSystemVersion</key>
|
42
|
+
<string>10.8</string>
|
43
|
+
<key>LSUIElement</key>
|
44
|
+
<true/>
|
45
|
+
<key>NSHumanReadableCopyright</key>
|
46
|
+
<string>Copyright © 2012 Eloy Durán. All rights reserved.</string>
|
47
|
+
<key>NSMainNibFile</key>
|
48
|
+
<string>MainMenu</string>
|
49
|
+
<key>NSPrincipalClass</key>
|
50
|
+
<string>NSApplication</string>
|
51
|
+
</dict>
|
52
|
+
</plist>
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
APPL????
|
Binary file
|
data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/Credits.rtf
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
|
2
|
+
{\colortbl;\red255\green255\blue255;}
|
3
|
+
\paperw9840\paperh8400
|
4
|
+
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
|
5
|
+
|
6
|
+
\f0\b\fs24 \cf0 Engineering:
|
7
|
+
\b0 \
|
8
|
+
Some people\
|
9
|
+
\
|
10
|
+
|
11
|
+
\b Human Interface Design:
|
12
|
+
\b0 \
|
13
|
+
Some other people\
|
14
|
+
\
|
15
|
+
|
16
|
+
\b Testing:
|
17
|
+
\b0 \
|
18
|
+
Hopefully not nobody\
|
19
|
+
\
|
20
|
+
|
21
|
+
\b Documentation:
|
22
|
+
\b0 \
|
23
|
+
Whoever\
|
24
|
+
\
|
25
|
+
|
26
|
+
\b With special thanks to:
|
27
|
+
\b0 \
|
28
|
+
Mom\
|
29
|
+
}
|
Binary file
|
data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib
ADDED
Binary file
|
data/vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/_CodeSignature/CodeResources
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>files</key>
|
6
|
+
<dict>
|
7
|
+
<key>Resources/Terminal.icns</key>
|
8
|
+
<data>
|
9
|
+
Oq9GtJM1DqcGF1JCHiEgb0hoN6I=
|
10
|
+
</data>
|
11
|
+
<key>Resources/en.lproj/Credits.rtf</key>
|
12
|
+
<dict>
|
13
|
+
<key>hash</key>
|
14
|
+
<data>
|
15
|
+
YKJIFIsxneJuNkJNJQIcJIjiPOg=
|
16
|
+
</data>
|
17
|
+
<key>optional</key>
|
18
|
+
<true/>
|
19
|
+
</dict>
|
20
|
+
<key>Resources/en.lproj/InfoPlist.strings</key>
|
21
|
+
<dict>
|
22
|
+
<key>hash</key>
|
23
|
+
<data>
|
24
|
+
MiLKDDnrUKr4EmuvhS5VQwxHGK8=
|
25
|
+
</data>
|
26
|
+
<key>optional</key>
|
27
|
+
<true/>
|
28
|
+
</dict>
|
29
|
+
<key>Resources/en.lproj/MainMenu.nib</key>
|
30
|
+
<dict>
|
31
|
+
<key>hash</key>
|
32
|
+
<data>
|
33
|
+
N1QqAM17vgDk7XNtv27koaE4IhE=
|
34
|
+
</data>
|
35
|
+
<key>optional</key>
|
36
|
+
<true/>
|
37
|
+
</dict>
|
38
|
+
</dict>
|
39
|
+
<key>rules</key>
|
40
|
+
<dict>
|
41
|
+
<key>^Resources/</key>
|
42
|
+
<true/>
|
43
|
+
<key>^Resources/.*\.lproj/</key>
|
44
|
+
<dict>
|
45
|
+
<key>optional</key>
|
46
|
+
<true/>
|
47
|
+
<key>weight</key>
|
48
|
+
<real>1000</real>
|
49
|
+
</dict>
|
50
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
51
|
+
<dict>
|
52
|
+
<key>omit</key>
|
53
|
+
<true/>
|
54
|
+
<key>weight</key>
|
55
|
+
<real>1100</real>
|
56
|
+
</dict>
|
57
|
+
<key>^version.plist$</key>
|
58
|
+
<true/>
|
59
|
+
</dict>
|
60
|
+
</dict>
|
61
|
+
</plist>
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kicker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.0pre1
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eloy Duran
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: listen
|
@@ -139,7 +139,7 @@ files:
|
|
139
139
|
- lib/kicker/callback_chain.rb
|
140
140
|
- lib/kicker/core_ext.rb
|
141
141
|
- lib/kicker/fsevents.rb
|
142
|
-
- lib/kicker/
|
142
|
+
- lib/kicker/notification.rb
|
143
143
|
- lib/kicker/options.rb
|
144
144
|
- lib/kicker/recipes/could_not_handle_file.rb
|
145
145
|
- lib/kicker/recipes/dot_kick.rb
|
@@ -152,8 +152,15 @@ files:
|
|
152
152
|
- lib/kicker/utils.rb
|
153
153
|
- lib/kicker/version.rb
|
154
154
|
- lib/kicker.rb
|
155
|
-
- vendor/
|
156
|
-
- vendor/
|
155
|
+
- vendor/terminal-notifier_v1.0/README.markdown
|
156
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/_CodeSignature/CodeResources
|
157
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Info.plist
|
158
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/MacOS/terminal-notifier
|
159
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/PkgInfo
|
160
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/Credits.rtf
|
161
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/InfoPlist.strings
|
162
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib
|
163
|
+
- vendor/terminal-notifier_v1.0/terminal-notifier.app/Contents/Resources/Terminal.icns
|
157
164
|
- README.rdoc
|
158
165
|
- LICENSE
|
159
166
|
- html/images/kikker.jpg
|
@@ -173,9 +180,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
181
|
none: false
|
175
182
|
requirements:
|
176
|
-
- - ! '
|
183
|
+
- - ! '>'
|
177
184
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
185
|
+
version: 1.3.1
|
179
186
|
requirements: []
|
180
187
|
rubyforge_project:
|
181
188
|
rubygems_version: 1.8.23
|
@@ -183,4 +190,3 @@ signing_key:
|
|
183
190
|
specification_version: 3
|
184
191
|
summary: A lean, agnostic, flexible file-change watcher.
|
185
192
|
test_files: []
|
186
|
-
has_rdoc:
|
data/lib/kicker/growl.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
class Kicker
|
2
|
-
module Growl #:nodoc:
|
3
|
-
class << self
|
4
|
-
attr_accessor :use, :command
|
5
|
-
|
6
|
-
def usable?
|
7
|
-
false
|
8
|
-
end
|
9
|
-
|
10
|
-
def use?
|
11
|
-
@use
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
begin
|
18
|
-
require 'osx/cocoa'
|
19
|
-
require 'growlnotifier/growl_helpers'
|
20
|
-
|
21
|
-
class Kicker
|
22
|
-
module Growl #:nodoc:
|
23
|
-
NOTIFICATIONS = {
|
24
|
-
:change => 'Change occured',
|
25
|
-
:succeeded => 'Command succeeded',
|
26
|
-
:failed => 'Command failed'
|
27
|
-
}
|
28
|
-
|
29
|
-
DEFAULT_CALLBACK = lambda do
|
30
|
-
OSX::NSWorkspace.sharedWorkspace.launchApplication('Terminal')
|
31
|
-
end
|
32
|
-
|
33
|
-
class << self
|
34
|
-
include ::Growl
|
35
|
-
|
36
|
-
Growl.use = true
|
37
|
-
Growl.command = nil
|
38
|
-
|
39
|
-
def usable?
|
40
|
-
true
|
41
|
-
end
|
42
|
-
|
43
|
-
def notifications
|
44
|
-
NOTIFICATIONS
|
45
|
-
end
|
46
|
-
|
47
|
-
def start!
|
48
|
-
::Growl::Notifier.sharedInstance.register('Kicker', NOTIFICATIONS.values)
|
49
|
-
end
|
50
|
-
|
51
|
-
def change_occured(status)
|
52
|
-
growl(notifications[:change], 'Kicker: Executing', status.command)
|
53
|
-
end
|
54
|
-
|
55
|
-
def result(status)
|
56
|
-
status.success? ? succeeded(status) : failed(status)
|
57
|
-
end
|
58
|
-
|
59
|
-
def succeeded(status)
|
60
|
-
body = Kicker.silent? ? '' : status.output
|
61
|
-
growl(notifications[:succeeded], "Kicker: Success", body, &DEFAULT_CALLBACK)
|
62
|
-
end
|
63
|
-
|
64
|
-
def failed(status)
|
65
|
-
message = "Kicker: Failed (#{status.exit_code})"
|
66
|
-
body = Kicker.silent? ? '' : status.output
|
67
|
-
growl(notifications[:failed], message, body, &DEFAULT_CALLBACK)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
rescue LoadError
|
74
|
-
end
|
@@ -1,170 +0,0 @@
|
|
1
|
-
require 'osx/cocoa'
|
2
|
-
|
3
|
-
module Growl
|
4
|
-
class Notifier < OSX::NSObject
|
5
|
-
VERSION = '1.0.2'
|
6
|
-
|
7
|
-
GROWL_IS_READY = "Lend Me Some Sugar; I Am Your Neighbor!"
|
8
|
-
GROWL_NOTIFICATION_CLICKED = "GrowlClicked!"
|
9
|
-
GROWL_NOTIFICATION_TIMED_OUT = "GrowlTimedOut!"
|
10
|
-
GROWL_KEY_CLICKED_CONTEXT = "ClickedContext"
|
11
|
-
|
12
|
-
PRIORITIES = {
|
13
|
-
:emergency => 2,
|
14
|
-
:high => 1,
|
15
|
-
:normal => 0,
|
16
|
-
:moderate => -1,
|
17
|
-
:very_low => -2,
|
18
|
-
}
|
19
|
-
|
20
|
-
class << self
|
21
|
-
# Returns the singleton instance of Growl::Notifier with which you register and send your Growl notifications.
|
22
|
-
def sharedInstance
|
23
|
-
@sharedInstance ||= alloc.init
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
attr_reader :application_name, :application_icon, :notifications, :default_notifications
|
28
|
-
attr_accessor :delegate
|
29
|
-
|
30
|
-
# Set to +true+ if you want to receive delegate callback messages,
|
31
|
-
# <tt>growlNotifierClicked_context</tt> & <tt>growlNotifierTimedOut_context</tt>,
|
32
|
-
# without the need to specify a <tt>:click_context</tt>.
|
33
|
-
#
|
34
|
-
# The default is +false+, which means your application won't receive any delegate
|
35
|
-
# callback messages if the <tt>:click_context</tt> is omitted.
|
36
|
-
attr_accessor :always_callback
|
37
|
-
|
38
|
-
# Registers the applications metadata and the notifications, that your application might send, to Growl.
|
39
|
-
# The +default_notifications+ are notifications that will be enabled by default, the regular +notifications+ are
|
40
|
-
# optional and should be enabled by the user in the Growl system preferences.
|
41
|
-
#
|
42
|
-
# Register the applications name and the notifications that will be used.
|
43
|
-
# * +default_notifications+ defaults to the regular +notifications+.
|
44
|
-
# * +application_icon+ defaults to OSX::NSApplication.sharedApplication.applicationIconImage.
|
45
|
-
#
|
46
|
-
# Growl::Notifier.sharedInstance.register 'FoodApp', ['YourHamburgerIsReady', 'OhSomeoneElseAteIt']
|
47
|
-
#
|
48
|
-
# Register the applications name, the notifications plus the default notifications that will be used and the icon that's to be used in the Growl notifications.
|
49
|
-
#
|
50
|
-
# Growl::Notifier.sharedInstance.register 'FoodApp', ['YourHamburgerIsReady', 'OhSomeoneElseAteIt'], ['DefaultNotification], OSX::NSImage.imageNamed('GreasyHamburger')
|
51
|
-
def register(application_name, notifications, default_notifications = nil, application_icon = nil)
|
52
|
-
@application_name, @application_icon = application_name, (application_icon || OSX::NSApplication.sharedApplication.applicationIconImage)
|
53
|
-
@notifications, @default_notifications = notifications, (default_notifications || notifications)
|
54
|
-
@callbacks = {}
|
55
|
-
send_registration!
|
56
|
-
end
|
57
|
-
|
58
|
-
# Sends a Growl notification.
|
59
|
-
#
|
60
|
-
# * +notification_name+ : the name of one of the notifcations that your apllication registered with Growl. See register for more info.
|
61
|
-
# * +title+ : the title that should be used in the Growl notification.
|
62
|
-
# * +description+ : the body of the Grow notification.
|
63
|
-
# * +options+ : specifies a few optional options:
|
64
|
-
# * <tt>:sticky</tt> : indicates if the Grow notification should "stick" to the screen. Defaults to +false+.
|
65
|
-
# * <tt>:priority</tt> : sets the priority level of the Growl notification. Defaults to 0.
|
66
|
-
# * <tt>:click_context</tt> : a string describing the context of the notification. This is send back to the delegate so you can check what kind of notification it was. If omitted, no delegate messages will be send. You can disable this behaviour by setting always_callback to +true+.
|
67
|
-
# * <tt>:icon</tt> : specifies the icon to be used in the Growl notification. Defaults to the registered +application_icon+, see register for more info.
|
68
|
-
#
|
69
|
-
# Simple example:
|
70
|
-
#
|
71
|
-
# name = 'YourHamburgerIsReady'
|
72
|
-
# title = 'Your hamburger is ready for consumption!'
|
73
|
-
# description = 'Please pick it up at isle 4.'
|
74
|
-
#
|
75
|
-
# Growl::Notifier.sharedInstance.notify(name, title, description)
|
76
|
-
#
|
77
|
-
# Example with optional options:
|
78
|
-
#
|
79
|
-
# Growl::Notifier.sharedInstance.notify(name, title, description, :sticky => true, :priority => 1, :icon => OSX::NSImage.imageNamed('SuperBigHamburger'))
|
80
|
-
#
|
81
|
-
# When you pass notify a block, that block will be used as the callback handler if the Growl notification was clicked. Eg:
|
82
|
-
#
|
83
|
-
# Growl::Notifier.sharedInstance.notify(name, title, description, :sticky => true) do
|
84
|
-
# user_clicked_notification_so_do_something!
|
85
|
-
# end
|
86
|
-
def notify(notification_name, title, description, options = {}, &callback)
|
87
|
-
dict = {
|
88
|
-
:ApplicationName => @application_name,
|
89
|
-
:ApplicationPID => pid,
|
90
|
-
:NotificationName => notification_name,
|
91
|
-
:NotificationTitle => title,
|
92
|
-
:NotificationDescription => description,
|
93
|
-
:NotificationPriority => PRIORITIES[options[:priority]] || options[:priority] || 0
|
94
|
-
}
|
95
|
-
dict[:NotificationIcon] = options[:icon].TIFFRepresentation if options[:icon]
|
96
|
-
dict[:NotificationSticky] = 1 if options[:sticky]
|
97
|
-
|
98
|
-
context = {}
|
99
|
-
context[:user_click_context] = options[:click_context] if options[:click_context]
|
100
|
-
if block_given?
|
101
|
-
@callbacks[callback.object_id] = callback
|
102
|
-
context[:callback_object_id] = callback.object_id.to_s
|
103
|
-
end
|
104
|
-
dict[:NotificationClickContext] = context if always_callback || !context.empty?
|
105
|
-
|
106
|
-
notification_center.postNotificationName_object_userInfo_deliverImmediately(:GrowlNotification, nil, dict, true)
|
107
|
-
end
|
108
|
-
|
109
|
-
def onReady(notification)
|
110
|
-
send_registration!
|
111
|
-
end
|
112
|
-
|
113
|
-
def onClicked(notification)
|
114
|
-
user_context = nil
|
115
|
-
if context = notification.userInfo[GROWL_KEY_CLICKED_CONTEXT]
|
116
|
-
user_context = context[:user_click_context]
|
117
|
-
if callback_object_id = context[:callback_object_id]
|
118
|
-
@callbacks.delete(callback_object_id.to_i).call
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
@delegate.growlNotifierClicked_context(self, user_context) if @delegate && @delegate.respond_to?(:growlNotifierClicked_context)
|
123
|
-
end
|
124
|
-
|
125
|
-
def onTimeout(notification)
|
126
|
-
user_context = nil
|
127
|
-
if context = notification.userInfo[GROWL_KEY_CLICKED_CONTEXT]
|
128
|
-
@callbacks.delete(context[:callback_object_id].to_i) if context[:callback_object_id]
|
129
|
-
user_context = context[:user_click_context]
|
130
|
-
end
|
131
|
-
|
132
|
-
@delegate.growlNotifierTimedOut_context(self, user_context) if @delegate && @delegate.respond_to?(:growlNotifierTimedOut_context)
|
133
|
-
end
|
134
|
-
|
135
|
-
private
|
136
|
-
|
137
|
-
def pid
|
138
|
-
OSX::NSProcessInfo.processInfo.processIdentifier.to_i
|
139
|
-
end
|
140
|
-
|
141
|
-
def notification_center
|
142
|
-
OSX::NSDistributedNotificationCenter.defaultCenter
|
143
|
-
end
|
144
|
-
|
145
|
-
def send_registration!
|
146
|
-
add_observer 'onReady:', GROWL_IS_READY, false
|
147
|
-
add_observer 'onClicked:', GROWL_NOTIFICATION_CLICKED, true
|
148
|
-
add_observer 'onTimeout:', GROWL_NOTIFICATION_TIMED_OUT, true
|
149
|
-
|
150
|
-
dict = {
|
151
|
-
:ApplicationName => @application_name,
|
152
|
-
:ApplicationIcon => application_icon.TIFFRepresentation,
|
153
|
-
:AllNotifications => @notifications,
|
154
|
-
:DefaultNotifications => @default_notifications
|
155
|
-
}
|
156
|
-
|
157
|
-
notification_center.objc_send(
|
158
|
-
:postNotificationName, :GrowlApplicationRegistrationNotification,
|
159
|
-
:object, nil,
|
160
|
-
:userInfo, dict,
|
161
|
-
:deliverImmediately, true
|
162
|
-
)
|
163
|
-
end
|
164
|
-
|
165
|
-
def add_observer(selector, name, prepend_name_and_pid)
|
166
|
-
name = "#{@application_name}-#{pid}-#{name}" if prepend_name_and_pid
|
167
|
-
notification_center.addObserver_selector_name_object self, selector, name, nil
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.expand_path('../growl', __FILE__)
|
2
|
-
|
3
|
-
# Defines a few convenience methods that you can use in your class if you include the Growl module.
|
4
|
-
# Eg:
|
5
|
-
#
|
6
|
-
# class FoodReporter < OSX::NSObject
|
7
|
-
# include Growl
|
8
|
-
#
|
9
|
-
# def hamburger_time!
|
10
|
-
# growl 'YourHamburgerIsReady', 'Your hamburger is ready for consumption!', 'Please pick it up at isle 4.', :priority => 1 do
|
11
|
-
# throw_it_away_before_user_reaches_counter!
|
12
|
-
# end
|
13
|
-
# end
|
14
|
-
# end
|
15
|
-
module Growl
|
16
|
-
# Sends a Growl notification. See Growl::Notifier#notify for more info.
|
17
|
-
def growl(name, title, description, options = {}, &callback)
|
18
|
-
Growl::Notifier.sharedInstance.notify name, title, description, options, &callback
|
19
|
-
end
|
20
|
-
|
21
|
-
# Sends a sticky Growl notification. See Growl::Notifier#notify for more info.
|
22
|
-
def sticky_growl(name, title, description, options = {}, &callback)
|
23
|
-
growl name, title, description, options.merge!(:sticky => true), &callback
|
24
|
-
end
|
25
|
-
end
|