Execute args
against the binary.
# File lib/growl/growl.rb, line 54 def self.exec *args Kernel.system BIN, *args end
Check if the binary is installed and accessable.
# File lib/growl/growl.rb, line 68 def self.installed? version rescue false end
Return an instance of Growl::Base or nil when not installed.
# File lib/growl/growl.rb, line 75 def self.new *args, &block return unless installed? Base.new *args, &block end
Normalize the icon option in options
. This performs the
following operations in order to allow for the :icon key to work with a
variety of values:
path to an icon sets :iconpath
path to an image sets :image
capitalized word sets :appIcon
filename uses extname as :icon
otherwise treated as :icon
# File lib/growl/growl.rb, line 91 def self.normalize_icon! options = {} return unless options.include? :icon icon = options.delete(:icon).to_s if File.exists? icon if File.extname(icon) == '.icns' options[:iconpath] = icon else options[:image] = icon end else if icon.capitalize == icon options[:appIcon] = icon elsif !(ext = File.extname(icon)).empty? options[:icon] = ext[1..-1] else options[:icon] = icon end end end
Display a growl notification message
, with
options
documented below. Alternatively a block
may be passed which is then instance evaluated or yielded to the block.
This method is simply returns nil when growlnotify is not installed, as growl notifications should never be the only means of communication between your application and your user.
Growl.notify 'Hello' Growl.notify 'Hello', :title => 'TJ Says:', :sticky => true Growl.notify { |n| n.message = 'Hello'; n.sticky! } Growl.notify { self.message = 'Hello'; sticky! }
# File lib/growl/growl.rb, line 30 def notify message = nil, options = {}, &block return unless Growl.installed? options.merge! :message => message if message Growl.normalize_icon! options Growl.new(options, &block).run end
Return the version triple of the binary.
# File lib/growl/growl.rb, line 61 def self.version @version ||= %x#{BIN} --version`.split[1] end