Module: NRSER::Notify
- Extended by:
- MethodDecorators
- Defined in:
- lib/nrser/notify.rb,
lib/nrser/notify/version.rb
Overview
Definitions
Constant Summary collapse
- ROOT =
Absolute, expanded path to the gem’s root directory.
Here in ‘//lib/nrser/version` so that it can be used via
require 'nrser/version'
without loading the entire module.
( Pathname.new( __FILE__ ).dirname / '..' / '..' / '..' ).
- VERSION =
String version of the gem.
(ROOT / 'VERSION').read
Class Method Summary collapse
-
.available? ⇒ Boolean
Can we send notification to the user?.
-
.notify(message, **options, &block) ⇒ Object
Send a notification to the use if notifications are Notify.available?.
-
.notify!(message, **options, &block) ⇒ Object
Force sending of a notification regardless of Notify.available?.
-
.terminal_notifier? ⇒ Boolean
Is the ‘terminal-notifier` gem available?.
Class Method Details
.available? ⇒ Boolean
Can we send notification to the user?
Right now, only terminal_notifier? is tested, but we can add more options in the future.
70 71 72 |
# File 'lib/nrser/notify.rb', line 70 def self.available? terminal_notifier? end |
.notify(message, **options, &block) ⇒ Object
Send a notification to the use if notifications are available?.
77 78 79 80 |
# File 'lib/nrser/notify.rb', line 77 def self.notify , **, &block return false unless available? notify! , **, &block end |
.notify!(message, **options, &block) ⇒ Object
Force sending of a notification regardless of available?.
85 86 87 88 |
# File 'lib/nrser/notify.rb', line 85 def self.notify! , **, &block require 'terminal-notifier' TerminalNotifier.notify , **, &block end |
.terminal_notifier? ⇒ Boolean
Is the ‘terminal-notifier` gem available?
- terminal-notifier][
-
is not an NRSER dependency since it does not make
sense for many systems and situations. It must be installed separately.
[terminal-notifier]: rubygems.org/gems/terminal-notifier
Tests by trying to ‘require` it.
51 52 53 54 55 56 57 58 59 |
# File 'lib/nrser/notify.rb', line 51 def self.terminal_notifier? begin require 'terminal-notifier' rescue LoadError => error false else TerminalNotifier.available? end end |