public
Description: A ruby library which allows you to send Growl notifications. Extracted from LimeChat.
Homepage: http://rubyforge.org/projects/growlnotifier/
Clone URL: git://github.com/psychs/growlnotifier.git
Click here to lend your support to: growlnotifier and make a donation at www.pledgie.com !
Send notifications to Growl with the #notify method.
alloy (author)
Fri Jul 25 16:42:15 -0700 2008
commit  a26dd31be2152abb41783de8211709952087e8c7
tree    3cdc066f860c638fd54accaa30bc7f22c85b0a5f
parent  2eba4d83a9959c788c5926bb68d43e86fab3b6b2
...
67
68
69
70
 
71
72
73
...
79
80
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
83
84
...
67
68
69
 
70
71
72
73
...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
@@ -67,7 +67,7 @@ module Growl
0
       end
0
     end
0
     
0
-    attr_reader :application_name, :application_icon, :notifications, :default_notifications
1
+    attr_reader :application_name, :notifications, :default_notifications
0
     
0
     def start(application_name, notifications, default_notifications = nil, application_icon = nil)
0
       @application_name, @notifications, @application_icon = application_name, notifications, application_icon
0
@@ -79,6 +79,22 @@ module Growl
0
       @application_icon ||= OSX::NSApplication.sharedApplication.applicationIconImage
0
     end
0
     
0
+    def notify(options)
0
+      dict = {
0
+        :ApplicationName => @application_name,
0
+        :ApplicationPID => pid,
0
+        :NotificationName => options[:name],
0
+        :NotificationTitle => options[:title],
0
+        :NotificationDescription => options[:description],
0
+        :NotificationPriority => options[:priority] || 0
0
+      }
0
+      dict[:NotificationIcon] = options[:icon] if options[:icon]
0
+      dict[:NotificationSticky] = 1 if options[:sticky]
0
+      dict[:NotificationClickContext] = options[:click_context] if options[:click_context]
0
+      
0
+      notification_center.postNotificationName_object_userInfo_deliverImmediately(:GrowlNotification, nil, dict, true)
0
+    end
0
+    
0
     private
0
     
0
     def pid
...
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
0
@@ -136,4 +136,51 @@ describe "Growl::Notifier.sharedInstance" do
0
     @center.expects(:addObserver_selector_name_object).with(@instance, 'selector:', "#{@name}-#{@pid}-name", nil)
0
     @instance.send(:add_observer, 'selector:', 'name', true)
0
   end
0
+  
0
+  it "should send a notification to Growl" do
0
+    another_icon = mock('Another icon')
0
+    
0
+    dict = {
0
+      :ApplicationName => @name,
0
+      :ApplicationPID => @pid,
0
+      :NotificationName => @notifications.first,
0
+      :NotificationTitle => 'title',
0
+      :NotificationDescription => 'description',
0
+      :NotificationPriority => 1,
0
+      :NotificationIcon => another_icon,
0
+      :NotificationSticky => 1,
0
+      :NotificationClickContext => 'click_context'
0
+    }
0
+    
0
+    @center.expects(:postNotificationName_object_userInfo_deliverImmediately).with(:GrowlNotification, nil, dict, true)
0
+    
0
+    @instance.notify(
0
+      :name => @notifications.first,
0
+      :title => 'title',
0
+      :description => 'description',
0
+      :click_context => 'click_context',
0
+      :sticky => true,
0
+      :priority => 1,
0
+      :icon => another_icon
0
+    )
0
+  end
0
+  
0
+  it "should not require all options to be specified when sending a notification to Growl" do
0
+    dict = {
0
+      :ApplicationName => @name,
0
+      :ApplicationPID => @pid,
0
+      :NotificationName => @notifications.first,
0
+      :NotificationTitle => 'title',
0
+      :NotificationDescription => 'description',
0
+      :NotificationPriority => 0
0
+    }
0
+    
0
+    @center.expects(:postNotificationName_object_userInfo_deliverImmediately).with(:GrowlNotification, nil, dict, true)
0
+    
0
+    @instance.notify(
0
+      :name => @notifications.first,
0
+      :title => 'title',
0
+      :description => 'description'
0
+    )
0
+  end
0
 end
0
\ No newline at end of file

Comments

alloy Fri Jul 25 16:50:38 -0700 2008 at lib/growl.rb L71

This is not the way it’s actually on disk.