Class: Notiffany::Notifier::TerminalNotifier
- Defined in:
- lib/notiffany/notifier/terminal_notifier.rb
Overview
System notifications using the
[terminal-notifier](github.com/Springest/terminal-notifier-guard)
gem.
This gem is available for OS X 10.8 Mountain Lion and sends notifications to the OS X notification center.
Constant Summary collapse
- DEFAULTS =
{ app_name: "Notiffany" }
- ERROR_ONLY_OSX10 =
"The :terminal_notifier only runs"\ " on Mac OS X 10.8 and later."
Constants inherited from Base
Base::ERROR_ADD_GEM_AND_RUN_BUNDLE, Base::HOSTS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #_check_available(_opts = {}) ⇒ Object
- #_gem_name ⇒ Object
-
#_perform_notify(message, opts = {}) ⇒ Object
Shows a system notification.
- #_supported_hosts ⇒ Object
Methods inherited from Base
#_image_path, #initialize, #name, #notify, #title
Constructor Details
This class inherits a constructor from Notiffany::Notifier::Base
Instance Method Details
#_check_available(_opts = {}) ⇒ Object
27 28 29 30 |
# File 'lib/notiffany/notifier/terminal_notifier.rb', line 27 def _check_available(_opts = {}) return if ::TerminalNotifier::Guard.available? fail UnavailableError, ERROR_ONLY_OSX10 end |
#_gem_name ⇒ Object
23 24 25 |
# File 'lib/notiffany/notifier/terminal_notifier.rb', line 23 def _gem_name "terminal-notifier-guard" end |
#_perform_notify(message, opts = {}) ⇒ Object
Shows a system notification.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/notiffany/notifier/terminal_notifier.rb', line 45 def _perform_notify(, opts = {}) title = [opts[:app_name], opts[:type].downcase.capitalize].join(" ") opts = { title: title }.merge(opts) opts[:message] = opts[:title] ||= title opts.delete(:image) opts.delete(:app_name) ::TerminalNotifier::Guard.execute(false, opts) end |
#_supported_hosts ⇒ Object
19 20 21 |
# File 'lib/notiffany/notifier/terminal_notifier.rb', line 19 def _supported_hosts %w(darwin) end |