Sha256: e9e3190683054284d3f464fea3acdde08e010b9591bce876f50d3f2e577c6277

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 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
      end

      def send(message)
        @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.debug "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

2 entries across 2 versions & 1 rubygems

Version Path
simple_deploy-0.4.2 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.4.1 lib/simple_deploy/notifier/campfire.rb