Sha256: 65ab390e13094f879916a525e3c02a3cba2285b0f7ba1f223091070b8f9f3b63

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

class PgExport
  module Ftp
    class Repository
      def initialize(adapter:, logger:)
        @adapter, @logger = adapter, logger
      end

      def persist(dump)
        adapter.persist(dump.path, dump.timestamped_name)
        logger.info "Persist #{dump} #{dump.timestamped_name} to #{adapter}"
      end

      def get(db_name)
        dump = Dump.new(name: 'Encrypted Dump', db_name: db_name)
        adapter.get(dump.path, dump.db_name)
        logger.info "Get #{dump} #{db_name} from #{adapter}"
        dump
      end

      def remove_old(name, keep)
        find_by_name(name).drop(keep).each do |filename|
          adapter.delete(filename)
          logger.info "Remove #{filename} from #{adapter}"
        end
      end

      def find_by_name(name)
        adapter.list(name + '_*')
      end

      def all
        adapter.list('*')
      end

      private

      attr_reader :adapter, :logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.6.1 lib/pg_export/ftp/repository.rb
pg_export-0.6.0 lib/pg_export/ftp/repository.rb