Module TerminalNotifier
In: lib/terminal-notifier.rb

Methods

available?   execute   list   notify   notify_result   remove   version  

Classes and Modules

Class TerminalNotifier::UnsupportedPlatformError

Constants

BIN_PATH = File.expand_path('../../vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier', __FILE__)
LIST_FIELDS = [:group, :title, :subtitle, :message, :delivered_at].freeze

Public Class methods

Returns wether or not the current platform is macOS 10.10, or higher.

Public Instance methods

If a ‘group’ ID is given, and a notification for that group exists, returns a hash with details about the notification.

If no ‘group’ ID is given, an array of hashes describing all notifications.

If no information is available this will return `nil`.

Sends a User Notification and returns whether or not it was a success.

The available options are `:title`, `:group`, `:activate`, `:open`, `:execute`, `:sender`, and `:sound`. For a description of each option see:

  https://github.com/julienXX/terminal-notifier/blob/master/README.markdown

Examples are:

  TerminalNotifier.notify('Hello World')
  TerminalNotifier.notify('Hello World', :title => 'Ruby')
  TerminalNotifier.notify('Hello World', :group => Process.pid)
  TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
  TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/julienXX')
  TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
  TerminalNotifier.notify('Hello World', :sender => 'com.apple.Safari')
  TerminalNotifier.notify('Hello World', :sound => 'default')

Raises if not supported on the current platform.

Cleans up the result of a notification, making it easier to work it

The result of a notification is downcased, then groups of 1 or more non-word characters are replaced with an underscore, before being symbolised.

If the reply option was given, then instead of going through the above process, the result is returned with no changes as a string.

If the always_string param is set to true, a the result is returned with no changes as a string, like above.

Examples are:

notify_result(‘Test’, {}) #=> :test notify_result(‘No, sir’, {}) #=> :no_sir notify_result(’@timeout’, {}) #=> :_timeout notify_result(’@closeaction’, {}) #=> :_closeaction notify_result(‘I like pie’, {reply: true}) #=> ‘I like pie’ notify_result(‘I do not like pie’, {‘reply’ => true}) #=> ‘I do not like pie’ notify_result(’@timeout’, {‘reply’ => true}) #=> ’@timeout’ notify_result(‘I may like pie’, {}) #=> :i_may_like_pie

Removes a notification that was previously sent with the specified ‘group’ ID, if one exists.

If no ‘group’ ID is given, all notifications are removed.

[Validate]