module NRSER::Notify
Definitions
¶ ↑
Definitions
¶ ↑
Constants
- 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.
@return [Pathname]
- VERSION
String version of the gem.
@return [String]
Public Class Methods
Can we send notification to the user?
Right now, only {.terminal_notifier?} is tested, but we can add more options in the future.
@return [Boolean]
# File lib/nrser/notify.rb, line 70 def self.available? terminal_notifier? end
Send a notification to the use if notifications are {.available?}.
# File lib/nrser/notify.rb, line 77 def self.notify message, **options, &block return false unless available? notify! message, **options, &block end
Force sending of a notification regardless of {.available?}.
# File lib/nrser/notify.rb, line 85 def self.notify! message, **options, &block require 'terminal-notifier' TerminalNotifier.notify message, **options, &block end
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.
@return [Boolean]
# File lib/nrser/notify.rb, line 51 def self.terminal_notifier? begin require 'terminal-notifier' rescue LoadError => error false else TerminalNotifier.available? end end