Class: PgExport::FtpService

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_export/ftp_service.rb,
lib/pg_export/ftp_service/connection.rb

Defined Under Namespace

Classes: Connection

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ FtpService

Returns a new instance of FtpService.



3
4
5
6
7
# File 'lib/pg_export/ftp_service.rb', line 3

def initialize(params)
  connection = Connection.new(params)
  @ftp = connection.ftp
  ObjectSpace.define_finalizer(self, proc { connection.close })
end

Instance Method Details

#delete(filename) ⇒ Object



13
14
15
# File 'lib/pg_export/ftp_service.rb', line 13

def delete(filename)
  ftp.delete(filename)
end

#list(regexp) ⇒ Object



9
10
11
# File 'lib/pg_export/ftp_service.rb', line 9

def list(regexp)
  ftp.list(regexp).map { |item| item.split(' ').last }.sort.reverse
end

#upload_file(path) ⇒ Object



17
18
19
# File 'lib/pg_export/ftp_service.rb', line 17

def upload_file(path)
  ftp.putbinaryfile(path.to_s)
end