lib/ruby-growl.rb in ruby-growl-2.0 vs lib/ruby-growl.rb in ruby-growl-2.1
- old
+ new
@@ -44,11 +44,11 @@
LITTLE_ENDIAN = little_endian
##
# ruby-growl Version
- VERSION = "2.0"
+ VERSION = '2.1'
##
# Growl Network Registration Packet +pack+ Format
#--
# Format:
@@ -129,10 +129,17 @@
# Growl Notification Packet Id
GROWL_TYPE_NOTIFICATION = 1
##
+ # String bytesize method
+ #--
+ # HACK for 1.8.6 support
+
+ STRING_BYTESIZE_METHOD = ("".respond_to? :bytesize) ? :bytesize : :length
+
+ ##
# List of hosts accessible via dnssd
def self.list
require 'dnssd'
@@ -367,16 +374,16 @@
packet = [
GROWL_PROTOCOL_VERSION,
GROWL_TYPE_REGISTRATION
]
- packet << @app_name.length
+ packet << @app_name.send(STRING_BYTESIZE_METHOD)
packet << @all_notifies.length
packet << @default_notifies.length
data << @app_name
- data_format = "a#{@app_name.length}"
+ data_format = "a#{@app_name.send(STRING_BYTESIZE_METHOD)}"
@all_notifies.each do |notify|
data << notify.length
data << notify
data_format << "na#{notify.length}"
@@ -418,13 +425,13 @@
flags = 0
flags |= ((0x7 & priority) << 1) # 3 bits for priority
flags |= 1 if sticky # 1 bit for sticky
packet << flags
- packet << name.length
+ packet << name.send(STRING_BYTESIZE_METHOD)
packet << title.length
- packet << description.length
- packet << @app_name.length
+ packet << description.send(STRING_BYTESIZE_METHOD)
+ packet << @app_name.send(STRING_BYTESIZE_METHOD)
data << name
data << title
data << description
data << @app_name