Class: UniformNotifier::Growl

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

Class Method Summary collapse

Methods inherited from Base

inline_notify, out_of_channel_notify

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/uniform_notifier/growl.rb', line 5

def self.active?
  @growl
end

.setup_connection(growl) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/uniform_notifier/growl.rb', line 9

def self.setup_connection( growl )
  setup_connection_growl(growl)
rescue LoadError
  begin
    setup_connection_gntp(growl)
  rescue LoadError
    @growl = nil
    raise NotificationError.new( 'You must install the ruby-growl or the ruby_gntp gem to use Growl notification: `gem install ruby-growl` or `gem install ruby_gntp`' )
  end
end

.setup_connection_gntp(growl) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/uniform_notifier/growl.rb', line 31

def self.setup_connection_gntp( growl )
  return unless growl
  require 'ruby_gntp'
  @password = growl.instance_of?(Hash) ? growl[:password] : nil
  @growl = GNTP.new('uniform_notifier', 'localhost', @password, 23053)
  @growl.register({:notifications => [{
                                        :name     => 'uniform_notifier',
                                        :enabled  => true,
                                      }]})

  notify 'Uniform Notifier Growl has been turned on (using GNTP)' if !growl.instance_of?(Hash) || !growl[:quiet]
end

.setup_connection_growl(growl) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/uniform_notifier/growl.rb', line 20

def self.setup_connection_growl( growl )
  return unless growl
  require 'ruby-growl'
  @password = growl.instance_of?(Hash) ? growl[:password] : nil
  @growl = ::Growl.new 'localhost', 'uniform_notifier'
  @growl.add_notification 'uniform_notifier'
  @growl.password = @password

  notify 'Uniform Notifier Growl has been turned on' if !growl.instance_of?(Hash) || !growl[:quiet]
end