Class: Integrity::Notifier::Jabber

Inherits:
Notifier::Base
  • Object
show all
Defined in:
lib/integrity/notifier/jabber.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build, config = {}) ⇒ Jabber

Returns a new instance of Jabber.



13
14
15
16
17
18
19
20
# File 'lib/integrity/notifier/jabber.rb', line 13

def initialize(build, config = {})
  host = config["host"].blank? ? nil  : config.delete("host")
  post = config["port"].blank? ? 5222 : config.delete("port")
  @server = ::Jabber::Simple.new(config.delete("user"), config.delete("pass"), nil, "Available", host, port)
  sleep 4
  @recipients = config["recipients"].nil? ? [] : config.delete("recipients").split(/\s+/) 
  super
end

Instance Attribute Details

#recipientsObject (readonly)

Returns the value of attribute recipients.



7
8
9
# File 'lib/integrity/notifier/jabber.rb', line 7

def recipients
  @recipients
end

Class Method Details

.to_hamlObject



9
10
11
# File 'lib/integrity/notifier/jabber.rb', line 9

def self.to_haml
  File.read(File.dirname(__FILE__) / "config.haml")
end

Instance Method Details

#deliver!Object



22
23
24
25
26
# File 'lib/integrity/notifier/jabber.rb', line 22

def deliver!
  @recipients.each do |r|
    @server.deliver(r, message)
  end
end

#messageObject



28
29
30
31
32
33
34
35
# File 'lib/integrity/notifier/jabber.rb', line 28

def message
  @message ||= <<-content
#{build.project.name}: #{short_message}  (#{commit.committed_at} by #{commit.author.name})
Message: #{commit.message}
Link: #{build_url}
content
  
end