Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added examples and updated docs

  • Loading branch information...
commit 4876578f47fcf261a60c7bbc94a04189a5dfd059 1 parent 015e3f8
@tj authored
View
25 README.rdoc
@@ -9,11 +9,11 @@ Ruby growlnotify 'bindings'.
notification.message = 'Hello World'
notification.sticky!
notification.icon = :jpeg
- notification.run
+ notification.run if Growl.installed?
# OR
- Growl {
+ Growl.notify {
self.message = 'Hello World'
self.icon = :jpeg
sticky!
@@ -21,7 +21,7 @@ Ruby growlnotify 'bindings'.
# OR
- Growl do |n|
+ Growl.notify do |n|
n.message = 'Hello World'
n.icon = :jpeg
n.stick!
@@ -29,15 +29,28 @@ Ruby growlnotify 'bindings'.
# OR
- Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl
+ Growl.notify 'Foo', :icon => :jpeg, :title => 'Growl'
+
+ # OR
+
+ include Growl
+ notify 'Email received', :sticky => true
+
+ #Convenience methods
+
+ notify_ok 'Deployment successful'
+ notify_info 'Email received'
+ notify_warning 'Merge required'
+ notify_error 'Failed to send email', :sticky => true
== Features
-* Check availability with Growl#installed?
-* Check dependencies with Growl#version
+* Check availability with Growl.installed?
+* Check dependencies with Growl.version
* Use images, icon paths, application icons, or file format icons
* Sticky a notification making it appear until explicitly closed
* Set notification priority
+* Convenience methods such as notify_ok, notify_warning, notify_error, and notify_info
* Etc (consult growlnotify --help)
== License:
View
1  Todo.rdoc
@@ -1,6 +1,7 @@
== Major:
+* Fix priority, and have constants
* Switch aliases since appIcon is ... lame
* Allow the icon switch to be an image, icon, or extension. This would be much more usable than --icon, --image, and --iconpath
* Docs for installing growlnotify
View
30 examples/growl.rb
@@ -0,0 +1,30 @@
+
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require 'growl'
+
+puts "growlnotify version #{Growl.version} installed"
+
+imagepath = File.dirname(__FILE__) + '/../spec/fixtures/image.png'
+iconpath = File.dirname(__FILE__) + '/../spec/fixtures/icon.icns'
+
+Growl.notify do |notification|
+ notification.sticky!
+ notification.title = 'Sticky'
+ notification.message = 'Im sticky'
+end
+
+Growl.notify do
+ sticky!
+ self.title = 'Image'
+ self.message = 'I have an image as an icon'
+ self.image = imagepath
+end
+
+include Growl
+
+notify 'Whoop', :appIcon => 'Safari'
+notify 'Image processing complete', :icon => :jpeg
+notify 'Kicks ass!', :title => 'Growl', :iconpath => iconpath
+notify_info 'New email received'
+notify_ok 'Deployment complete'
+notify_error 'Deployment failure'
View
8 lib/growl/growl.rb
@@ -28,7 +28,7 @@ class Error < StandardError; end
#
def notify message = nil, options = {}, &block
- return unless installed?
+ return unless Growl.installed?
options.merge! :message => message if message
Growl.new(options, &block).run
end
@@ -65,7 +65,7 @@ def self.version
# Check if the binary is installed and accessable.
def self.installed?
- !! version
+ version
end
##
@@ -110,7 +110,7 @@ def run
self.class.switches.each do |switch|
if send(:"#{switch}?")
args << "--#{switch}"
- args << send(switch) if send(switch).is_a? String
+ args << send(switch).to_s if send(switch) && !(TrueClass === send(switch))
end
end
Growl.exec *args
@@ -133,7 +133,7 @@ def self.switch name
ivar = :"@#{name}"
(@switches ||= []) << name
attr_accessor :"#{name}"
- define_method(:"#{name}?") { !! instance_variable_get(ivar) }
+ define_method(:"#{name}?") { instance_variable_get(ivar) }
define_method(:"#{name}!") { instance_variable_set(ivar, true) }
end
View
10 spec/growl_spec.rb
@@ -81,7 +81,7 @@
describe "#appIcon" do
it "should use an application for the icon" do
@growl.appIcon = 'Safari'
- @growl.message = 'Safari Icon'
+ @growl.message = 'Safari icon'
@growl.run.should be_true
end
end
@@ -89,7 +89,7 @@
describe "#iconpath" do
it "should use a path for the icon" do
@growl.iconpath = fixture 'icon.icns'
- @growl.message = 'Custom Icon'
+ @growl.message = 'Custom icon'
@growl.run.should be_true
end
end
@@ -100,6 +100,12 @@
@growl.message = 'Jpeg Icon'
@growl.run.should be_true
end
+
+ it "should allow symbols" do
+ @growl.icon = :jpeg
+ @growl.message = 'Jpeg icon with symbol'
+ @growl.run.should be_true
+ end
end
describe "#image" do
Please sign in to comment.
Something went wrong with that request. Please try again.