Sha256: 6e6467370fd74b706bd35e78679912c6226981330890a99806b099c9ee1dd869

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

class ExceptionNotifier
  class CampfireNotifier
    cattr_accessor :tinder_available, true

    attr_accessor :subdomain
    attr_accessor :token
    attr_accessor :room

    def initialize(options)
      begin
        return unless tinder_available

        subdomain = options.delete(:subdomain)
        room_name = options.delete(:room_name)
        @campfire = Tinder::Campfire.new subdomain, options
        @room     = @campfire.find_room_by_name room_name
      rescue
        @campfire = @room = nil
      end
    end

    def exception_notification(exception)
      @room.paste "A new exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'" if active?
    end

    private

    def active?
      !@room.nil?
    end
  end
end

ExceptionNotifier::CampfireNotifier.tinder_available = Gem.loaded_specs.keys.include? 'tinder'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exception_notification-3.0.1 lib/exception_notifier/campfire_notifier.rb
exception_notification-3.0.1.rc1 lib/exception_notifier/campfire_notifier.rb