Class: Integrity::Notifier::Jabber

Inherits:
Notifier::Base
  • Object
show all
Defined in:
lib/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.



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

def initialize(build, config = {})
  host = config["host"].blank? ? nil  : config.delete("host")
  port = 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.



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

def recipients
  @recipients
end

Class Method Details

.to_hamlObject



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

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

Instance Method Details

#deliver!Object



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

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

#messageObject



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

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