Module: Growl
- Defined in:
- lib/growl/growl.rb,
lib/growl/version.rb
Defined Under Namespace
Constant Summary collapse
- PACKAGED_BIN =
File.(File.dirname(__FILE__) + '/notify/growlnotify')
- VERSION =
'1.0.5'
Class Method Summary collapse
-
.exec(*args) ⇒ Object
Execute
args
against the binary. -
.installed? ⇒ Boolean
Check if the binary is installed and accessable.
- .is_windows? ⇒ Boolean
-
.new(*args, &block) ⇒ Object
Return an instance of Growl::Base or nil when not installed.
-
.normalize_icon!(options = {}) ⇒ Object
Normalize the icon option in
options
. -
.notify(message = nil, options = {}, &block) ⇒ Object
Display a growl notification
message
, withoptions
documented below. -
.version ⇒ Object
Return the version triple of the binary.
Class Method Details
.exec(*args) ⇒ Object
Execute args
against the binary.
59 60 61 62 63 64 |
# File 'lib/growl/growl.rb', line 59 def self.exec *args bin = PACKAGED_BIN bin += '.exe' if is_windows? Kernel.system bin, *args end |
.installed? ⇒ Boolean
Check if the binary is installed and accessable.
76 77 78 |
# File 'lib/growl/growl.rb', line 76 def self.installed? version end |
.is_windows? ⇒ Boolean
51 52 53 54 |
# File 'lib/growl/growl.rb', line 51 def self.is_windows? processor, platform, *rest = RUBY_PLATFORM.split("-") platform == 'mswin32' end |
.new(*args, &block) ⇒ Object
Return an instance of Growl::Base or nil when not installed.
83 84 85 86 |
# File 'lib/growl/growl.rb', line 83 def self.new *args, &block return unless installed? Base.new *args, &block end |
.normalize_icon!(options = {}) ⇒ Object
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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/growl/growl.rb', line 99 def self.normalize_icon! = {} return unless .include? :icon icon = .delete(:icon).to_s if File.exists? icon if File.extname(icon) == '.icns' [:iconpath] = icon else [:image] = icon end else if icon.capitalize == icon [:appIcon] = icon elsif !(ext = File.extname(icon)).empty? [:icon] = ext[1..-1] else [:icon] = icon end end end |
.notify(message = nil, options = {}, &block) ⇒ Object
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.
Examples
Growl.notify 'Hello'
Growl.notify 'Hello', :title => 'TJ Says:', :sticky => true
Growl.notify { |n| n. = 'Hello'; n.sticky! }
Growl.notify { self. = 'Hello'; sticky! }
30 31 32 33 34 35 |
# File 'lib/growl/growl.rb', line 30 def notify = nil, = {}, &block return unless Growl.installed? .merge! :message => if Growl.normalize_icon! Growl.new(, &block).run end |
.version ⇒ Object
Return the version triple of the binary.
69 70 71 |
# File 'lib/growl/growl.rb', line 69 def self.version return '0.0.0' end |