Sha256: bd64d1b86b99f2cecf684d97ce2fa599e0ab70a332191d4b2f814e4d8d288702

Contents?: true

Size: 1.36 KB

Versions: 24

Compression:

Stored size: 1.36 KB

Contents

require 'esbit'

module SimpleDeploy
  class Notifier
    class Campfire

      def initialize(args)
        @stack_name = args[:stack_name]
        @environment = args[:environment]
        @config = SimpleDeploy.config
        @logger = SimpleDeploy.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}'."

        if @subdomain
          @token = @config.notifications['campfire']['token']
          @campfire = Esbit::Campfire.new @subdomain, @token
          @rooms = @campfire.rooms
        end
      end

      def send(message)
        @logger.info "Sending Campfire notifications."
        @room_ids.split(',').each do |room_id|
          room = @rooms.find { |r| r.id == room_id.to_i }
          if room
            @logger.debug "Sending notification to Campfire room #{room.name}."
            room.say message
          else
            @logger.warn "Could not find a room for id #{room_id}"
          end
        end
        @logger.info "Campfire notifications complete."
      end

      private

      def stack
        @stack ||= Stack.new :name        => @stack_name,
                             :environment => @environment
      end
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
simple_deploy-0.10.2 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.10.1 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.10.0 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.10.0.beta.3 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.10.0.beta.2 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.10.0.beta.1 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.9.2 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.9.1 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.9.0 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.8.2 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.8.2.beta1 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.8.1.beta1 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.8.0 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.8 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.7 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.7.beta.1 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.6 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.6.beta.6 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.6.beta.5 lib/simple_deploy/notifier/campfire.rb
simple_deploy-0.7.6.beta.3 lib/simple_deploy/notifier/campfire.rb