Class: Notiffany::Notifier::Growl

Inherits:
Base
  • Object
show all
Defined in:
lib/notiffany/notifier/growl.rb

Overview

System notifications using the [growl](github.com/visionmedia/growl) gem.

This gem is available for OS X and sends system notifications to [Growl](growl.info) through the [GrowlNotify](growl.info/downloads) executable.

The `growlnotify` executable must be installed manually or by using [Homebrew](mxcl.github.com/homebrew/).

Sending notifications with this notifier will not show the different notifications in the Growl preferences. Use the :gntp notifier if you want to customize each notification type in Growl.

your `Guardfile` notification :growl, sticky: true, host: '192.168.1.5', password: 'secret'

Examples:

Install `growlnotify` with Homebrew

brew install growlnotify

Add the `growl` gem to your `Gemfile`

group :development
  gem 'growl'
end

Add the `:growl` notifier to your `Guardfile`

notification :growl

Add the `:growl_notify` notifier with configuration options to

Constant Summary collapse

INSTALL_GROWLNOTIFY =
"Please install the 'growlnotify' executable'\
' (available by installing the 'growl' gem)."
DEFAULTS =

Default options for the growl notifications.

{
  sticky:   false,
  priority: 0
}

Constants inherited from Base

Base::ERROR_ADD_GEM_AND_RUN_BUNDLE, Base::HOSTS

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#_image_path, #initialize, #name, #notify, #title

Constructor Details

This class inherits a constructor from Notiffany::Notifier::Base

Instance Method Details

#_check_available(_opts = {}) ⇒ Object


48
49
50
# File 'lib/notiffany/notifier/growl.rb', line 48

def _check_available(_opts = {})
  fail UnavailableError, INSTALL_GROWLNOTIFY unless ::Growl.installed?
end

#_perform_notify(message, opts = {}) ⇒ Object

Shows a system notification.

The documented options are for GrowlNotify 1.3, but the older options are also supported. Please see `growlnotify –help`.

Priority can be one of the following named keys: `Very Low`, `Moderate`, `Normal`, `High`, `Emergency`. It can also be an integer between -2 and 2.

Parameters:

  • message (String)

    the notification message body

  • opts (Hash) (defaults to: {})

    additional notification library options

Options Hash (opts):

  • type (String)

    the notification type. Either 'success', 'pending', 'failed' or 'notify'

  • title (String)

    the notification title

  • image (String)

    the path to the notification image

  • sticky (Boolean)

    make the notification sticky

  • priority (String, Integer)

    specify an int or named key (default is 0)

  • host (String)

    the hostname or IP address to which to send a remote notification

  • password (String)

    the password used for remote notifications


75
76
77
78
79
# File 'lib/notiffany/notifier/growl.rb', line 75

def _perform_notify(message, opts = {})
  opts = { name: "Notiffany" }.merge(opts)
  opts.select! { |k, _| ::Growl::Base.switches.include?(k) }
  ::Growl.notify(message, opts)
end

#_supported_hostsObject


44
45
46
# File 'lib/notiffany/notifier/growl.rb', line 44

def _supported_hosts
  %w(darwin)
end