Class: Chef::Handler::Campfire

Inherits:
Chef::Handler show all
Defined in:
lib/chef/handler/campfire.rb

Constant Summary collapse

VERSION =
'2.0.2'

Instance Method Summary collapse

Constructor Details

#initialize(subdomain, token, room) ⇒ Campfire

Returns a new instance of Campfire.



22
23
24
25
26
# File 'lib/chef/handler/campfire.rb', line 22

def initialize(subdomain, token, room)
  @subdomain = subdomain
  @token = token
  @room = room
end

Instance Method Details

#reportObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/chef/handler/campfire.rb', line 28

def report
  if run_status.failed?
    Chef::Log.error('Creating Campfire exception report.')
    campfire = Tinder::Campfire.new(@subdomain, :token => @token)

    room = if @room.nil?
             campfire.rooms.first
           else
             campfire.find_room_by_id(@room.to_i)
           end

    room.speak([node.hostname, run_status.formatted_exception].join(' '))
    room.paste(Array(backtrace).join('\n'))
  end
end