ruby-growl 1.0.1 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1,10 @@
1
+ === 2.0 / 2010-06-11
2
+
3
+ * Major Enhancements
4
+ * 1.9-ready
5
+ * Notification levels now work on x86
6
+ * Notification levels no longer work on PPC
7
+
8
+ * Minor Enhancements
9
+ * Added Growl.list which finds local hosts running growl using dnssd.
10
+
@@ -1,6 +1,7 @@
1
- LICENSE
1
+ History.txt
2
2
  Manifest.txt
3
+ README.txt
3
4
  Rakefile
4
5
  bin/growl
5
6
  lib/ruby-growl.rb
6
- test/test_ruby-growl.rb
7
+ test/test_ruby_growl.rb
@@ -1,4 +1,34 @@
1
- Copyright 2004 Eric Hodel. All rights reserved.
1
+ = ruby-growl
2
+
3
+ * http://ruby-growl.rubyforge.org/ruby-growl
4
+
5
+ == DESCRIPTION:
6
+
7
+ A pure-ruby growl notifier. ruby-growl allows you to perform Growl
8
+ notification via UDP from machines without growl installed (for example,
9
+ non-OSX machines).
10
+
11
+ What's Growl? Growl is a really cool "global notification system for Mac OS
12
+ X". See http://growl.info/
13
+
14
+ See also the Ruby Growl bindings in Growl's subversion repository:
15
+ http://growl.info/documentation/growl-source-install.php
16
+
17
+ ruby-growl also contains a command-line notification tool named 'growl'. Where
18
+ possible, it isoption-compatible with growlnotify. (Use --priority instead of
19
+ -p.)
20
+
21
+ == FEATURES/PROBLEMS:
22
+
23
+ * Requires "Listen for incoming notifications" enabled
24
+
25
+ == INSTALL:
26
+
27
+ gem install ruby-growl
28
+
29
+ == LICENSE:
30
+
31
+ Copyright Eric Hodel. All rights reserved.
2
32
 
3
33
  Redistribution and use in source and binary forms, with or without
4
34
  modification, are permitted provided that the following conditions
data/Rakefile CHANGED
@@ -1,67 +1,10 @@
1
1
  require 'rubygems'
2
- require 'rake'
3
- require 'rake/testtask'
4
- require 'rake/rdoctask'
5
- require 'rake/gempackagetask'
2
+ require 'hoe'
6
3
 
7
- require 'lib/ruby-growl'
4
+ Hoe.plugin :git
5
+ Hoe.plugin :minitest
8
6
 
9
- $VERBOSE = nil
10
-
11
- spec = Gem::Specification.new do |s|
12
- s.name = "ruby-growl"
13
- s.version = Growl::VERSION
14
- s.summary = "Pure-Ruby Growl Notifier"
15
- s.description = <<-EOF
16
- ruby-growl allows you to perform Growl notification via UDP from machines
17
- without growl installed (for example, non-OSX machines).
18
-
19
- What's Growl? Growl is a really cool "global notification system for Mac OS
20
- X". See http://growl.info/
21
-
22
- See also the Ruby Growl bindings in Growl's subversion repository:
23
- http://growl.info/documentation/growl-source-install.php
24
-
25
- ruby-growl also contains a command-line notification tool named 'growl'. Where possible, it isoption-compatible with growlnotify. (Use --priority instead of -p.)
26
- EOF
27
-
28
- s.files = File.read("Manifest.txt").split($\)
29
-
30
- s.require_path = 'lib'
31
-
32
- s.executables = ["growl"]
33
- s.default_executable = "growl"
34
-
35
- s.has_rdoc = true
36
-
37
- s.author = "Eric Hodel"
38
- s.email = "drbrain@segment7.net"
39
- s.homepage = "http://segment7.net/projects/ruby/growl/"
40
- end
41
-
42
- ##
43
- # Targets
44
- ##
45
-
46
- desc "Run the tests"
47
- task :default => [ :test ]
48
-
49
- desc "Run the tests"
50
- Rake::TestTask.new "test" do |t|
51
- t.libs << "test"
52
- t.pattern = "test/test_*.rb"
53
- t.verbose = true
54
- end
55
-
56
- desc "Build RDoc"
57
- Rake::RDocTask.new "rdoc" do |rd|
58
- rd.rdoc_dir = "doc"
59
- rd.rdoc_files.add "lib"
60
- rd.main = "Growl"
61
- end
62
-
63
- desc "Build Packages"
64
- Rake::GemPackageTask.new(spec) do |pkg|
65
- pkg.need_tar = true
7
+ Hoe.spec 'ruby-growl' do
8
+ developer 'Eric Hodel', 'drbrain@segment7.net'
66
9
  end
