Sha256: 0a9dca6a048991f1d2ec50cd752c35071cc274a20404aa1419f58b98bf218ee1

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 Bytes

Contents

module Bullet
  module Presenter
    class Growl < Base
      @growl = nil

      def self.active? 
        @growl
      end

      def self.out_of_channel( notice )
        return unless active?
        notify( notice.standard_notice )
      end

      def self.setup_connection( password )
        require 'ruby-growl'
        @password = password
        @growl = connect

        notify 'Bullet Growl notifications have been turned on'
      rescue MissingSourceFile
        @growl = nil
        raise NotificationError.new( 'You must install the ruby-growl gem to use Growl notifications: `sudo gem install ruby-growl`' )
      end

      private
        def self.connect
          ::Growl.new 'localhost',
                      'ruby-growl',
                      [ 'Bullet Notification' ],
                      nil,
                      @password
        end

        def self.notify( message )
          @growl.notify( 'Bullet Notification', 'Bullet Notification', message )
        end
    end 
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bullet-2.0.0.rc2 lib/bullet/presenter/growl.rb
bullet-2.0.0.rc1 lib/bullet/presenter/growl.rb
bullet-2.0.0.beta.4 lib/bullet/presenter/growl.rb
bullet-2.0.0.beta.3 lib/bullet/presenter/growl.rb