public
Description: Other clients for irccat
Homepage: http://irccat.rubyforge.org/clients.html
Clone URL: git://github.com/webs/irccat-clients.git
irccat-clients / cat_notifier / cat_notifier.rb
100644 44 lines (38 sloc) 1.231 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# CatNotifier - CruiseControl Notifier for irc_cat
#
# Put this file in {CruiseControl Path}/builder_plugins/installed/
# Tell the builder, whom do you want to receive build notices
# <pre><code>Project.configure do |project|
# ...
# project.cat_notifier.host = "your.irccat.host"
# project.cat_notifier.port = "yourport"
# ...
# end</code></pre>
#
# And enjoy :-)
# -Jordan Bracco <jordan@lifeisdead.net>
class CatNotifier
  attr_accessor :host, :port
  def initialize(project = nil)
  end
 
  def build_finished(build)
    return if not build.failed?
    catsend("#{build.project.name} build #{build.label} failed :-( Build cat is not happy.")
    CruiseControl::Log.event("Sent build failed to irccat", :debug)
  end
 
  def build_fixed(build, previous_build)
    catsend("#{build.project.name} build #{build.label} fixed! Yay!")
    CruiseControl::Log.event("Sent build fixed to irccat", :debug)
  end
  
  def catsend(message)
    begin
      raise "Not Configured!" if @host.nil?||@port.nil?
      socket = TCPSocket.open(@host,@port)
      socket.write(message + "\r\n")
    rescue => e
      CruiseControl::Log.event("CatNotifier Error :\n#{e}", :error)
      raise
    end
  end
 
end
 
Project.plugin :cat_notifier