Module: Guard::Notifier
- Defined in:
- lib/guard/notifier.rb
Overview
The notifier class handles cross-platform system notifications that supports:
-
Growl on Mac OS X
-
Libnotify on Linux
-
Notifu on Windows
Constant Summary collapse
- APPLICATION_NAME =
Application name as shown in the specific notification settings
"Guard"
Class Attribute Summary collapse
-
.gntp ⇒ Object
Returns the value of attribute gntp.
-
.growl_library ⇒ Object
Returns the value of attribute growl_library.
Class Method Summary collapse
-
.enabled? ⇒ Boolean
Test if the notifications are enabled and available.
-
.notify(message, options = { }) ⇒ Object
Show a message with the system notification.
-
.turn_off ⇒ Object
Turn notifications off.
-
.turn_on ⇒ Boolean
Turn notifications on.
Class Attribute Details
.gntp ⇒ Object
Returns the value of attribute gntp.
20 21 22 |
# File 'lib/guard/notifier.rb', line 20 def gntp @gntp end |
.growl_library ⇒ Object
Returns the value of attribute growl_library.
20 21 22 |
# File 'lib/guard/notifier.rb', line 20 def growl_library @growl_library end |
Class Method Details
.enabled? ⇒ Boolean
Test if the notifications are enabled and available.
73 74 75 |
# File 'lib/guard/notifier.rb', line 73 def enabled? ENV["GUARD_NOTIFY"] == 'true' end |
.notify(message, options = { }) ⇒ Object
Show a message with the system notification.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/guard/notifier.rb', line 53 def notify(, = { }) if enabled? image = .delete(:image) || :success title = .delete(:title) || "Guard" case RbConfig::CONFIG['target_os'] when /darwin/i notify_mac(title, , image, ) when /linux/i notify_linux(title, , image, ) when /mswin|mingw/i notify_windows(title, , image, ) end end end |
.turn_off ⇒ Object
Turn notifications off.
24 25 26 |
# File 'lib/guard/notifier.rb', line 24 def turn_off ENV["GUARD_NOTIFY"] = 'false' end |
.turn_on ⇒ Boolean
Turn notifications on. This tries to load the platform specific notification library.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/guard/notifier.rb', line 33 def turn_on ENV["GUARD_NOTIFY"] = 'true' case RbConfig::CONFIG['target_os'] when /darwin/i require_growl when /linux/i require_libnotify when /mswin|mingw/i require_rbnotifu end end |