Sha256: e085e91be298c7df6b4ffc12a225eb0f66dad58a3e714899e577d5c62f6d0638

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'damagecontrol/publisher/base'
require 'ruby-growl'

module DamageControl
  module Publisher
    class Growl < Base
      register self
    
      NOTIFICATION_TYPES = ["Build Successful", "Build Failed"] unless defined? NOTIFICATION_TYPES
    
      ann :description => "Hosts", :tip => "Comma-separated list of (OS X) hosts that will receive Growl notifications. Requires Growl 0.6 or later."
      attr_reader :hosts

      def initialize
        @hosts = "localhost"
      end

      def name
        "Growl"
      end    

      def publish(build)
        message = nil
        index = nil
        if(build.successful?)
          message = "#{build.status_message} build (by #{build.changeset.developer})"
          index = 0
        else
          message = "#{build.changeset.developer} broke the build"
          index = 1
        end
        @hosts.split(%r{,\s*}).each do |host|
          begin
            g = ::Growl.new(host, "DamageControl (#{build.project.name})", NOTIFICATION_TYPES)
            # A bug in Ruby-Growl (or Growl) prevents the message from being sticky.
            g.notify(NOTIFICATION_TYPES[index], build.project.name, message, 0, true)
          rescue Exception => e
            Log.info("Growl publisher failed to notify #{host}: #{e.message}")
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
damagecontrol-0.5.0.1391 lib/damagecontrol/publisher/growl.rb
damagecontrol-0.5.0.1392 lib/damagecontrol/publisher/growl.rb
damagecontrol-0.5.0.1393 lib/damagecontrol/publisher/growl.rb
damagecontrol-0.5.0.1404 lib/damagecontrol/publisher/growl.rb