Class: Outpost::Notifiers::Campfire

Inherits:
Object
  • Object
show all
Defined in:
lib/outpost/notifiers/campfire.rb

Overview

The Campfire notifier issues Outpost notifications to the 37signals' Campfire web app (campfirenow.com). It issues messages about the system status in the specified subdomain and room.

This requires the 'tinder' gem to be installed.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Campfire

Returns a new instance of Campfire

Options Hash (options):

  • :subdomain (String)

    The subdomain of your campfire rooms

  • :token (String)

    An access token, can be found in your Account info

  • :room (String)

    The room notifications will be sent to

  • :campfire_notifier (Class)

    Another Campfire notification class. Defaults to Tinder's gem


25
26
27
28
29
30
31
32
33
34
# File 'lib/outpost/notifiers/campfire.rb', line 25

def initialize(options={})
  @subdomain         = options[:subdomain]         || ''
  @token             = options[:token]             || ''
  @room              = options[:room]              || ''
  @campfire_notifier = options[:campfire_notifier] || Tinder::Campfire

  if [@subdomain, @token, @room].any?(&:empty?)
    raise ArgumentError, 'You need to supply :token, :subdomain and :room.'
  end
end

Instance Method Details

#notify(outpost) ⇒ Object

Issues a notification to a Campfire room. This is a callback, called by an Outpost instance.


41
42
43
44
45
46
47
# File 'lib/outpost/notifiers/campfire.rb', line 41

def notify(outpost)
  campfire = @campfire_notifier.new @subdomain, :token => @token
  room     = campfire.find_room_by_name @room

  status = outpost.last_status.to_s
  room.speak "System is #{status}: #{outpost.messages.join(',')}"
end