Permalink
Browse files

Added #Growl hash support

  • Loading branch information...
1 parent 058b8fb commit ce03429d3bd67c2bd8eaca889953e6280c347720 @tj committed Apr 8, 2009
Showing with 15 additions and 3 deletions.
  1. +4 −0 README.rdoc
  2. +7 −3 lib/growl/growl.rb
  3. +4 −0 spec/growl_spec.rb
View
@@ -27,6 +27,10 @@ Ruby growlnotify 'bindings'.
n.stick!
end
+ # OR
+
+ Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl
+
== Features
* Check availability with Growl#installed?
View
@@ -54,14 +54,18 @@ class Base
# Initialize with optional +block+, which is then
# instance evaled or yielded depending on the blocks arity.
- def initialize &block
+ def initialize options = {}, &block
@args = []
if block_given?
if block.arity > 0
yield self
else
self.instance_eval &block
end
+ else
+ options.each do |key, value|
+ send :"#{key}=", value
+ end
end
end
@@ -133,6 +137,6 @@ def self.switches
end
-def Growl *args, &block
- Growl.new(*args, &block).run
+def Growl options = {}, &block
+ Growl.new(options, &block).run
end
View
@@ -22,6 +22,10 @@
it "should accept a block, running immediately after" do
Growl { |n| n.message = 'Invoked via Growl' }
end
+
+ it "should accept a hash" do
+ Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl'
+ end
end
describe "#run" do

0 comments on commit ce03429

Please sign in to comment.