Class: Guard::Notifier::Notifu

Inherits:
Base
  • Object
show all
Defined in:
lib/guard/notifiers/rb_notifu.rb

Overview

System notifications using the [rb-notifu](github.com/stereobooster/rb-notifu) gem.

This gem is available for Windows and sends system notifications to [Notifu](www.paralint.com/projects/notifu/index.html):

Examples:

Add the `rb-notifu` gem to your `Gemfile`

group :development
  gem 'rb-notifu'
end

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

notification :notifu

Add the `:notifu` notifier with configuration options to your `Guardfile`

notification :notifu, time: 5, nosound: true, xp: true

Constant Summary

DEFAULTS =

Default options for the rb-notifu notifications.

{
  time:    3,
  icon:    false,
  baloon:  false,
  nosound: false,
  noquiet: false,
  xp:      false
}

Constants inherited from Base

Base::HOSTS

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Base

_supported_host?, #images_path, #initialize, name, #name, #normalize_standard_options!, require_gem_safely, title, #title

Constructor Details

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

Class Method Details

+ (Boolean) available?(opts = {})



43
44
45
# File 'lib/guard/notifiers/rb_notifu.rb', line 43

def self.available?(opts = {})
  super and require_gem_safely(opts)
end

+ (Object) gem_name



39
40
41
# File 'lib/guard/notifiers/rb_notifu.rb', line 39

def self.gem_name
  'rb-notifu'
end

+ (Object) supported_hosts



35
36
37
# File 'lib/guard/notifiers/rb_notifu.rb', line 35

def self.supported_hosts
  %w[mswin mingw]
end

Instance Method Details

- (Object) notify(message, opts = {})

Shows a system notification.

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

  • time (Number)

    the number of seconds to display (0 for infinit)

  • icon (Boolean)

    specify an icon to use (“parent” uses the icon of the parent process)

  • baloon (Boolean)

    enable ballon tips in the registry (for this user only)

  • nosound (Boolean)

    do not play a sound when the tooltip is displayed

  • noquiet (Boolean)

    show the tooltip even if the user is in the quiet period that follows his very first login (Windows 7 and up)

  • xp (Boolean)

    use IUserNotification interface event when IUserNotification2 is available



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/guard/notifiers/rb_notifu.rb', line 68

def notify(message, opts = {})
  super
  self.class.require_gem_safely

  opts = DEFAULTS.merge(
    type:    _notifu_type(opts.delete(:type)),
    message: message
  ).merge(opts)

  # The empty block is needed until https://github.com/stereobooster/rb-notifu/pull/1 is merged
  ::Notifu.show(opts) {}
end