karl-growl 1.0.3
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.
- data/History.rdoc +41 -0
- data/Manifest +22 -0
- data/README.rdoc +111 -0
- data/Rakefile +16 -0
- data/examples/growl.rb +19 -0
- data/growl.gemspec +30 -0
- data/lib/growl/growl.rb +249 -0
- data/lib/growl/images/error.png +0 -0
- data/lib/growl/images/info.png +0 -0
- data/lib/growl/images/ok.png +0 -0
- data/lib/growl/images/warning.png +0 -0
- data/lib/growl/notify/growlnotify +0 -0
- data/lib/growl/notify/growlnotify.com +0 -0
- data/lib/growl/version.rb +4 -0
- data/lib/growl.rb +25 -0
- data/spec/fixtures/icon.icns +0 -0
- data/spec/fixtures/image.png +0 -0
- data/spec/growl_spec.rb +119 -0
- data/spec/spec_helper.rb +6 -0
- data/tasks/docs.rake +13 -0
- data/tasks/gemspec.rake +3 -0
- data/tasks/spec.rake +25 -0
- metadata +91 -0
data/History.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
=== 1.0.2 / 2009-04-19
|
3
|
+
|
4
|
+
* Added new gemspec
|
5
|
+
* Removed capitalized gemspec name causing build issues
|
6
|
+
|
7
|
+
=== 1.0.1 / 2009-04-19
|
8
|
+
|
9
|
+
* Changed url for ticketing system
|
10
|
+
|
11
|
+
=== 1.0.0 / 2009-04-13
|
12
|
+
|
13
|
+
* Added new examples
|
14
|
+
* Added growlnotify install docs [#3]
|
15
|
+
* Changed; Growl#notify now normalizes the :icon option key [#2] (checkout README)
|
16
|
+
|
17
|
+
=== 0.0.6 / 2009-04-09
|
18
|
+
|
19
|
+
* Added #notify_{ok,info,warning,error} and images
|
20
|
+
* Added examples and updated docs
|
21
|
+
* Refactored Growl::Base.switch
|
22
|
+
|
23
|
+
=== 0.0.5 / 2009-04-08
|
24
|
+
|
25
|
+
* Now returning nil when trying to instantiate Growl when not installed
|
26
|
+
|
27
|
+
=== 0.0.4 / 2009-04-08
|
28
|
+
|
29
|
+
* We dont want visionmedia-Growl, shesh :p, fixed to lowercase
|
30
|
+
|
31
|
+
=== 0.0.3 / 2009-04-08
|
32
|
+
|
33
|
+
* Added #Growl hash support
|
34
|
+
|
35
|
+
=== 0.0.2 / 2009-04-08
|
36
|
+
|
37
|
+
* Github build me!!!
|
38
|
+
|
39
|
+
=== 0.0.1 / 2009-04-08
|
40
|
+
|
41
|
+
* Initial release
|
data/Manifest
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
examples/growl.rb
|
2
|
+
growl.gemspec
|
3
|
+
History.rdoc
|
4
|
+
lib/growl/growl.rb
|
5
|
+
lib/growl/images/error.png
|
6
|
+
lib/growl/images/info.png
|
7
|
+
lib/growl/images/ok.png
|
8
|
+
lib/growl/images/warning.png
|
9
|
+
lib/growl/version.rb
|
10
|
+
lib/growl/notify/growlnotify
|
11
|
+
lib/growl/notify/growlnotify.com
|
12
|
+
lib/growl.rb
|
13
|
+
Manifest
|
14
|
+
Rakefile
|
15
|
+
README.rdoc
|
16
|
+
spec/fixtures/icon.icns
|
17
|
+
spec/fixtures/image.png
|
18
|
+
spec/growl_spec.rb
|
19
|
+
spec/spec_helper.rb
|
20
|
+
tasks/docs.rake
|
21
|
+
tasks/gemspec.rake
|
22
|
+
tasks/spec.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
= Growl
|
3
|
+
|
4
|
+
Ruby growlnotify 'bindings'.
|
5
|
+
|
6
|
+
== Examples
|
7
|
+
|
8
|
+
notification = Growl.new
|
9
|
+
notification.message = 'Hello World'
|
10
|
+
notification.sticky!
|
11
|
+
notification.icon = :jpeg
|
12
|
+
notification.run if Growl.installed?
|
13
|
+
|
14
|
+
# OR
|
15
|
+
|
16
|
+
Growl.notify {
|
17
|
+
self.message = 'Hello World'
|
18
|
+
self.icon = :jpeg
|
19
|
+
sticky!
|
20
|
+
}
|
21
|
+
|
22
|
+
# OR
|
23
|
+
|
24
|
+
Growl.notify do |n|
|
25
|
+
n.message = 'Hello World'
|
26
|
+
n.icon = :jpeg
|
27
|
+
n.stick!
|
28
|
+
end
|
29
|
+
|
30
|
+
# OR
|
31
|
+
|
32
|
+
Growl.notify 'Foo', :icon => :jpeg, :title => 'Growl'
|
33
|
+
|
34
|
+
# OR
|
35
|
+
|
36
|
+
include Growl
|
37
|
+
notify 'Email received', :sticky => true
|
38
|
+
|
39
|
+
# Convenience methods
|
40
|
+
|
41
|
+
notify_ok 'Deployment successful'
|
42
|
+
notify_info 'Email received'
|
43
|
+
notify_warning 'Merge required'
|
44
|
+
notify_error 'Failed to send email', :sticky => true
|
45
|
+
|
46
|
+
== Normaized Icons
|
47
|
+
|
48
|
+
The :icon option key is automatically normalized when you use any of the Growl#notify
|
49
|
+
methods, this removes the need to explicitly use :appIcon, :image, etc.
|
50
|
+
|
51
|
+
notify 'App icon', :icon => :Safari
|
52
|
+
notify 'Jpeg icon', :icon => :jpeg
|
53
|
+
notify 'Image icon', :icon => 'path/to/image.png'
|
54
|
+
notify 'Icns icon', :icon => 'path/to/icon.icns'
|
55
|
+
notify 'Path extname icon', :icon => 'foo.rb'
|
56
|
+
|
57
|
+
== Features
|
58
|
+
|
59
|
+
* Check availability with Growl.installed?
|
60
|
+
* Check dependencies with Growl.version
|
61
|
+
* Use images, icon paths, application icons, or file format icons
|
62
|
+
* Sticky a notification making it appear until explicitly closed
|
63
|
+
* Set notification priority
|
64
|
+
* Convenience methods such as notify_ok, notify_warning, notify_error, and notify_info
|
65
|
+
* Etc (consult growlnotify --help)
|
66
|
+
|
67
|
+
== Installing growlnotify
|
68
|
+
|
69
|
+
Visit http://growl.info/documentation.php for installation help.
|
70
|
+
|
71
|
+
== Known Issues
|
72
|
+
|
73
|
+
It seems that growlnotify will essentially ignore or block excessive usage
|
74
|
+
of the notifications at random. To prevent this you may need to do something like
|
75
|
+
below if you are calling many in sequence:
|
76
|
+
|
77
|
+
notify 'Something'; sleep 0.2
|
78
|
+
notify_ok 'Updated'; sleep 0.2
|
79
|
+
notify_info 'You have new mail'; sleep 0.2
|
80
|
+
notify_warning 'Merged required'; sleep 0.2
|
81
|
+
notify_error 'Oh Noes!'; sleep 0.2
|
82
|
+
|
83
|
+
== Contribute
|
84
|
+
|
85
|
+
Fork / send a pull request or submit a ticket at:
|
86
|
+
http://github.com/visionmedia/growl/issues
|
87
|
+
|
88
|
+
== License:
|
89
|
+
|
90
|
+
(The MIT License)
|
91
|
+
|
92
|
+
Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
93
|
+
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
95
|
+
a copy of this software and associated documentation files (the
|
96
|
+
'Software'), to deal in the Software without restriction, including
|
97
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
98
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
99
|
+
permit persons to whom the Software is furnished to do so, subject to
|
100
|
+
the following conditions:
|
101
|
+
|
102
|
+
The above copyright notice and this permission notice shall be
|
103
|
+
included in all copies or substantial portions of the Software.
|
104
|
+
|
105
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
106
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
107
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
108
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
109
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
110
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
111
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
$:.unshift 'lib'
|
3
|
+
require 'growl'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rake'
|
6
|
+
require 'echoe'
|
7
|
+
|
8
|
+
Echoe.new "growl", Growl::VERSION do |p|
|
9
|
+
p.author = ["TJ Holowaychuk", "Karl O'Keeffe"]
|
10
|
+
p.email = "tj@vision-media.ca"
|
11
|
+
p.summary = "growlnotify bindings"
|
12
|
+
p.url = "http://github.com/visionmedia/growl"
|
13
|
+
p.runtime_dependencies = []
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir['tasks/**/*.rake'].sort.each { |f| load f }
|
data/examples/growl.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
3
|
+
require 'growl'
|
4
|
+
|
5
|
+
puts "growlnotify version #{Growl.version} installed"
|
6
|
+
|
7
|
+
imagepath = File.dirname(__FILE__) + '/../spec/fixtures/image.png'
|
8
|
+
iconpath = File.dirname(__FILE__) + '/../spec/fixtures/icon.icns'
|
9
|
+
|
10
|
+
include Growl
|
11
|
+
|
12
|
+
notify_info 'New email received', :sticky => true, :title => 'Some app'; sleep 0.2
|
13
|
+
notify_ok 'Deployment complete' ; sleep 0.2
|
14
|
+
notify_error 'Deployment failure' ; sleep 0.2
|
15
|
+
notify 'Safari icon', :icon => :Safari ; sleep 0.2
|
16
|
+
notify 'Jpeg icon', :icon => :jpeg ; sleep 0.2
|
17
|
+
notify 'Image icon', :icon => imagepath ; sleep 0.2
|
18
|
+
notify 'Icns icon', :icon => iconpath ; sleep 0.2
|
19
|
+
notify 'Path extname icon', :icon => 'foo.rb' ; sleep 0.2
|
data/growl.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{growl}
|
5
|
+
s.version = "1.0.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["TJ Holowaychuk, Karl O'Keeffe"]
|
9
|
+
s.date = %q{2009-07-17}
|
10
|
+
s.description = %q{growlnotify bindings}
|
11
|
+
s.email = %q{tj@vision-media.ca}
|
12
|
+
s.extra_rdoc_files = ["lib/growl/growl.rb", "lib/growl/images/error.png", "lib/growl/images/info.png", "lib/growl/images/ok.png", "lib/growl/images/warning.png", "lib/growl/version.rb", "lib/growl/notify/growlnotify", "lib/growl/notify/growlnotify.com", "lib/growl.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
13
|
+
s.files = ["examples/growl.rb", "growl.gemspec", "History.rdoc", "lib/growl/growl.rb", "lib/growl/images/error.png", "lib/growl/images/info.png", "lib/growl/images/ok.png", "lib/growl/images/warning.png", "lib/growl/version.rb", "lib/growl/notify/growlnotify", "lib/growl/notify/growlnotify.com", "lib/growl.rb", "Manifest", "Rakefile", "README.rdoc", "spec/fixtures/icon.icns", "spec/fixtures/image.png", "spec/growl_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
14
|
+
s.homepage = %q{http://github.com/visionmedia/growl}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Growl", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{growl}
|
18
|
+
s.rubygems_version = %q{1.3.4}
|
19
|
+
s.summary = %q{growlnotify bindings}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
data/lib/growl/growl.rb
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
|
2
|
+
module Growl
|
3
|
+
|
4
|
+
BIN = 'growlnotify'
|
5
|
+
PACKAGED_BIN = File.expand_path(File.dirname(__FILE__) + '/notify/growlnotify')
|
6
|
+
|
7
|
+
#--
|
8
|
+
# Exceptions
|
9
|
+
#++
|
10
|
+
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Display a growl notification +message+, with +options+
|
15
|
+
# documented below. Alternatively a +block+ may be passed
|
16
|
+
# which is then instance evaluated or yielded to the block.
|
17
|
+
#
|
18
|
+
# This method is simply returns nil when growlnotify
|
19
|
+
# is not installed, as growl notifications should never
|
20
|
+
# be the only means of communication between your application
|
21
|
+
# and your user.
|
22
|
+
#
|
23
|
+
# === Examples
|
24
|
+
#
|
25
|
+
# Growl.notify 'Hello'
|
26
|
+
# Growl.notify 'Hello', :title => 'TJ Says:', :sticky => true
|
27
|
+
# Growl.notify { |n| n.message = 'Hello'; n.sticky! }
|
28
|
+
# Growl.notify { self.message = 'Hello'; sticky! }
|
29
|
+
#
|
30
|
+
|
31
|
+
def notify message = nil, options = {}, &block
|
32
|
+
return unless Growl.installed?
|
33
|
+
options.merge! :message => message if message
|
34
|
+
Growl.normalize_icon! options
|
35
|
+
Growl.new(options, &block).run
|
36
|
+
end
|
37
|
+
module_function :notify
|
38
|
+
|
39
|
+
#--
|
40
|
+
# Generate notify_STATUS methods.
|
41
|
+
#++
|
42
|
+
|
43
|
+
%w( ok info warning error ).each do |type|
|
44
|
+
define_method :"notify_#{type}" do |message, *args|
|
45
|
+
options = args.first || {}
|
46
|
+
image = File.join File.expand_path(File.dirname(__FILE__)), 'images', "#{type}.png"
|
47
|
+
notify message, options.merge(:image => image)
|
48
|
+
end
|
49
|
+
module_function :"notify_#{type}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.is_windows?
|
53
|
+
processor, platform, *rest = RUBY_PLATFORM.split("-")
|
54
|
+
platform == 'mswin32'
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Execute +args+ against the binary.
|
59
|
+
|
60
|
+
def self.exec *args
|
61
|
+
bin = existing_install? ? BIN : PACKAGED_BIN
|
62
|
+
|
63
|
+
bin += '.com' if is_windows?
|
64
|
+
|
65
|
+
puts bin
|
66
|
+
puts *args
|
67
|
+
|
68
|
+
Kernel.system bin, *args
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Return the version triple of the binary.
|
73
|
+
|
74
|
+
def self.version
|
75
|
+
return existing_version || packaged_version
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Check if the binary is installed and accessable.
|
80
|
+
|
81
|
+
def self.installed?
|
82
|
+
version
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.existing_version
|
86
|
+
@existing_version ||= `#{BIN} --version`.split[1] rescue false
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.existing_install?
|
90
|
+
existing_version
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.packaged_version
|
94
|
+
'0.0.0'
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Return an instance of Growl::Base or nil when not installed.
|
99
|
+
|
100
|
+
def self.new *args, &block
|
101
|
+
return unless installed?
|
102
|
+
Base.new *args, &block
|
103
|
+
end
|
104
|
+
|
105
|
+
##
|
106
|
+
# Normalize the icon option in +options+. This performs
|
107
|
+
# the following operations in order to allow for the :icon
|
108
|
+
# key to work with a variety of values:
|
109
|
+
#
|
110
|
+
# * path to an icon sets :iconpath
|
111
|
+
# * path to an image sets :image
|
112
|
+
# * capitalized word sets :appIcon
|
113
|
+
# * filename uses extname as :icon
|
114
|
+
# * otherwise treated as :icon
|
115
|
+
|
116
|
+
def self.normalize_icon! options = {}
|
117
|
+
return unless options.include? :icon
|
118
|
+
icon = options.delete(:icon).to_s
|
119
|
+
if File.exists? icon
|
120
|
+
if File.extname(icon) == '.icns'
|
121
|
+
options[:iconpath] = icon
|
122
|
+
else
|
123
|
+
options[:image] = icon
|
124
|
+
end
|
125
|
+
else
|
126
|
+
if icon.capitalize == icon
|
127
|
+
options[:appIcon] = icon
|
128
|
+
elsif !(ext = File.extname(icon)).empty?
|
129
|
+
options[:icon] = ext[1..-1]
|
130
|
+
else
|
131
|
+
options[:icon] = icon
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
#--
|
137
|
+
# Growl base
|
138
|
+
#++
|
139
|
+
|
140
|
+
class Base
|
141
|
+
attr_reader :args
|
142
|
+
|
143
|
+
##
|
144
|
+
# Initialize with optional +block+, which is then
|
145
|
+
# instance evaled or yielded depending on the blocks arity.
|
146
|
+
|
147
|
+
def initialize options = {}, &block
|
148
|
+
@args = []
|
149
|
+
if block_given?
|
150
|
+
if block.arity > 0
|
151
|
+
yield self
|
152
|
+
else
|
153
|
+
self.instance_eval &block
|
154
|
+
end
|
155
|
+
else
|
156
|
+
options.each do |key, value|
|
157
|
+
send :"#{key}=", value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def is_windows?
|
163
|
+
processor, platform, *rest = RUBY_PLATFORM.split("-")
|
164
|
+
platform == 'mswin32'
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# Run the notification, only --message is required.
|
169
|
+
|
170
|
+
def run
|
171
|
+
raise Error, 'message required' unless message
|
172
|
+
self.class.switches.each do |name, win_name|
|
173
|
+
if send(:"#{name}?")
|
174
|
+
value = send(name).to_s if send(name) && !(TrueClass === send(name))
|
175
|
+
if is_windows?
|
176
|
+
next if win_name.nil?
|
177
|
+
|
178
|
+
arg = is_windows? ? ( (win_name == :EMPTY) ? "" : "/#{win_name}:") : "--#{name}"
|
179
|
+
args << arg + value
|
180
|
+
else
|
181
|
+
args << "--#{name}"
|
182
|
+
args << value
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
Growl.exec *args
|
187
|
+
end
|
188
|
+
|
189
|
+
##
|
190
|
+
# Define a switch +name+.
|
191
|
+
#
|
192
|
+
# === examples
|
193
|
+
#
|
194
|
+
# switch :sticky
|
195
|
+
#
|
196
|
+
# @growl.sticky! # => true
|
197
|
+
# @growl.sticky? # => true
|
198
|
+
# @growl.sticky = false # => false
|
199
|
+
# @growl.sticky? # => false
|
200
|
+
#
|
201
|
+
|
202
|
+
def self.switch name, win_name
|
203
|
+
ivar = :"@#{name}"
|
204
|
+
(@switches ||= []) << [name, win_name]
|
205
|
+
attr_accessor :"#{name}"
|
206
|
+
define_method(:"#{name}?") { instance_variable_get(ivar) }
|
207
|
+
define_method(:"#{name}!") { instance_variable_set(ivar, true) }
|
208
|
+
end
|
209
|
+
|
210
|
+
##
|
211
|
+
# Return array of available switch symbols.
|
212
|
+
|
213
|
+
def self.switches
|
214
|
+
@switches
|
215
|
+
end
|
216
|
+
|
217
|
+
#--
|
218
|
+
# Switches
|
219
|
+
#++
|
220
|
+
|
221
|
+
switch :title, :t
|
222
|
+
switch :sticky, :s
|
223
|
+
switch :priority, :p
|
224
|
+
switch :host, :host
|
225
|
+
switch :password, :pass
|
226
|
+
switch :port, :port
|
227
|
+
|
228
|
+
switch :name, :a
|
229
|
+
switch :message, :EMPTY
|
230
|
+
switch :image, :i
|
231
|
+
switch :identifier, :id
|
232
|
+
|
233
|
+
switch :iconpath, nil
|
234
|
+
switch :appIcon, nil
|
235
|
+
switch :icon, nil
|
236
|
+
|
237
|
+
switch :udp, nil
|
238
|
+
switch :auth, :hash
|
239
|
+
switch :crypt, nil
|
240
|
+
|
241
|
+
#r
|
242
|
+
#n
|
243
|
+
#cu
|
244
|
+
#cc
|
245
|
+
#enc
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/growl.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'growl/version'
|
25
|
+
require 'growl/growl'
|
File without changes
|
Binary file
|
data/spec/growl_spec.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
describe Growl do
|
3
|
+
|
4
|
+
describe "#installed?" do
|
5
|
+
it "should check if growlnotify is available" do
|
6
|
+
Growl.should be_installed
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#version" do
|
11
|
+
it "should return only the version triple" do
|
12
|
+
Growl.version.should match(/\d+\.\d+\.\d+/)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
@growl = Growl.new
|
18
|
+
@growl.message = 'Hello World'
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#notify" do
|
22
|
+
it "should accept a block, running immediately after" do
|
23
|
+
Growl.notify { |n| n.message = 'Invoked via Growl' }.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should accept a hash" do
|
27
|
+
Growl.notify('Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl').should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return nil when not installed" do
|
31
|
+
Growl.stub!(:installed?).and_return(false)
|
32
|
+
Growl.new.should be_nil
|
33
|
+
lambda { Growl.notify 'I should never show :)' }.should_not raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
%w( ok info warning error ).each do |type|
|
38
|
+
describe "#notify_#{type}" do
|
39
|
+
it "should display #{type} notifications" do
|
40
|
+
Growl.send(:"notify_#{type}", "Hello", :title => type).should be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#run" do
|
46
|
+
it "should fail when no message is present" do
|
47
|
+
lambda { Growl.new.run }.should raise_error(Growl::Error, /message required/)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should execute a growl notification" do
|
51
|
+
@growl.run.should be_true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#sticky!" do
|
56
|
+
it "should make a notification stick until explicitly closed" do
|
57
|
+
@growl.sticky = false
|
58
|
+
@growl.should_not be_sticky
|
59
|
+
@growl.sticky!
|
60
|
+
@growl.should be_sticky
|
61
|
+
@growl.message = 'Im Sticky'
|
62
|
+
@growl.run.should be_true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#name" do
|
67
|
+
it "should set the application name" do
|
68
|
+
@growl.name = 'Ruby'
|
69
|
+
@growl.run.should be_true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#title" do
|
74
|
+
it "should add a title" do
|
75
|
+
@growl.title = 'Im a title'
|
76
|
+
@growl.message = 'I am not a title'
|
77
|
+
@growl.run.should be_true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#appIcon" do
|
82
|
+
it "should use an application for the icon" do
|
83
|
+
@growl.appIcon = 'Safari'
|
84
|
+
@growl.message = 'Safari icon'
|
85
|
+
@growl.run.should be_true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#iconpath" do
|
90
|
+
it "should use a path for the icon" do
|
91
|
+
@growl.iconpath = fixture 'icon.icns'
|
92
|
+
@growl.message = 'Custom icon'
|
93
|
+
@growl.run.should be_true
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#icon" do
|
98
|
+
it "should use an icon based on a file type" do
|
99
|
+
@growl.icon = 'jpeg'
|
100
|
+
@growl.message = 'Jpeg Icon'
|
101
|
+
@growl.run.should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should allow symbols" do
|
105
|
+
@growl.icon = :jpeg
|
106
|
+
@growl.message = 'Jpeg icon with symbol'
|
107
|
+
@growl.run.should be_true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#image" do
|
112
|
+
it "should use an image path for the 'icon'" do
|
113
|
+
@growl.image = fixture 'image.png'
|
114
|
+
@growl.message = 'Image as icon'
|
115
|
+
@growl.run.should be_true
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tasks/docs.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
namespace :docs do
|
3
|
+
|
4
|
+
desc 'Remove rdoc products'
|
5
|
+
task :remove => [:clobber_docs]
|
6
|
+
|
7
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
8
|
+
task :open do
|
9
|
+
browser = ENV["BROWSER"] || "safari"
|
10
|
+
sh "open -a #{browser} doc/index.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/tasks/gemspec.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: karl-growl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TJ Holowaychuk, Karl O'Keeffe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-17 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: growlnotify bindings
|
17
|
+
email: tj@vision-media.ca
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- lib/growl/growl.rb
|
24
|
+
- lib/growl/images/error.png
|
25
|
+
- lib/growl/images/info.png
|
26
|
+
- lib/growl/images/ok.png
|
27
|
+
- lib/growl/images/warning.png
|
28
|
+
- lib/growl/version.rb
|
29
|
+
- lib/growl/notify/growlnotify
|
30
|
+
- lib/growl/notify/growlnotify.com
|
31
|
+
- lib/growl.rb
|
32
|
+
- README.rdoc
|
33
|
+
- tasks/docs.rake
|
34
|
+
- tasks/gemspec.rake
|
35
|
+
- tasks/spec.rake
|
36
|
+
files:
|
37
|
+
- examples/growl.rb
|
38
|
+
- growl.gemspec
|
39
|
+
- History.rdoc
|
40
|
+
- lib/growl/growl.rb
|
41
|
+
- lib/growl/images/error.png
|
42
|
+
- lib/growl/images/info.png
|
43
|
+
- lib/growl/images/ok.png
|
44
|
+
- lib/growl/images/warning.png
|
45
|
+
- lib/growl/version.rb
|
46
|
+
- lib/growl/notify/growlnotify
|
47
|
+
- lib/growl/notify/growlnotify.com
|
48
|
+
- lib/growl.rb
|
49
|
+
- Manifest
|
50
|
+
- Rakefile
|
51
|
+
- README.rdoc
|
52
|
+
- spec/fixtures/icon.icns
|
53
|
+
- spec/fixtures/image.png
|
54
|
+
- spec/growl_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
- tasks/docs.rake
|
57
|
+
- tasks/gemspec.rake
|
58
|
+
- tasks/spec.rake
|
59
|
+
has_rdoc: false
|
60
|
+
homepage: http://github.com/visionmedia/growl
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options:
|
63
|
+
- --line-numbers
|
64
|
+
- --inline-source
|
65
|
+
- --title
|
66
|
+
- Growl
|
67
|
+
- --main
|
68
|
+
- README.rdoc
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "1.2"
|
82
|
+
version:
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: growl
|
86
|
+
rubygems_version: 1.2.0
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: growlnotify bindings
|
90
|
+
test_files: []
|
91
|
+
|