67
10
 
data/bin/growl CHANGED
@@ -1,97 +1,6 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
3
  require 'ruby-growl'
4
- require 'optparse'
5
4
 
6
- ##
7
- # Defaults
8
-
9
- host = nil
10
- name = "ruby-growl"
11
- notify_type = "ruby-growl Notification"
12
- title = ""
13
- message = nil
14
- priority = 0
15
- sticky = false
16
- password = nil
17
-
18
- ##
19
- # Options
20
-
21
- opts = OptionParser.new do |opts|
22
- opts.banner = "Usage: #{$0} -H HOSTNAME [options]"
23
- opts.separator ""
24
- opts.separator " Where possible, growl is compatible with growlnotify's arguments."
25
- opts.separator " (Except for -p, use --priority)"
26
- opts.separator ""
27
- opts.separator "Synopsis:"
28
- opts.separator "echo \"message\" | growl -H localhost"
29
- opts.separator ""
30
- opts.separator "growl -H localhost -m message"
31
- opts.separator ""
32
- opts.separator "Options:"
33
-
34
- opts.on("-H", "--host HOSTNAME", "Send notifications to HOSTNAME") do |val|
35
- host = val
36
- end
37
-
38
- opts.on("-n", "--name [NAME]", "Sending application name",
39
- "(Defaults to \"ruby-growl\")") do |val|
40
- name = val
41
- end
42
-
43
- opts.on("-y", "--type [TYPE]", "Notification type",
44
- "(Defauts to \"Ruby Growl Notification\")") do |val|
45
- notify_type = val
46
- end
47
-
48
- opts.on("-t", "--title [TITLE]", "Notification title") do |val|
49
- title = val
50
- end
51
-
52
- opts.on("-m", "--message [MESSAGE]",
53
- "Send this message instead of reading STDIN") do |val|
54
- message = val
55
- end
56
-
57
- # HACK -p -1 raises
58
- opts.on("--priority [PRIORITY]", Integer,
59
- "Notification priority",
60
- "Priority can be between -2 and 2") do |val|
61
- priority = val
62
- end
63
-
64
- opts.on("-s", "--[no-]sticky", "Make the notification sticky") do |val|
65
- sticky = val
66
- end
67
-
68
- opts.on("-P", "--password [PASSWORD]", "Growl UDP Password") do |val|
69
- password = val
70
- end
71
-
72
- opts.separator ""
73
-
74
- opts.on("-h", "--help", "Show this message") do
75
- puts opts
76
- exit
77
- end
78
-
79
- opts.on("-v", "--version", "Show version") do
80
- puts Growl::VERSION
81
- end
82
- end
83
-
84
- ##
85
- # Do it!
86
- opts.parse!
87
-
88
- if host.nil? then
89
- puts opts
90
- exit 1
91
- end
92
-
93
- message = STDIN.read if message.nil?
94
-
95
- g = Growl.new host, name, [notify_type], [notify_type], password
96
- g.notify notify_type, title, message, priority, sticky
5
+ Growl.run ARGV
97
6
 
@@ -1,23 +1,21 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
- $TESTING = false unless defined? $TESTING
4
-
5
- require 'md5'
3
+ require 'digest/md5'
6
4
  require 'socket'
7
5
 
8
6
  ##
9
7
  # ruby-growl allows you to perform Growl notification via UDP from machines
10
8
  # without growl installed (for example, non-OSX machines).
11
- #
9
+ #
12
10
  # What's Growl? Growl is a really cool "global notification system for Mac OS
13
11
  # X". See http://growl.info/
14
- #
12
+ #
15
13
  # You'll need a Mac to recieve Growl notifications, but you can send Growl
16
14
  # notifications from any UDP-capable machine that runs Ruby.
17
15
  #
18
16
  # See also the Ruby Growl bindings in Growl's subversion repository:
19
17
  # http://growl.info/documentation/growl-source-install.php
20
- #
18
+ #
21
19
  # ruby-growl also contains a command-line notification tool named 'growl'. It
22
20
  # is almost completely option-compatible with growlnotify. (All except for -p
23
21
  # is supported, use --priority instead.)
@@ -37,16 +35,24 @@ class Growl
37
35
 
