Module: Guard::Notifier::Notifu

Extended by:
Notifu
Included in:
Notifu
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 rb-notifu gem

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

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) available?(silent = false)

Test if the notification library is available.

Parameters:

  • silent (Boolean) (defaults to: false)

    true if no error messages should be shown

Returns:

  • (Boolean)

    the availability status



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/guard/notifiers/rb_notifu.rb', line 40

def available?(silent = false)
  if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
    require 'rb-notifu'

    true

  else
    ::Guard::UI.error 'The :notifu notifier runs only on Windows.' unless silent
    false
  end

rescue LoadError
  ::Guard::UI.error "Please add \"gem 'rb-notifu'\" to your Gemfile and run Guard with \"bundle exec\"." unless silent
  false
end

- (Object) notify(type, title, message, image, options = { })

Show a system notification.

Parameters:

  • type (String)

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

  • title (String)

    the notification title

  • message (String)

    the notification message body

  • image (String)

    the path to the notification image

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

    additional notification library options

Options Hash (options):

  • 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



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

def notify(type, title, message, image, options = { })
  require 'rb-notifu'

  ::Notifu.show(DEFAULTS.merge(options).merge({
    :type    => notifu_type(type),
    :title   => title,
    :message => message
  }))
end