Module: Notifier::Growl

Extended by:
Growl
Included in:
Growl
Defined in:
lib/notifier/growl.rb

Constant Summary collapse

SCRIPT =
File.dirname(__FILE__) + "/../../resources/register-growl.scpt"
FILE =
File.expand_path("~/.test_notifier-growl")

Instance Method Summary collapse

Instance Method Details

#notify(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/notifier/growl.rb', line 12

def notify(options)
  register
  command = [
    "growlnotify",
    "--name", "test_notifier",
    "--image", options.fetch(:image, '').to_s,
    "--priority", "2",
    "--message", options[:message].to_s,
    options[:title].to_s
  ]

  Thread.new { system(*command) }.join
end

#registerObject



26
27
28
29
# File 'lib/notifier/growl.rb', line 26

def register
  return if File.file?(FILE)
  system "osascript #{SCRIPT} > #{FILE}"
end

#supported?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/notifier/growl.rb', line 8

def supported?
  Notifier.os?(/darwin/) && `which growlnotify` && $? == 0
end