38
36
  BROKEN_PACK = [1].pack("n") != "\000\001" # :nodoc:
39
37
 
38
+ little_endian = [1].pack('V*') == [1].pack('L*')
39
+ little_endian = !little_endian if BROKEN_PACK
40
+
41
+ ##
42
+ # Endianness of this machine
43
+
44
+ LITTLE_ENDIAN = little_endian
45
+
40
46
  ##
41
47
  # ruby-growl Version
42
48
 
43
- VERSION = "1.0.1"
49
+ VERSION = "2.0"
44
50
 
45
51
  ##
46
52
  # Growl Network Registration Packet +pack+ Format
47
53
  #--
48
54
  # Format:
49
- #
55
+ #
50
56
  # struct GrowlNetworkRegistration {
51
57
  # struct GrowlNetworkPacket {
52
58
  # unsigned char version;
@@ -73,7 +79,7 @@ class Growl
73
79
  # Growl Network Notification Packet +pack+ Format
74
80
  #--
75
81
  # Format:
76
- #
82
+ #
77
83
  # struct GrowlNetworkNotification {
78
84
  # struct GrowlNetworkPacket {
79
85
  # unsigned char version;
@@ -84,7 +90,7 @@ class Growl
84
90
  # signed priority: 3;
85
91
  # unsigned sticky: 1;
86
92
  # } __attribute__((packed)) flags; //size = 16 (12 + 3 + 1)
87
- # unsigned short nameLen;
93
+ # unsigned short nameLen;
88
94
  # unsigned short titleLen;
89
95
  # unsigned short descriptionLen;
90
96
  # unsigned short appNameLen;
@@ -99,6 +105,11 @@ class Growl
99
105
 
100
106
  GNN_FORMAT.gsub!(/n/, 'v') if BROKEN_PACK
101
107
 
108
+ # For litle endian machines the NetworkNotificationFlags aren't in network
109
+ # byte order
110
+
111
+ GNN_FORMAT.sub!((BROKEN_PACK ? 'v' : 'n'), 'v') if LITTLE_ENDIAN
112
+
102
113
  ##
103
114
  # Growl UDP Port
104
115
 
@@ -119,6 +130,165 @@ class Growl
119
130
 
120
131
  GROWL_TYPE_NOTIFICATION = 1
121
132
 
