Parent

Files

Guard::Notifier::TerminalNotifier

System notifications using the [terminal-notifier-guard](github.com/Springest/terminal-notifier-guard) gem.

This gem is available for OS X 10.8 Mountain Lion and sends notifications to the OS X notification center.

@example Add the `terminal-notifier-guard` gem to your `Gemfile`

group :development
  gem 'terminal-notifier-guard'
end

@example Add the `:terminal_notifier` notifier to your `Guardfile`

notification :terminal_notifier

@example Add the `:terminal_notifier` notifier with configuration options to your `Guardfile`

notification :terminal_notifier, app_name: "MyApp"

Public Class Methods

_register!(options) click to toggle source

@private

# File lib/guard/notifiers/terminal_notifier.rb, line 65
def self._register!(options)
  if ::TerminalNotifier::Guard.available?
    true
  else
    unless options[:silent]
      ::Guard::UI.error 'The :terminal_notifier only runs on Mac OS X 10.8 and later.'
    end
    false
  end
end
available?(opts = {}) click to toggle source
# File lib/guard/notifiers/terminal_notifier.rb, line 34
def self.available?(opts = {})
  super
  _register!(opts) if require_gem_safely(opts)
end
gem_name() click to toggle source
# File lib/guard/notifiers/terminal_notifier.rb, line 30
def self.gem_name
  'terminal-notifier-guard'
end
supported_hosts() click to toggle source
# File lib/guard/notifiers/terminal_notifier.rb, line 26
def self.supported_hosts
  ]darwin]
end

Public Instance Methods

notify(message, opts = {}) click to toggle source

Shows a system notification.

@param [String] message the notification message body @param [Hash] opts additional notification library options @option opts [String] type the notification type. Either 'success',

'pending', 'failed' or 'notify'

@option opts [String] title the notification title @option opts [String] image the path to the notification image (ignored) @option opts [String] app_name name of your app @option opts [String] execute a command @option opts [String] activate an app bundle @option opts [String] open some url or file

# File lib/guard/notifiers/terminal_notifier.rb, line 52
def notify(message, opts = {})
  self.class.require_gem_safely
  title = opts[:title]
  normalize_standard_options!(opts)

  opts.delete(:image)
  opts[:title] = title || [opts.delete(:app_name) { 'Guard' }, opts[:type].downcase.capitalize].join(' ')

  ::TerminalNotifier::Guard.execute(false, opts.merge(message: message))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.