Class: Integrity::Notifier::Bonjour

Inherits:
Notifier::Base
  • Object
show all
Defined in:
lib/bonjour.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Bonjour.



13
14
15
16
# File 'lib/bonjour.rb', line 13

def initialize(build, config={})
  @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/bonjour.rb', line 7

def recipients
  @recipients
end

Class Method Details

.to_hamlObject



9
10
11
# File 'lib/bonjour.rb', line 9

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

Instance Method Details

#deliver!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bonjour.rb', line 18

def deliver!
  user = Ahoy::User.new("Integrity")
  user.
  sleep 1 # wait for the contact list to populate
  
  contacts = user.contacts.select{|c|@recipients.include?(c.name)}
  
  contacts.each do |contact|
    chat = user.chat(contact)
    chat.send(message)
    chat.close
  end
  user.sign_out
end

#messageObject



33
34
35
# File 'lib/bonjour.rb', line 33

def message
  @message ||= commit.successful? ? short_message : "#{short_message} #{commit_url}"
end