Files

Guard::Notifier::GrowlNotify

System notifications using the [GrowlNotify](github.com/scottdavis/growl_notify) gem.

This gem is available for OS X and sends system notifications to [Growl](growl.info) through AppleScript.

@example Add the `growl_notify` gem to your `Gemfile`

group :development
  gem 'growl_notify'
end

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

notification :growl_notify

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

notification :growl_notify, sticky: true

Constants

DEFAULTS

Default options for the growl_notify notifications.

Public Class Methods

_register!(options) click to toggle source

@private

Detects if the GrowlNotify gem is available and if not, displays an error message unless `opts` is true. If it’s available, GrowlNotify is configured for Guard.

@return [Boolean] whether or not GrowlNotify is available

# File lib/guard/notifiers/growl_notify.rb, line 46
def self._register!(options)
  if ::GrowlNotify.application_name != 'Guard'
    ::GrowlNotify.config do |c|
      c.notifications         = %(success pending failed notify)
      c.default_notifications = 'notify'
      c.application_name      = 'Guard'
    end
  end

  true

rescue ::GrowlNotify::GrowlNotFound
  unless options[:silent]
    ::Guard::UI.error 'Please install Growl from http://growl.info'
  end
  false
end
available?(opts = {}) click to toggle source
# File lib/guard/notifiers/growl_notify.rb, line 34
def self.available?(opts = {})
  super and require_gem_safely(opts) and _register!(opts)
end
supported_hosts() click to toggle source
# File lib/guard/notifiers/growl_notify.rb, line 30
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 @option opts [Boolean] sticky if the message should stick to the screen @option opts [Integer] priority the importance of message from -2 (very

low) to 2 (emergency)
# File lib/guard/notifiers/growl_notify.rb, line 76
def notify(message, opts = {})
  super
  self.class.require_gem_safely

  opts = DEFAULTS.merge(
    application_name: 'Guard',
    with_name:        opts.delete(:type).to_s,
    description:      message,
    icon:             opts.delete(:image)
  ).merge(opts)

  ::GrowlNotify.send_notification(opts)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.