Sha256: 34c40b119fab5bcf5c00c77798e1deb85482f0de4d9f09e04a4780353434a0f2

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 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_name = reader.key_name

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

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

          s3_destroyer.destroy_file :key_name   => key_name,
                                    :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

14 entries across 14 versions & 1 rubygems

Version Path
heirloom-0.12.7 lib/heirloom/archive/destroyer.rb
heirloom-0.12.5 lib/heirloom/archive/destroyer.rb
heirloom-0.12.4 lib/heirloom/archive/destroyer.rb
heirloom-0.12.3 lib/heirloom/archive/destroyer.rb
heirloom-0.12.2 lib/heirloom/archive/destroyer.rb
heirloom-0.12.1 lib/heirloom/archive/destroyer.rb
heirloom-0.12.0 lib/heirloom/archive/destroyer.rb
heirloom-0.11.2 lib/heirloom/archive/destroyer.rb
heirloom-0.11.1 lib/heirloom/archive/destroyer.rb
heirloom-0.11.0 lib/heirloom/archive/destroyer.rb
heirloom-0.11.0.beta.2 lib/heirloom/archive/destroyer.rb
heirloom-0.11.0.beta.1 lib/heirloom/archive/destroyer.rb
heirloom-0.10.1 lib/heirloom/archive/destroyer.rb
heirloom-0.10.0 lib/heirloom/archive/destroyer.rb