Module: Kernel

Defined in:
lib/growlmessages/growlmessages.rb

Instance Method Summary collapse

Instance Method Details

#growl(msg = "Message from rails!", *args) ⇒ Object

Displays a message using Growl notification system’s “growlnotify” command. Options:

  • sticky - if true, the message won’t disappear until clicked

  • wait - if true, rails app will wait until message disappears



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/growlmessages/growlmessages.rb', line 7

def growl(msg="Message from rails!", *args)
  return false unless RAILS_ENV == 'development'
  options = args.extract_options!
  flags = String.new
  flags << " -w" if options[:wait]
  flags << " -s" if options[:sticky]
  system_command = system 'growlnotify -m "' + Time.now.to_formatted_s("%H:%M") + "\n" + msg + '" --image "'+File.dirname(__FILE__) +'/../rails.png" -n "rails" '+flags+''
  begin
    system system_command
  rescue => error
    system 'growlnotify -m "GrowlMessages error: ' + error + '" --image "'+File.dirname(__FILE__) +'/../rails.png" -n "rails"'
  end
end