module Guard::Notifier::GNTP
def available?(silent = false)
-
(Boolean)
- the availability status
Parameters:
-
silent
(Boolean
) -- true if no error messages should be shown
def available?(silent = false) if RbConfig::CONFIG['host_os'] =~ /darwin|linux|freebsd|openbsd|sunos|solaris|mswin|mingw/ require 'ruby_gntp' true else ::Guard::UI.error 'The :gntp notifier runs only on Mac OS X, Linux, FreeBSD, OpenBSD, Solaris and Windows.' unless silent false end rescue LoadError ::Guard::UI.error "Please add \"gem 'ruby_gntp'\" to your Gemfile and run Guard with \"bundle exec\"." unless silent false end
def notify(type, title, message, image, options = { })
(**options)
-
sticky
(Boolean
) -- make the notification sticky -
port
(Integer
) -- the port to send a remote notification -
password
(String
) -- the password used for remote notifications -
host
(String
) -- the hostname or IP address to which to send a remote notification
Parameters:
-
options
(Hash
) -- additional notification library options -
image
(String
) -- the path to the notification image -
message
(String
) -- the notification message body -
title
(String
) -- the notification title -
type
(String
) -- the notification type. Either 'success', 'pending', 'failed' or 'notify'
def notify(type, title, message, image, options = { }) require 'ruby_gntp' options = DEFAULTS.merge(options) gntp = ::GNTP.new('Guard', options.delete(:host), options.delete(:password), options.delete(:port)) unless registered? gntp.register(:notifications => [ { :name => 'notify', :enabled => true }, { :name => 'failed', :enabled => true }, { :name => 'pending', :enabled => true }, { :name => 'success', :enabled => true } ]) registered! end gntp.notify(options.merge({ :name => type, :title => title, :text => message, :icon => "file://#{ image }" })) end
def registered!
Mark the notifier as registered.
def registered! @registered = true end
def registered?
-
(Boolean)
- registration status
def registered? @registered ||= false end