Module: Notifier
- Extended by:
- Notifier
- Included in:
- Notifier
- Defined in:
- lib/notifier.rb,
lib/notifier/hud.rb,
lib/notifier/noop.rb,
lib/notifier/snarl.rb,
lib/notifier/kdialog.rb,
lib/notifier/knotify.rb,
lib/notifier/osd_cat.rb,
lib/notifier/version.rb,
lib/notifier/notify_send.rb,
lib/notifier/terminal_notifier.rb
Defined Under Namespace
Modules: Hud, Kdialog, Knotify, Noop, NotifySend, OsdCat, Snarl, TerminalNotifier, Version
Class Attribute Summary collapse
Instance Method Summary
collapse
Class Attribute Details
.default_notifier ⇒ Object
Returns the value of attribute default_notifier.
25
26
27
|
# File 'lib/notifier.rb', line 25
def default_notifier
@default_notifier
end
|
Instance Method Details
#from_name(name) ⇒ Object
56
57
58
59
60
|
# File 'lib/notifier.rb', line 56
def from_name(name)
const_get(classify(name.to_s))
rescue StandardError
nil
end
|
#notifier ⇒ Object
36
37
38
|
# File 'lib/notifier.rb', line 36
def notifier
supported_notifier_from_name(default_notifier) || supported_notifiers.first
end
|
#notifiers ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/notifier.rb', line 44
def notifiers
notifiers = constants.filter_map do |name|
const_get(name) unless skip_constants.include?(name.to_s)
end
notifiers.sort_by(&:name) + [Noop]
end
|
#notify(options) ⇒ Object
40
41
42
|
# File 'lib/notifier.rb', line 40
def notify(options)
notifier.notify(options)
end
|
#os?(regex) ⇒ Boolean
67
68
69
|
# File 'lib/notifier.rb', line 67
def os?(regex)
RUBY_PLATFORM =~ regex || RbConfig::CONFIG["host_os"] =~ regex
end
|
#setup ⇒ Object
28
29
30
|
# File 'lib/notifier.rb', line 28
def setup
self.default_notifier = ENV.fetch("NOTIFIER", nil)
end
|
#skip_constants ⇒ Object
32
33
34
|
# File 'lib/notifier.rb', line 32
def skip_constants
@skip_constants ||= %w[Noop Adapters Version]
end
|
#supported_notifier_from_name(name) ⇒ Object
62
63
64
65
|
# File 'lib/notifier.rb', line 62
def supported_notifier_from_name(name)
notifier = from_name(name)
notifier&.supported? ? notifier : nil
end
|
#supported_notifiers ⇒ Object
52
53
54
|
# File 'lib/notifier.rb', line 52
def supported_notifiers
notifiers.select(&:supported?)
end
|