sanultari-growl 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +50 -0
- data/Manifest +23 -0
- data/README.rdoc +112 -0
- data/Rakefile +16 -0
- data/examples/growl.rb +19 -0
- data/growl.gemspec +29 -0
- data/lib/growl.rb +25 -0
- data/lib/growl/growl.rb +232 -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 +4 -0
- data/lib/growl/notify/growlnotify-original +0 -0
- data/lib/growl/notify/growlnotify.com +0 -0
- data/lib/growl/version.rb +4 -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 +22 -0
- metadata +106 -0
data/History.rdoc
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
=== 1.0.5 / 2009-07-17
|
2
|
+
|
3
|
+
* Improved README and History documentation
|
4
|
+
|
5
|
+
=== 1.0.4 / 2009-07-17
|
6
|
+
|
7
|
+
* Bundled growlnotify (so always counts as installed)
|
8
|
+
* Added support for Windows
|
9
|
+
* Wrap OSX growlnotify to avoid dropped notifications
|
10
|
+
|
11
|
+
=== 1.0.2 / 2009-04-19
|
12
|
+
|
13
|
+
* Added new gemspec
|
14
|
+
* Removed capitalized gemspec name causing build issues
|
15
|
+
|
16
|
+
=== 1.0.1 / 2009-04-19
|
17
|
+
|
18
|
+
* Changed url for ticketing system
|
19
|
+
|
20
|
+
=== 1.0.0 / 2009-04-13
|
21
|
+
|
22
|
+
* Added new examples
|
23
|
+
* Added growlnotify install docs [#3]
|
24
|
+
* Changed; Growl#notify now normalizes the :icon option key [#2] (checkout README)
|
25
|
+
|
26
|
+
=== 0.0.6 / 2009-04-09
|
27
|
+
|
28
|
+
* Added #notify_{ok,info,warning,error} and images
|
29
|
+
* Added examples and updated docs
|
30
|
+
* Refactored Growl::Base.switch
|
31
|
+
|
32
|
+
=== 0.0.5 / 2009-04-08
|
33
|
+
|
34
|
+
* Now returning nil when trying to instantiate Growl when not installed
|
35
|
+
|
36
|
+
=== 0.0.4 / 2009-04-08
|
37
|
+
|
38
|
+
* We dont want visionmedia-Growl, shesh :p, fixed to lowercase
|
39
|
+
|
40
|
+
=== 0.0.3 / 2009-04-08
|
41
|
+
|
42
|
+
* Added #Growl hash support
|
43
|
+
|
44
|
+
=== 0.0.2 / 2009-04-08
|
45
|
+
|
46
|
+
* Github build me!!!
|
47
|
+
|
48
|
+
=== 0.0.1 / 2009-04-08
|
49
|
+
|
50
|
+
* Initial release
|
data/Manifest
ADDED
@@ -0,0 +1,23 @@
|
|
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-original
|
12
|
+
lib/growl/notify/growlnotify.com
|
13
|
+
lib/growl.rb
|
14
|
+
Manifest
|
15
|
+
Rakefile
|
16
|
+
README.rdoc
|
17
|
+
spec/fixtures/icon.icns
|
18
|
+
spec/fixtures/image.png
|
19
|
+
spec/growl_spec.rb
|
20
|
+
spec/spec_helper.rb
|
21
|
+
tasks/docs.rake
|
22
|
+
tasks/gemspec.rake
|
23
|
+
tasks/spec.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,112 @@
|
|
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
|
+
Normalised icons only work on OSX.
|
58
|
+
|
59
|
+
To support OSX and Windows always give a path to an image, e.g.
|
60
|
+
|
61
|
+
:image => 'path/to/image.png'
|
62
|
+
|
63
|
+
== Features
|
64
|
+
|
65
|
+
* Packaged with growlnotify (so notificatons always available)
|
66
|
+
* Support for Growl for Windows
|
67
|
+
* Wraps growlnotify to avoid dropped notificatons on OSX
|
68
|
+
* Use images, icon paths, application icons, or file format icons
|
69
|
+
* Sticky a notification making it appear until explicitly closed
|
70
|
+
* Set notification priority
|
71
|
+
* Convenience methods such as notify_ok, notify_warning, notify_error, and notify_info
|
72
|
+
* Etc (consult growlnotify --help)
|
73
|
+
|
74
|
+
== Known Issues
|
75
|
+
|
76
|
+
Not all switches work on Windows. Unsupported switches are:
|
77
|
+
|
78
|
+
:iconpath
|
79
|
+
:appIcon
|
80
|
+
:icon
|
81
|
+
:udp
|
82
|
+
:crypt
|
83
|
+
|
84
|
+
== Contribute
|
85
|
+
|
86
|
+
Fork / send a pull request or submit a ticket at:
|
87
|
+
http://github.com/visionmedia/growl/issues
|
88
|
+
|
89
|
+
== License:
|
90
|
+
|
91
|
+
(The MIT License)
|
92
|
+
|
93
|
+
Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
94
|
+
|
95
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
96
|
+
a copy of this software and associated documentation files (the
|
97
|
+
'Software'), to deal in the Software without restriction, including
|
98
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
99
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
100
|
+
permit persons to whom the Software is furnished to do so, subject to
|
101
|
+
the following conditions:
|
102
|
+
|
103
|
+
The above copyright notice and this permission notice shall be
|
104
|
+
included in all copies or substantial portions of the Software.
|
105
|
+
|
106
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
107
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
108
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
109
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
110
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
111
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
112
|
+
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,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{sanultari-growl}
|
5
|
+
s.version = "1.0.5"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = [%q{TJ Holowaychuk, Karl O'Keeffe}]
|
9
|
+
s.date = %q{2011-08-10}
|
10
|
+
s.description = %q{growlnotify bindings}
|
11
|
+
s.email = %q{tj@vision-media.ca}
|
12
|
+
s.extra_rdoc_files = [%q{lib/growl/growl.rb}, %q{lib/growl/images/error.png}, %q{lib/growl/images/info.png}, %q{lib/growl/images/ok.png}, %q{lib/growl/images/warning.png}, %q{lib/growl/version.rb}, %q{lib/growl/notify/growlnotify}, %q{lib/growl/notify/growlnotify-original}, %q{lib/growl/notify/growlnotify.com}, %q{lib/growl.rb}, %q{README.rdoc}, %q{tasks/docs.rake}, %q{tasks/gemspec.rake}, %q{tasks/spec.rake}]
|
13
|
+
s.files = [%q{examples/growl.rb}, %q{growl.gemspec}, %q{History.rdoc}, %q{lib/growl/growl.rb}, %q{lib/growl/images/error.png}, %q{lib/growl/images/info.png}, %q{lib/growl/images/ok.png}, %q{lib/growl/images/warning.png}, %q{lib/growl/version.rb}, %q{lib/growl/notify/growlnotify}, %q{lib/growl/notify/growlnotify-original}, %q{lib/growl/notify/growlnotify.com}, %q{lib/growl.rb}, %q{Manifest}, %q{Rakefile}, %q{README.rdoc}, %q{spec/fixtures/icon.icns}, %q{spec/fixtures/image.png}, %q{spec/growl_spec.rb}, %q{spec/spec_helper.rb}, %q{tasks/docs.rake}, %q{tasks/gemspec.rake}, %q{tasks/spec.rake}]
|
14
|
+
s.homepage = %q{http://github.com/visionmedia/growl}
|
15
|
+
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Growl}, %q{--main}, %q{README.rdoc}]
|
16
|
+
s.require_paths = [%q{lib}]
|
17
|
+
s.rubyforge_project = %q{growl}
|
18
|
+
s.rubygems_version = %q{1.8.5}
|
19
|
+
s.summary = %q{growlnotify bindings}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
else
|
26
|
+
end
|
27
|
+
else
|
28
|
+
end
|
29
|
+
end
|
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'
|
data/lib/growl/growl.rb
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
|
2
|
+
module Growl
|
3
|
+
|
4
|
+
PACKAGED_BIN = File.expand_path(File.dirname(__FILE__) + '/notify/growlnotify')
|
5
|
+
|
6
|
+
#--
|
7
|
+
# Exceptions
|
8
|
+
#++
|
9
|
+
|
10
|
+
class Error < StandardError; end
|
11
|
+
|
12
|
+
##
|
13
|
+
# Display a growl notification +message+, with +options+
|
14
|
+
# documented below. Alternatively a +block+ may be passed
|
15
|
+
# which is then instance evaluated or yielded to the block.
|
16
|
+
#
|
17
|
+
# This method is simply returns nil when growlnotify
|
18
|
+
# is not installed, as growl notifications should never
|
19
|
+
# be the only means of communication between your application
|
20
|
+
# and your user.
|
21
|
+
#
|
22
|
+
# === Examples
|
23
|
+
#
|
24
|
+
# Growl.notify 'Hello'
|
25
|
+
# Growl.notify 'Hello', :title => 'TJ Says:', :sticky => true
|
26
|
+
# Growl.notify { |n| n.message = 'Hello'; n.sticky! }
|
27
|
+
# Growl.notify { self.message = 'Hello'; sticky! }
|
28
|
+
#
|
29
|
+
|
30
|
+
def notify message = nil, options = {}, &block
|
31
|
+
return unless Growl.installed?
|
32
|
+
options.merge! :message => message if message
|
33
|
+
Growl.normalize_icon! options
|
34
|
+
Growl.new(options, &block).run
|
35
|
+
end
|
36
|
+
module_function :notify
|
37
|
+
|
38
|
+
#--
|
39
|
+
# Generate notify_STATUS methods.
|
40
|
+
#++
|
41
|
+
|
42
|
+
%w( ok info warning error ).each do |type|
|
43
|
+
define_method :"notify_#{type}" do |message, *args|
|
44
|
+
options = args.first || {}
|
45
|
+
image = File.join File.expand_path(File.dirname(__FILE__)), 'images', "#{type}.png"
|
46
|
+
notify message, options.merge(:image => image)
|
47
|
+
end
|
48
|
+
module_function :"notify_#{type}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.is_windows?
|
52
|
+
processor, platform, *rest = RUBY_PLATFORM.split("-")
|
53
|
+
platform == 'mswin32' || platform == 'mingw32'
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Execute +args+ against the binary.
|
58
|
+
|
59
|
+
def self.exec *args
|
60
|
+
bin = PACKAGED_BIN
|
61
|
+
bin += '.com' if is_windows?
|
62
|
+
|
63
|
+
Kernel.system bin, *args
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# Return the version triple of the binary.
|
68
|
+
|
69
|
+
def self.version
|
70
|
+
return '0.0.0'
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Check if the binary is installed and accessable.
|
75
|
+
|
76
|
+
def self.installed?
|
77
|
+
version
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Return an instance of Growl::Base or nil when not installed.
|
82
|
+
|
83
|
+
def self.new *args, &block
|
84
|
+
return unless installed?
|
85
|
+
Base.new *args, &block
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Normalize the icon option in +options+. This performs
|
90
|
+
# the following operations in order to allow for the :icon
|
91
|
+
# key to work with a variety of values:
|
92
|
+
#
|
93
|
+
# * path to an icon sets :iconpath
|
94
|
+
# * path to an image sets :image
|
95
|
+
# * capitalized word sets :appIcon
|
96
|
+
# * filename uses extname as :icon
|
97
|
+
# * otherwise treated as :icon
|
98
|
+
|
99
|
+
def self.normalize_icon! options = {}
|
100
|
+
return unless options.include? :icon
|
101
|
+
icon = options.delete(:icon).to_s
|
102
|
+
if File.exists? icon
|
103
|
+
if File.extname(icon) == '.icns'
|
104
|
+
options[:iconpath] = icon
|
105
|
+
else
|
106
|
+
options[:image] = icon
|
107
|
+
end
|
108
|
+
else
|
109
|
+
if icon.capitalize == icon
|
110
|
+
options[:appIcon] = icon
|
111
|
+
elsif !(ext = File.extname(icon)).empty?
|
112
|
+
options[:icon] = ext[1..-1]
|
113
|
+
else
|
114
|
+
options[:icon] = icon
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
#--
|
120
|
+
# Growl base
|
121
|
+
#++
|
122
|
+
|
123
|
+
class Base
|
124
|
+
attr_reader :args
|
125
|
+
|
126
|
+
##
|
127
|
+
# Initialize with optional +block+, which is then
|
128
|
+
# instance evaled or yielded depending on the blocks arity.
|
129
|
+
|
130
|
+
def initialize options = {}, &block
|
131
|
+
@args = []
|
132
|
+
if block_given?
|
133
|
+
if block.arity > 0
|
134
|
+
yield self
|
135
|
+
else
|
136
|
+
self.instance_eval &block
|
137
|
+
end
|
138
|
+
else
|
139
|
+
options.each do |key, value|
|
140
|
+
send :"#{key}=", value
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def is_windows?
|
146
|
+
processor, platform, *rest = RUBY_PLATFORM.split("-")
|
147
|
+
platform == 'mswin32' || platform == 'mingw32'
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# Run the notification, only --message is required.
|
152
|
+
|
153
|
+
def run
|
154
|
+
raise Error, 'message required' unless message
|
155
|
+
self.class.switches.each do |name, win_name|
|
156
|
+
if send(:"#{name}?")
|
157
|
+
value = send(name).to_s if send(name) && !(TrueClass === send(name))
|
158
|
+
if is_windows?
|
159
|
+
next if win_name.nil?
|
160
|
+
|
161
|
+
arg = is_windows? ? ( (win_name == :EMPTY) ? "" : "/#{win_name}:") : "--#{name}"
|
162
|
+
args << arg + value
|
163
|
+
else
|
164
|
+
args << "--#{name}"
|
165
|
+
args << value
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
Growl.exec *args
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# Define a switch +name+.
|
174
|
+
#
|
175
|
+
# === examples
|
176
|
+
#
|
177
|
+
# switch :sticky
|
178
|
+
#
|
179
|
+
# @growl.sticky! # => true
|
180
|
+
# @growl.sticky? # => true
|
181
|
+
# @growl.sticky = false # => false
|
182
|
+
# @growl.sticky? # => false
|
183
|
+
#
|
184
|
+
|
185
|
+
def self.switch name, win_name
|
186
|
+
ivar = :"@#{name}"
|
187
|
+
(@switches ||= []) << [name, win_name]
|
188
|
+
attr_accessor :"#{name}"
|
189
|
+
define_method(:"#{name}?") { instance_variable_get(ivar) }
|
190
|
+
define_method(:"#{name}!") { instance_variable_set(ivar, true) }
|
191
|
+
end
|
192
|
+
|
193
|
+
##
|
194
|
+
# Return array of available switch symbols.
|
195
|
+
|
196
|
+
def self.switches
|
197
|
+
@switches
|
198
|
+
end
|
199
|
+
|
200
|
+
#--
|
201
|
+
# Switches
|
202
|
+
#++
|
203
|
+
|
204
|
+
switch :title, :t
|
205
|
+
switch :sticky, :s
|
206
|
+
switch :priority, :p
|
207
|
+
switch :host, :host
|
208
|
+
switch :password, :pass
|
209
|
+
switch :port, :port
|
210
|
+
|
211
|
+
switch :name, :a
|
212
|
+
switch :message, :EMPTY
|
213
|
+
switch :image, :i
|
214
|
+
switch :identifier, :id
|
215
|
+
|
216
|
+
switch :iconpath, nil
|
217
|
+
switch :appIcon, nil
|
218
|
+
switch :icon, nil
|
219
|
+
|
220
|
+
switch :udp, nil
|
221
|
+
switch :auth, :hash
|
222
|
+
switch :crypt, nil
|
223
|
+
|
224
|
+
#r
|
225
|
+
#n
|
226
|
+
#cu
|
227
|
+
#cc
|
228
|
+
#enc
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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,22 @@
|
|
1
|
+
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
6
|
+
t.rspec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :spec do
|
10
|
+
|
11
|
+
desc "Run all specifications verbosely"
|
12
|
+
RSpec::Core::RakeTask.new(:verbose) do |t|
|
13
|
+
t.rspec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
17
|
+
RSpec::Core::RakeTask.new(:select) do |t|
|
18
|
+
t.pattern = ENV["SPEC"]
|
19
|
+
t.rspec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sanultari-growl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- TJ Holowaychuk, Karl O'Keeffe
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-10 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: growlnotify bindings
|
22
|
+
email: tj@vision-media.ca
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- lib/growl/growl.rb
|
29
|
+
- lib/growl/images/error.png
|
30
|
+
- lib/growl/images/info.png
|
31
|
+
- lib/growl/images/ok.png
|
32
|
+
- lib/growl/images/warning.png
|
33
|
+
- lib/growl/version.rb
|
34
|
+
- lib/growl/notify/growlnotify
|
35
|
+
- lib/growl/notify/growlnotify-original
|
36
|
+
- lib/growl/notify/growlnotify.com
|
37
|
+
- lib/growl.rb
|
38
|
+
- README.rdoc
|
39
|
+
- tasks/docs.rake
|
40
|
+
- tasks/gemspec.rake
|
41
|
+
- tasks/spec.rake
|
42
|
+
files:
|
43
|
+
- examples/growl.rb
|
44
|
+
- growl.gemspec
|
45
|
+
- History.rdoc
|
46
|
+
- lib/growl/growl.rb
|
47
|
+
- lib/growl/images/error.png
|
48
|
+
- lib/growl/images/info.png
|
49
|
+
- lib/growl/images/ok.png
|
50
|
+
- lib/growl/images/warning.png
|
51
|
+
- lib/growl/version.rb
|
52
|
+
- lib/growl/notify/growlnotify
|
53
|
+
- lib/growl/notify/growlnotify-original
|
54
|
+
- lib/growl/notify/growlnotify.com
|
55
|
+
- lib/growl.rb
|
56
|
+
- Manifest
|
57
|
+
- Rakefile
|
58
|
+
- README.rdoc
|
59
|
+
- spec/fixtures/icon.icns
|
60
|
+
- spec/fixtures/image.png
|
61
|
+
- spec/growl_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- tasks/docs.rake
|
64
|
+
- tasks/gemspec.rake
|
65
|
+
- tasks/spec.rake
|
66
|
+
homepage: http://github.com/visionmedia/growl
|
67
|
+
licenses: []
|
68
|
+
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options:
|
71
|
+
- --line-numbers
|
72
|
+
- --inline-source
|
73
|
+
- --title
|
74
|
+
- Growl
|
75
|
+
- --main
|
76
|
+
- README.rdoc
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 11
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 2
|
97
|
+
version: "1.2"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: growl
|
101
|
+
rubygems_version: 1.8.5
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: growlnotify bindings
|
105
|
+
test_files: []
|
106
|
+
|