Class: Photocopier::FTP

Inherits:
Adapter show all
Defined in:
lib/photocopier/ftp.rb,
lib/photocopier/ftp/session.rb

Defined Under Namespace

Classes: Session

Instance Attribute Summary

Attributes inherited from Adapter

#logger

Instance Method Summary collapse

Methods inherited from Adapter

#put

Constructor Details

#initialize(options = {}) ⇒ FTP

Returns a new instance of FTP.



3
4
5
# File 'lib/photocopier/ftp.rb', line 3

def initialize(options = {})
  @options = options
end

Instance Method Details

#delete(remote_path) ⇒ Object



19
20
21
# File 'lib/photocopier/ftp.rb', line 19

def delete(remote_path)
  session.delete(remote_path)
end

#get(remote_path, file_path = nil) ⇒ Object



11
12
13
# File 'lib/photocopier/ftp.rb', line 11

def get(remote_path, file_path = nil)
  session.get remote_path, file_path
end

#get_directory(remote_path, local_path, exclude = []) ⇒ Object



23
24
25
26
# File 'lib/photocopier/ftp.rb', line 23

def get_directory(remote_path, local_path, exclude = [])
  FileUtils.mkdir_p(local_path)
  lftp(local_path, remote_path, false, exclude, options[:port])
end

#inferred_portObject



32
33
34
35
36
37
38
39
40
# File 'lib/photocopier/ftp.rb', line 32

def inferred_port
  if options[:port].nil? && options[:scheme] == 'sftp'
    22
  elsif options[:port].nil?
    21
  else
    options[:port]
  end
end

#optionsObject



7
8
9
# File 'lib/photocopier/ftp.rb', line 7

def options
  @options.clone
end

#put_directory(local_path, remote_path, exclude = []) ⇒ Object



28
29
30
# File 'lib/photocopier/ftp.rb', line 28

def put_directory(local_path, remote_path, exclude = [])
  lftp(local_path, remote_path, true, exclude, options[:port])
end

#put_file(file_path, remote_path) ⇒ Object



15
16
17
# File 'lib/photocopier/ftp.rb', line 15

def put_file(file_path, remote_path)
  session.put_file file_path, remote_path
end