133
+ ##
134
+ # List of hosts accessible via dnssd
135
+
136
+ def self.list
137
+ require 'dnssd'
138
+
139
+ growls = []
140
+
141
+ DNSSD.browse! '_growl._tcp' do |reply|
142
+ next unless reply.flags.add?
143
+
144
+ growls << reply
145
+
146
+ break unless reply.flags.more_coming?
147
+ end
148
+
149
+ hosts = []
150
+
151
+ growls.each do |growl|
152
+ DNSSD.resolve! growl do |reply|
153
+ hosts << reply.target
154
+ break
155
+ end
156
+ end
157
+
158
+ hosts.uniq
159
+ rescue LoadError
160
+ raise 'you must gem install dnssd'
161
+ end
162
+
163
+ ##
164
+ # Sends a notification using +options+
165
+
166
+ def self.notify options
167
+ message = options[:message]
168
+
169
+ unless message then
170
+ puts "Type your message and hit ^D" if $stdin.tty?
171
+ message = $stdin.read
172
+ end
173
+
174
+ notify_type = options[:notify_type]
175
+ notify_types = [notify_type]
176
+
177
+ g = new(options[:host], options[:name], notify_types, notify_types,
178
+ options[:password])
179
+
180
+ g.notify(notify_type, options[:title], message, options[:priority],
181
+ options[:sticky])
182
+ end
183
+
184
+ ##
185
+ # Parses argv-style options from +ARGV+ into an options hash
186
+
187
+ def self.process_args argv
188
+ require 'optparse'
189
+
190
+ options = {
191
+ :host => nil,
192
+ :message => nil,
193
+ :name => "ruby-growl",
194
+ :notify_type => "ruby-growl Notification",
195
+ :password => nil,
196
+ :priority => 0,
197
+ :sticky => false,
198
+ :title => "",
199
+ :list => false,
200
+ }
201
+
202
+ opts = OptionParser.new do |o|
203
+ o.program_name = File.basename $0
204
+ o.version = Growl::VERSION
205
+ o.release = nil
206
+
207
+ o.banner = <<-BANNER
208
+ Usage: #{o.program_name} -H HOSTNAME [options]
209
+
210
+ Where possible, growl is compatible with growlnotify's arguments.
211
+ (Except for -p, use --priority)
212
+
213
+ Synopsis:
214
+ echo \"message\" | growl -H localhost
215
+
216
+ growl -H localhost -m message
217
+
218
+ BANNER
219
+
220
+ o.separator "Options:"
221
+
222
+ o.on("-H", "--host HOSTNAME", "Send notifications to HOSTNAME") do |val|
223
+ options[:host] = val
224
+ end
225
+
226
+ o.on("-n", "--name [NAME]", "Sending application name",
227
+ "(Defaults to \"ruby-growl\")") do |val|
228
+ options[:name] = val
229
+ end
230
+
231
+ o.on("-y", "--type [TYPE]", "Notification type",
232
+ "(Defauts to \"Ruby Growl Notification\")") do |val|
233
+ options[:notify_type] = val
234
+ end
235
+
236
+ o.on("-t", "--title [TITLE]", "Notification title") do |val|
237
+ options[:title] = val
238
+ end
239
+
240
+ o.on("-m", "--message [MESSAGE]",
241
+ "Send this message instead of reading STDIN") do |val|
242
+ options[:message] = val
243
+ end
244
+
245
+ # HACK -p -1 raises
246
+ o.on("--priority [PRIORITY]", Integer,
247
+ "Notification priority",
248
+ "Priority can be between -2 and 2") do |val|
249
+ options[:priority] = val
250
+ end
251
+
252
+ o.on("-s", "--[no-]sticky", "Make the notification sticky") do |val|
253
+ options[:sticky] = val
254
+ end
255
+
256
+ o.on("-P", "--password [PASSWORD]", "Growl UDP Password") do |val|
257
+ options[:password] = val
258
+ end
259
+
260
+ o.on("--list", "List growl hosts using dnssd") do |val|
261
+ options[:list] = true
262
+ end
263
+ end
264
+
265
+ opts.parse! argv
266
+
267
+ abort opts.to_s unless options[:host] or options[:list]
268
+
269
+ options
270
+ end
271
+
272
+ ##
273
+ # Command-line interface
274
+
275
+ def self.run argv = ARGV
276
+ options = process_args argv
277
+
278
+ if options[:list] then
279
+ begin
280
+ puts list
281
+ rescue => e
282
+ raise unless e.message =~ /gem install dnssd/
283
+
284
+ abort "#{e.message} to use --list"
285
+ end
286
+ return
287
+ end
288
+
289
+ notify options
290
+ end
291
+
122
292
  ##
123
293
  # Creates a new Growl notifier and automatically registers any notifications
124
294
  # with the remote machine.
@@ -170,8 +340,6 @@ class Growl
170
340
  send notification_packet(notify_type, title, message, priority, sticky)
171
341
  end
172
342
 
173
- private unless $TESTING
174
-
175
343
  ##
176
344
  # Registers the notification types with +host+.
177
345
 
@@ -227,7 +395,7 @@ class Growl
227
395
 
228
396
  packet = packet.pack GNR_FORMAT
229
397
 
230
- checksum = MD5.new packet
398
+ checksum = Digest::MD5.new << packet
231
399
  checksum.update @password unless @password.nil?
232
400
 
233
401
  packet << checksum.digest
@@ -265,7 +433,7 @@ class Growl
265
433
  packet << data.join
266
434
  packet = packet.pack GNN_FORMAT
267
435
 
268
- checksum = MD5.new packet
436
+ checksum = Digest::MD5.new << packet
269
437
  checksum.update @password unless @password.nil?
270
438
 
271
439
  packet << checksum.digest
@@ -1,12 +1,8 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- $TESTING = true
4
-
5
- require 'test/unit'
6
-
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
7
3
  require 'ruby-growl'
8
4
 
9
- class TestGrowl < Test::Unit::TestCase
5
+ class TestGrowl < MiniTest::Unit::TestCase
10
6
 
11
7
  def setup
12
8
  @growl = Growl.new "localhost", "ruby-growl test",
@@ -18,12 +14,10 @@ class TestGrowl < Test::Unit::TestCase
18
14
  @growl.notify "ruby-growl Test Notification", "", "", -3
19
15
  end
20
16
 
21
- assert_nothing_raised do
22
- -2.upto 2 do |priority|
23
- @growl.notify "ruby-growl Test Notification",
17
+ -2.upto 2 do |priority|
18
+ @growl.notify "ruby-growl Test Notification",
24
19
  "Priority #{priority}",
