Class: CheckZilla::Notifier::Hipchat

Inherits:
Object
  • Object
show all
Defined in:
lib/checkzilla/notifier/hipchat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Hipchat

Returns a new instance of Hipchat.



11
12
13
14
# File 'lib/checkzilla/notifier/hipchat.rb', line 11

def initialize &block
  instance_eval(&block) if block_given?
  self
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



7
8
9
# File 'lib/checkzilla/notifier/hipchat.rb', line 7

def api_token
  @api_token
end

#roomObject

Returns the value of attribute room.



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

def room
  @room
end

#usernameObject

Returns the value of attribute username.



9
10
11
# File 'lib/checkzilla/notifier/hipchat.rb', line 9

def username
  @username
end

Instance Method Details

#perform!(checkers) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/checkzilla/notifier/hipchat.rb', line 16

def perform! checkers
  client = HipChat::Client.new(@api_token)
  notify_users = false

  checkers.each do |checker|
    checker_name = checker.class.name.split("::").last
    title = "#{checker_name} Updates:"

    body = []
    checker.results.each do |name, versions|
      local_version = versions[0]
      newer_version = versions[1]
      body << "#{name} (#{local_version} -> #{newer_version})"
    end
    client[@room].send(@username, "#{title} #{body.join(', ')}", :notify => true, :color => 'red')
  end
end