Sha256: 9a6f5c8faea40e7b5431a1ae3c96bc03cc378e4cc60172dcb46ad09ab206824a

Contents?: true

Size: 909 Bytes

Versions: 3

Compression:

Stored size: 909 Bytes

Contents

# frozen_string_literal: true

require 'open3'
require 'pg_export/import'
require 'pg_export/lib/pg_export/entities/dump'
require 'pg_export/lib/pg_export/value_objects/dump_file'

class PgExport
  module Repositories
    class FtpDumpRepository
      def all(database_name:, ftp_adapter:)
        ftp_adapter.list([database_name, '*'].compact.join('_')).map do |name:, size:|
          begin
            dump(name, database_name, size)
          rescue Dry::Types::ConstraintError
            nil
          end
        end.compact
      end

      private

      FilePlaceholder = Struct.new(:size)
      private_constant :FilePlaceholder

      def dump(name, database_name, size)
        Entities::Dump.new(
          name: name,
          database: database_name,
          file: ValueObjects::DumpFile.new(FilePlaceholder.new(size.to_i)),
          type: :encrypted
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_export-0.7.2 lib/pg_export/lib/pg_export/repositories/ftp_dump_repository.rb
pg_export-0.7.1 lib/pg_export/lib/pg_export/repositories/ftp_dump_repository.rb
pg_export-0.7.0 lib/pg_export/lib/pg_export/repositories/ftp_dump_repository.rb