Class: DamageControl::Publisher::Jabber

Inherits:
Base
  • Object
show all
Defined in:
lib/damagecontrol/publisher/jabber.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#enabled

Instance Method Summary collapse

Methods inherited from Base

classes, register

Constructor Details

#initializeJabber

Returns a new instance of Jabber.



19
20
21
22
# File 'lib/damagecontrol/publisher/jabber.rb', line 19

def initialize
  @id_resource = "[email protected]/damagecontrol"
  @friends = "[email protected]"
end

Instance Attribute Details

#friendsObject (readonly)

Returns the value of attribute friends.



17
18
19
# File 'lib/damagecontrol/publisher/jabber.rb', line 17

def friends
  @friends
end

#id_resourceObject (readonly)

Returns the value of attribute id_resource.



11
12
13
# File 'lib/damagecontrol/publisher/jabber.rb', line 11

def id_resource
  @id_resource
end

#passwordObject (readonly)

Returns the value of attribute password.



14
15
16
# File 'lib/damagecontrol/publisher/jabber.rb', line 14

def password
  @password
end

Instance Method Details

#nameObject



24
25
26
# File 'lib/damagecontrol/publisher/jabber.rb', line 24

def name
  "Jabber"
end

#publish(build) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/damagecontrol/publisher/jabber.rb', line 28

def publish(build)
  session = nil
  begin
    session = 
    message = nil
    if(build.successful?)
      message = "#{build.project.name}: #{build.status_message} build (by #{build.changeset.developer})"
    else
      message = "#{build.project.name}: #{build.changeset.developer} broke the build"
    end
    @friends.split(%r{,\s*}).each do |friend|
      begin
        session.new_message(friend).set_subject(message).set_body(message).send
      rescue Exception => e
        Log.error "Failed to send Jabber message to #{friend}"
      end
    end
  ensure
    session.release if session
  end
end