Sha256: 7c53cd271b3a4894360560ad87d4cb23b566e5b6e5b8d185eefc7be8c7f7a4db

Contents?: true

Size: 973 Bytes

Versions: 1

Compression:

Stored size: 973 Bytes

Contents

module UniformNotifier
  class Growl < Base
    @growl = nil

    def self.active?
      @growl
    end

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

    def self.setup_connection( growl )
      return unless growl
      require 'ruby-growl'
      @password = growl.instance_of?(Hash) ? growl[:password] : nil
      @growl = connect

      notify 'Uniform Notifier Growl has been turned on'
    rescue LoadError
      @growl = nil
      raise NotificationError.new( 'You must install the ruby-growl gem to use Growl notification: `gem install ruby-growl`' )
    end

    private
      def self.connect
        ::Growl.new 'localhost',
                    'uniform_notifier',
                    [ 'uniform_notifier' ],
                    nil,
                    @password
      end

      def self.notify( message )
        @growl.notify( 'uniform_notifier', 'Uniform Notifier', message )
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uniform_notifier-1.0.1 lib/uniform_notifier/growl.rb