Module: Notifier::TerminalNotifier

Extended by:
TerminalNotifier
Included in:
TerminalNotifier
Defined in:
lib/notifier/terminal_notifier.rb

Instance Method Summary collapse

Instance Method Details

#notify(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/notifier/terminal_notifier.rb', line 9

def notify(options)
  command = [
    "terminal-notifier",
    "-group", "notifier-rubygems",
    "-title", options[:title].to_s,
    "-appIcon", options.fetch(:image, "").to_s,
    "-message", options[:message].to_s,
    "-subtitle", options.fetch(:subtitle, "").to_s
  ]

  # -sound with an empty string (e.g., "") will trigger the
  # default sound so we need to check for it.
  command.concat(["-sound", options.fetch(:sound, "default").to_s] ) if options[:sound]

  Thread.new { system(*command) }.join
end

#supported?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/notifier/terminal_notifier.rb', line 5

def supported?
  Notifier.os?(/darwin/) && `which terminal-notifier` && $? == 0
end