Sha256: c47b900885235eba2ade74aaf854e9e83451a8ee27fba3673a3bbbf4cabe01a4

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

Contents

#!/usr/bin/env ruby

require 'xmpp4r-simple'

module Flapjack
  module Notifiers
    class Xmpp
    
      def initialize(opts={})
    
        @jid = opts[:jid]
        @password = opts[:password]
        @log = opts[:logger]
        unless @jid && @password 
          raise ArgumentError, "You have to provide a username and password"
        end

        begin 
          @xmpp = Jabber::Simple.new(@jid, @password)
        rescue SocketError => e
          @log.error("XMPP: #{e.message}")
        end
    
      end
    
      def notify(opts={})
    
        raise unless opts[:who] && opts[:result]
    
        message = <<-DESC
          Check #{opts[:result].id} returned the status "#{opts[:result].status}".
            http://localhost:4000/checks/#{opts[:result].id}
        DESC
    
        @xmpp.deliver(opts[:who].jid, message)
    
      end
    
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
auxesis-flapjack-0.4.10 lib/flapjack/notifiers/xmpp/xmpp.rb
auxesis-flapjack-0.4.8 lib/flapjack/notifiers/xmpp/xmpp.rb
auxesis-flapjack-0.4.9 lib/flapjack/notifiers/xmpp/xmpp.rb
flapjack-0.4.11 lib/flapjack/notifiers/xmpp/xmpp.rb
flapjack-0.4.10 lib/flapjack/notifiers/xmpp/xmpp.rb