Sha256: ee1282f0cbf8fb5e7afdd4e7a5dd4b4e452c6b7beb672fb266aad8c020d0b987

Contents?: true

Size: 506 Bytes

Versions: 3

Compression:

Stored size: 506 Bytes

Contents

class PgExport
  class RemoveOldDumps
    include Logging

    def initialize(dump, keep_dumps_count)
      @dump = dump
      @keep_dumps_count = keep_dumps_count
    end

    def call
      files.sort.reverse.drop(keep_dumps_count).each do |filename|
        File.delete("#{dump.dirname}/#{filename}")
        logger.info "Remove file #{filename}"
      end
    end

    private

    attr_reader :dump, :keep_dumps_count

    def files
      Dir.entries(dump.dirname).grep(dump.regexp)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_export-0.1.2 lib/pg_export/actions/remove_old_dumps.rb
pg_export-0.1.1 lib/pg_export/actions/remove_old_dumps.rb
pg_export-0.1.0 lib/pg_export/actions/remove_old_dumps.rb