Class: Photocopier::FTP
- Defined in:
- lib/photocopier/ftp.rb,
lib/photocopier/ftp/session.rb
Defined Under Namespace
Classes: Session
Instance Attribute Summary
Attributes inherited from Adapter
Instance Method Summary collapse
- #delete(remote_path) ⇒ Object
- #get(remote_path, file_path = nil) ⇒ Object
- #get_directory(remote_path, local_path, exclude = []) ⇒ Object
- #inferred_port ⇒ Object
-
#initialize(options = {}) ⇒ FTP
constructor
A new instance of FTP.
- #options ⇒ Object
- #put_directory(local_path, remote_path, exclude = []) ⇒ Object
- #put_file(file_path, remote_path) ⇒ Object
Methods inherited from Adapter
Constructor Details
#initialize(options = {}) ⇒ FTP
Returns a new instance of FTP.
3 4 5 |
# File 'lib/photocopier/ftp.rb', line 3 def initialize( = {}) @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, [:port]) end |
#inferred_port ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/photocopier/ftp.rb', line 32 def inferred_port if [:port].nil? && [:scheme] == 'sftp' 22 elsif [:port].nil? 21 else [:port] end end |
#options ⇒ Object
7 8 9 |
# File 'lib/photocopier/ftp.rb', line 7 def @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, [: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 |