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, wrap_js_association

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


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

def self.active?
  @growl
end

.out_of_channel_notify(message) ⇒ Object



9
10
11
12
# File 'lib/uniform_notifier/growl.rb', line 9

def self.out_of_channel_notify( message )
  return unless active?
  notify( message )
end

.setup_connection(growl) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/uniform_notifier/growl.rb', line 14

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



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/uniform_notifier/growl.rb', line 38

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)'
end

.setup_connection_growl(growl) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/uniform_notifier/growl.rb', line 25

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',
                       [ 'uniform_notifier' ],
                       nil,
                       @password)

  notify 'Uniform Notifier Growl has been turned on'
end