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

rubocop:disable Lint/MissingSuper



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

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

Instance Method Details

#delete(remote_path) ⇒ Object



21
22
23
# File 'lib/photocopier/ftp.rb', line 21

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

#get(remote_path, file_path = nil) ⇒ Object



13
14
15
# File 'lib/photocopier/ftp.rb', line 13

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

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



25
26
27
28
# File 'lib/photocopier/ftp.rb', line 25

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



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

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

#optionsObject

rubocop:enable Lint/MissingSuper



9
10
11
# File 'lib/photocopier/ftp.rb', line 9

def options
  @options.clone
end

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



30
31
32
# File 'lib/photocopier/ftp.rb', line 30

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



17
18
19
# File 'lib/photocopier/ftp.rb', line 17

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