Sha256: a1c65e0c2a5ba5050572cd6c7a05495d7c9a5837c69bfcfec1ef4cf8376fd0ac

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'tinder'

module SimpleDeploy
  class Notifier
    class Campfire

      def initialize(args)
        @stack_name = args[:stack_name]
        @environment = args[:environment]
        @config = args[:config]
        @logger = @config.logger

        attributes = stack.attributes
        @subdomain = attributes['campfire_subdomain']
        @room_ids = attributes['campfire_room_ids'] ||= ''
        @logger.debug "Campfire subdomain '#{@subdomain}'."
        @logger.debug "Campfire room ids '#{@room_ids}'."
        @token = @config.notifications['campfire']['token']
        @campfire = Tinder::Campfire.new @subdomain, :token => @token,
                                                     :verify => true
      end

      def send(message)
        @logger.info "Sending Campfire notifications."
        @room_ids.split(',').each do |room_id|
          @logger.debug "Sending notification to Campfire room #{room_id}."
          room = @campfire.find_room_by_id room_id.to_i
          room.speak message
        end
        @logger.info "Campfire notifications complete."
      end

      private

      def stack
        @stack ||= Stackster::Stack.new :environment => @environment,
                                        :name        => @stack_name,
                                        :config      => @config.environment(@environment),
                                        :logger      => @logger
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_deploy-0.4.3 lib/simple_deploy/notifier/campfire.rb