Sha256: 7895bc0b8f26045c6bf5dc6126c88fe30894c92586becdd7ac454547b5f79050

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'simple_deploy/notifier/campfire'

module SimpleDeploy
  class Notifier
    def initialize(args)
      @stack_name = args[:stack_name]
      @environment = args[:environment]
      @config = Config.new :logger => args[:logger]
      @logger = @config.logger
      @notifications = @config.notifications
    end

    def send_deployment_complete_message
      message = "Deployment to #{@stack_name} complete."
      attributes = stack.attributes

      if attributes['app_github_url']
        message += " App: #{attributes['app_github_url']}/commit/#{attributes['app']}"
      end

      if attributes['chef_repo_github_url']
        message += " Chef: #{attributes['chef_repo_github_url']}/commit/#{attributes['chef_repo']}"
      end

      send message
    end

    def send(message)
      @notifications.keys.each do |notification|
        case notification
        when 'campfire'
          campfire = Notifier::Campfire.new :stack_name  => @stack_name,
                                            :environment => @environment,
                                            :config      => @config
          campfire.send message
        end
      end
    end

    private

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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