25
20
  "This message should have a priority set.", priority
26
- end
27
21
  end
28
22
 
29
23
  assert_raises RuntimeError do
@@ -36,14 +30,12 @@ class TestGrowl < Test::Unit::TestCase
36
30
  @growl.notify "bad notify type", "", ""
37
31
  end
38
32
 
39
- assert_nothing_raised do
40
- @growl.notify "ruby-growl Test Notification", "Empty", "This notification is empty."
41
- end
33
+ @growl.notify "ruby-growl Test Notification", "Empty", "This notification is empty."
42
34
  end
43
35
 
44
36
  def test_notify_sticky
45
- @growl.notify "ruby-growl Test Notification", "Sticky",
46
- "This notification should be sticky.", 0, true
37
+ @growl.notify "ruby-growl Test Notification", "Sticky",
38
+ "This notification should be sticky.", 0, true
47
39
  end
48
40
 
49
41
  def test_registration_packet
@@ -64,9 +56,7 @@ class TestGrowl < Test::Unit::TestCase
64
56
 
65
57
  packet = @growl.registration_packet
66
58
 
67
- packet = packet.split(//).map { |char| "%02x" % char[0] }
68
-
69
- assert_equal expected, packet
59
+ assert_equal expected, util_hexes(packet)
70
60
  end
71
61
 
72
62
  def test_notification_packet
@@ -74,7 +64,7 @@ class TestGrowl < Test::Unit::TestCase
74
64
  ["Command-Line Growl Notification"]
75
65
 
76
66
  expected = [
77
- "01", "01", "00", "00", "00", "1f", "00", "00", # ........
67
+ "01", "01", "00", "00", "00", "1f", "00", "00", # ........
78
68
  "00", "02", "00", "0b", "43", "6f", "6d", "6d", # ....Comm
79
69
  "61", "6e", "64", "2d", "4c", "69", "6e", "65", # and-Line
80
70
  "20", "47", "72", "6f", "77", "6c", "20", "4e", # .Growl.N
@@ -88,9 +78,7 @@ class TestGrowl < Test::Unit::TestCase
88
78
  packet = @growl.notification_packet "Command-Line Growl Notification",
89
79
  "", "hi", 0, false
90
80
 
91
- packet = packet.split(//).map { |char| "%02x" % char[0] }
92
-
93
- assert_equal expected, packet
81
+ assert_equal expected, util_hexes(packet)
94
82
  end
95
83
 
96
84
  def test_notification_packet_priority_negative_2
@@ -98,23 +86,21 @@ class TestGrowl < Test::Unit::TestCase
98
86
  ["Command-Line Growl Notification"]
99
87
 
100
88
  expected = [
101
- "01", "01", "00", "0c", "00", "1f", "00", "00", # ........
89
+ "01", "01", "0c", "00", "00", "1f", "00", "00", # ........
102
90
  "00", "02", "00", "0b", "43", "6f", "6d", "6d", # ....Comm
103
91
  "61", "6e", "64", "2d", "4c", "69", "6e", "65", # and-Line
104
92
  "20", "47", "72", "6f", "77", "6c", "20", "4e", # .Growl.N
105
93
  "6f", "74", "69", "66", "69", "63", "61", "74", # otificat
106
94
  "69", "6f", "6e", "68", "69", "67", "72", "6f", # ionhigro
107
95
  "77", "6c", "6e", "6f", "74", "69", "66", "79", # wlnotify
108
- "6d", "98", "51", "12", "4f", "dc", "38", "4a",
109
- "b5", "eb", "9e", "f3", "2d", "e0", "aa", "5e"
96
+ "64", "b4", "cc", "a8", "74", "ea", "30", "2d",
97
+ "6e", "0f", "c1", "45", "b2", "b5", "58", "00"
110
98
  ]
111
99
 
112
100
  packet = @growl.notification_packet "Command-Line Growl Notification",
113
101
  "", "hi", -2, false
114
102
 
115
- packet = packet.split(//).map { |char| "%02x" % char[0] }
116
-
117
- assert_equal expected, packet
103
+ assert_equal expected, util_hexes(packet)
118
104
  end
119
105
 
120
106
  def test_notification_packet_priority_negative_1
@@ -122,23 +108,21 @@ class TestGrowl < Test::Unit::TestCase
122
108
  ["Command-Line Growl Notification"]
123
109
 
124
110
  expected = [
125
- "01", "01", "00", "0e", "00", "1f", "00", "00", # ........
111
+ "01", "01", "0e", "00", "00", "1f", "00", "00", # ........
126
112
  "00", "02", "00", "0b", "43", "6f", "6d", "6d", # ....Comm
127
113
  "61", "6e", "64", "2d", "4c", "69", "6e", "65", # and-Line
128
114
  "20", "47", "72", "6f", "77", "6c", "20", "4e", # .Growl.N
129
115
  "6f", "74", "69", "66", "69", "63", "61", "74", # otificat
130
116
  "69", "6f", "6e", "68", "69", "67", "72", "6f", # ionhigro
131
117
  "77", "6c", "6e", "6f", "74", "69", "66", "79", # wlnotify
132
- "d2", "cc", "44", "30", "21", "fa", "fd", "c6",
133
- "a8", "f3", "db", "72", "2b", "64", "f4", "25"
118
+ "19", "17", "9f", "84", "6d", "19", "c6", "04",
119
+ "8e", "6d", "8d", "84", "05", "84", "5b"
134
120
  ]
135
121
 
136
122
  packet = @growl.notification_packet "Command-Line Growl Notification",
137
123
  "", "hi", -1, false
138
124
 
139
- packet = packet.split(//).map { |char| "%02x" % char[0] }
140
-
141
- assert_equal expected, packet
125
+ assert_equal expected, util_hexes(packet)
142
126
  end
143
127
 
144
128
  def test_notification_packet_priority_1
@@ -146,21 +130,21 @@ class TestGrowl < Test::Unit::TestCase
146
130
  ["Command-Line Growl Notification"]
147
131
 
148
132
  expected = [
149
- "01", "01", "00", "02", "00", "1f", "00", "00", # ........
133
+ "01", "01", "02", "00", "00", "1f", "00", "00", # ........
150
134
  "00", "02", "00", "0b", "43", "6f", "6d", "6d", # ....Comm
151
135
  "61", "6e", "64", "2d", "4c", "69", "6e", "65", # and-Line
152
136
  "20", "47", "72", "6f", "77", "6c", "20", "4e", # .Growl.N
153
137
  "6f", "74", "69", "66", "69", "63", "61", "74", # otificat
154
138
  "69", "6f", "6e", "68", "69", "67", "72", "6f", # ionhigro
155
139
  "77", "6c", "6e", "6f", "74", "69", "66", "79", # wlnotify
156
- "bf", "de", "a5", "63", "09", "29", "27", "02",
157
- "13", "1f", "8e", "5c", "f1", "88", "f8", "93"
140
+ "03", "4d", "92", "cf", "5f", "6c", "c2", "4c",
141
+ "4c", "f4", "f2", "b5", "24", "d3", "ae", "96"
158
142
  ]
159
143
 
160
144
  packet = @growl.notification_packet "Command-Line Growl Notification",
161
145
  "", "hi", 1, false
162
146
 
163
- packet = packet.split(//).map { |char| "%02x" % char[0] }
147
+ packet = util_hexes(packet)
164
148
 
165
149
  assert_equal expected, packet
166
150
  end
@@ -170,23 +154,21 @@ class TestGrowl < Test::Unit::TestCase
170
154
  ["Command-Line Growl Notification"]
171
155
 
172
156
  expected = [
173
- "01", "01", "00", "04", "00", "1f", "00", "00", # ........
157
+ "01", "01", "04", "00", "00", "1f", "00", "00", # ........
174
158
  "00", "02", "00", "0b", "43", "6f", "6d", "6d", # ....Comm
175
159
  "61", "6e", "64", "2d", "4c", "69", "6e", "65", # and-Line
176
160
  "20", "47", "72", "6f", "77", "6c", "20", "4e", # .Growl.N
177
161
  "6f", "74", "69", "66", "69", "63", "61", "74", # otificat
178
162
  "69", "6f", "6e", "68", "69", "67", "72", "6f", # ionhigro
179
163
  "77", "6c", "6e", "6f", "74", "69", "66", "79", # wlnotify
180
- "d5", "40", "af", "67", "3c", "d3", "80", "eb",
181
- "3d", "46", "5d", "c3", "75", "09", "24", "95"
164
+ "68", "91", "f7", "82", "20", "7f", "1b", "08",
165
+ "98", "a3", "1b", "f6", "cc", "72", "39", "94"
182
166
  ]
183
167
 
184
168
  packet = @growl.notification_packet "Command-Line Growl Notification",
185
169
  "", "hi", 2, false
186
170
 
187
- packet = packet.split(//).map { |char| "%02x" % char[0] }
188
-
189
- assert_equal expected, packet
171
+ assert_equal expected, util_hexes(packet)
190
172
  end
191
173
 
192
174
  def test_notification_packet_priority_sticky
@@ -194,23 +176,29 @@ class TestGrowl < Test::Unit::TestCase
194
176
  ["Command-Line Growl Notification"]
195
177
 
196
178
  expected = [
197
- "01", "01", "00", "01", "00", "1f", "00", "00", # ........
179
+ "01", "01", "01", "00", "00", "1f", "00", "00", # ........
198
180
  "00", "02", "00", "0b", "43", "6f", "6d", "6d", # ....Comm
199
181
  "61", "6e", "64", "2d", "4c", "69", "6e", "65", # and-Line
200
182
  "20", "47", "72", "6f", "77", "6c", "20", "4e", # .Growl.N
201
183
  "6f", "74", "69", "66", "69", "63", "61", "74", # otificat
202
184
  "69", "6f", "6e", "68", "69", "67", "72", "6f", # ionhigro
203
185
  "77", "6c", "6e", "6f", "74", "69", "66", "79", # wlnotify
204
- "eb", "75", "2a", "36", "85", "6c", "d7", "a2",
205
- "72", "0b", "13", "6b", "41", "c7", "ea", "1b"
186
+ "94", "b7", "66", "74", "02", "ee", "78", "33",
187
+ "c2", "a4", "54", "b2", "3b", "77", "5e", "27"
206
188
  ]
207
189
 
208
190
  packet = @growl.notification_packet "Command-Line Growl Notification",
209
191
  "", "hi", 0, true
210
192
 
211
- packet = packet.split(//).map { |char| "%02x" % char[0] }
193
+ assert_equal expected, util_hexes(packet)
194
+ end
212
195
 
213
- assert_equal expected, packet
196
+ def util_hexes string
197
+ if string.respond_to? :ord then
198
+ string.scan(/./).map { |c| "%02x" % c.ord }
199
+ else
200
+ string.scan(/./).map { |c| "%02x" % c[0] }
201
+ end
214
202
  end
215
203
 
216
204
  end
metadata CHANGED
@@ -1,51 +1,173 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: ruby-growl
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2005-11-14 00:00:00 -08:00
8
- summary: Pure-Ruby Growl Notifier
9
- require_paths:
10
- - lib
11
- email: drbrain@segment7.net
12
- homepage: http://segment7.net/projects/ruby/growl/
13
- rubyforge_project:
14
- description: "ruby-growl allows you to perform Growl notification via UDP from machines
15
- without growl installed (for example, non-OSX machines). What's Growl? Growl
16
- is a really cool \"global notification system for Mac OS X\". See
17
- http://growl.info/ See also the Ruby Growl bindings in Growl's subversion
18
- repository: http://growl.info/documentation/growl-source-install.php ruby-growl
19
- also contains a command-line notification tool named 'growl'. Where possible,
20
- it isoption-compatible with growlnotify. (Use --priority instead of -p.)"
4
+ hash: 3
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 0
9
+ version: "2.0"
10
+ platform: ruby
11
+ authors:
12
+ - Eric Hodel
21
13
  autorequire:
22
- default_executable: growl
23
14
  bindir: bin
24
- has_rdoc: true
25
- required_ruby_version: !ruby/object:Gem::Version::Requirement
26
- requirements:
27
- -
28
- - ">"
29
- - !ruby/object:Gem::Version
30
- version: 0.0.0
31
- version:
32
- platform: ruby
33
- signing_key:
34
15
  cert_chain:
35
- authors:
36
- - Eric Hodel
37
- files:
38
- - LICENSE
39
- - Manifest.txt
40
- - Rakefile
41
- - bin/growl
42
- - lib/ruby-growl.rb
43
- - test/test_ruby-growl.rb
44
- test_files: []
45
- rdoc_options: []
46
- extra_rdoc_files: []
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy
19
+ YWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu
20
+ ZXQwHhcNMDcxMjIxMDIwNDE0WhcNMDgxMjIwMDIwNDE0WjBBMRAwDgYDVQQDDAdk
21
+ cmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ
22
+ FgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76
23
+ LV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J
24
+ U5ddZCVywn5nnAQ+Ui7jMW54CYt5/H6f2US6U0hQOjJR6cpfiymgxGdfyTiVcvTm
25
+ Gj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY
26
+ mUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd
27
+ g62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh
28
+ sCANiQ8BAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
29
+ BBS5k4Z75VSpdM0AclG2UvzFA/VW5DANBgkqhkiG9w0BAQUFAAOCAQEAHagT4lfX
30
+ kP/hDaiwGct7XPuVGbrOsKRVD59FF5kETBxEc9UQ1clKWngf8JoVuEoKD774dW19
31
+ bU0GOVWO+J6FMmT/Cp7nuFJ79egMf/gy4gfUfQMuvfcr6DvZUPIs9P/TlK59iMYF
32
+ DIOQ3DxdF3rMzztNUCizN4taVscEsjCcgW6WkUJnGdqlu3OHWpQxZBJkBTjPCoc6
33
+ UW6on70SFPmAy/5Cq0OJNGEWBfgD9q7rrs/X8GGwUWqXb85RXnUVi/P8Up75E0ag
34
+ 14jEc90kN+C7oI/AGCBN0j6JnEtYIEJZibjjDJTSMWlUKKkj30kq7hlUC2CepJ4v
35
+ x52qPcexcYZR7w==
36
+ -----END CERTIFICATE-----
37
+
38
+ date: 2010-06-11 00:00:00 -07:00
39
+ default_executable:
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubyforge
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 9
50
+ segments:
51
+ - 2
52
+ - 0
53
+ - 3
54
+ version: 2.0.3
55
+ type: :development
56
+ version_requirements: *id001
57
+ - !ruby/object:Gem::Dependency
58
+ name: gemcutter
59
+ prerelease: false
60
+ requirement: &id002 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 11
66
+ segments:
67
+ - 0
68
+ - 5
69
+ - 0
70
+ version: 0.5.0
71
+ type: :development
72
+ version_requirements: *id002
73
+ - !ruby/object:Gem::Dependency
74
+ name: minitest
75
+ prerelease: false
76
+ requirement: &id003 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 1
84
+ - 5
85
+ - 0
86
+ version: 1.5.0
87
+ type: :development
88
+ version_requirements: *id003
89
+ - !ruby/object:Gem::Dependency
90
+ name: hoe
91
+ prerelease: false
92
+ requirement: &id004 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 27
98
+ segments:
99
+ - 2
100
+ - 5
101
+ - 0
102
+ version: 2.5.0
103
+ type: :development
104
+ version_requirements: *id004
105
+ description: |-
106
+ A pure-ruby growl notifier. ruby-growl allows you to perform Growl
107
+ notification via UDP from machines without growl installed (for example,
108
+ non-OSX machines).
109
+
110
+ What's Growl? Growl is a really cool "global notification system for Mac OS
111
+ X". See http://growl.info/
112
+
113
+ See also the Ruby Growl bindings in Growl's subversion repository:
114
+ http://growl.info/documentation/growl-source-install.php
115
+
116
+ ruby-growl also contains a command-line notification tool named 'growl'. Where
117
+ possible, it isoption-compatible with growlnotify. (Use --priority instead of
118
+ -p.)
119
+ email:
120
+ - drbrain@segment7.net
47
121
  executables:
48
- - growl
122
+ - growl
49
123
  extensions: []
124
+
125
+ extra_rdoc_files:
126
+ - History.txt
127
+ - Manifest.txt
128
+ - README.txt
129
+ files:
130
+ - History.txt
131
+ - Manifest.txt
132
+ - README.txt
133
+ - Rakefile
134
+ - bin/growl
135
+ - lib/ruby-growl.rb
136
+ - test/test_ruby_growl.rb
137
+ has_rdoc: true
138
+ homepage: http://ruby-growl.rubyforge.org/ruby-growl
139
+ licenses: []
140
+
141
+ post_install_message:
142
+ rdoc_options:
143
+ - --main
144
+ - README.txt
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ hash: 3
153
+ segments:
154
+ - 0
155
+ version: "0"
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
50
165
  requirements: []
51
- dependencies: []
166
+
167
+ rubyforge_project: ruby-growl
168
+ rubygems_version: 1.3.7
169
+ signing_key:
170
+ specification_version: 3
171
+ summary: A pure-ruby growl notifier
172
+ test_files:
173
+ - test/test_ruby_growl.rb
Binary file