Sha256: f4db8eb3163cefe679253a098e90142d21cc0337cd63afb07fad8c07597e31d1

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

module Heirloom

  class Destroyer

    def initialize(args)
      @config = args[:config]
      @name = args[:name]
      @domain = "heirloom_#{@name}"
      @id = args[:id]
      @logger = @config.logger
    end

    def destroy(args)
      regions = args[:regions]

      @logger.info "Destroying #{@name} #{@id}"

      regions.each do |region|
        bucket = reader.get_bucket :region => region

        key = "#{@id}.tar.gz"

        if bucket
          @logger.debug "Destroying 's3://#{bucket}/#{@name}/#{key}'."

          s3_destroyer = Destroyer::S3.new :config => @config,
                                           :region => region

          s3_destroyer.destroy_file :key_name   => key,
                                    :bucket     => bucket,
                                    :key_folder => @name
        end
      end

      sdb.delete @domain, @id
    end

    private

    def sdb
      @sdb ||= AWS::SimpleDB.new :config => @config
    end

    def reader
      @reader ||= Reader.new :config => @config,
                             :name   => @name,
                             :id     => @id
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
heirloom-0.9.0 lib/heirloom/archive/destroyer.rb
heirloom-0.8.3 lib/heirloom/archive/destroyer.rb
heirloom-0.8.2 lib/heirloom/archive/destroyer.rb
heirloom-0.8.1 lib/heirloom/archive/destroyer.rb
heirloom-0.8.0 lib/heirloom/archive/destroyer.rb
heirloom-0.7.4 lib/heirloom/archive/destroyer.rb
heirloom-0.7.3 lib/heirloom/archive/destroyer.rb
heirloom-0.7.3rc2 lib/heirloom/archive/destroyer.rb
heirloom-0.7.3rc1 lib/heirloom/archive/destroyer.rb
heirloom-0.7.2 lib/heirloom/archive/destroyer.rb
heirloom-0.7.2rc2 lib/heirloom/archive/destroyer.rb
heirloom-0.7.2rc1 lib/heirloom/archive/destroyer.rb
heirloom-0.7.1 lib/heirloom/archive/destroyer.rb
heirloom-0.7.0 lib/heirloom/archive/destroyer.rb
heirloom-0.7.0rc1 lib/heirloom/archive/destroyer.rb