Class: Libelule::Client
- Inherits:
-
Object
- Object
- Libelule::Client
- Defined in:
- lib/libelule.rb
Class Attribute Summary collapse
-
.silence_log_messages ⇒ Object
Returns the value of attribute silence_log_messages.
Instance Attribute Summary collapse
-
#ftp_client ⇒ Object
Returns the value of attribute ftp_client.
Instance Method Summary collapse
- #clean_up(target_dir, options) ⇒ Object
- #clean_up_with_manifest(target_dir, manifest, options = {}) ⇒ Object
- #ftp ⇒ Object
-
#initialize(host, user, password) ⇒ Client
constructor
A new instance of Client.
- #one_way_sync_from_local_to_remote(local_dir, remote_dir) ⇒ Object
Constructor Details
#initialize(host, user, password) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 |
# File 'lib/libelule.rb', line 13 def initialize(host, user, password) @host = host @user = user @password = password @ftp_client = Net::FTP end |
Class Attribute Details
.silence_log_messages ⇒ Object
Returns the value of attribute silence_log_messages.
7 8 9 |
# File 'lib/libelule.rb', line 7 def @silence_log_messages end |
Instance Attribute Details
#ftp_client ⇒ Object
Returns the value of attribute ftp_client.
11 12 13 |
# File 'lib/libelule.rb', line 11 def ftp_client @ftp_client end |
Instance Method Details
#clean_up(target_dir, options) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/libelule.rb', line 41 def clean_up(target_dir, ) suffix_to_keep = [:suffix_to_keep] dry_run = [:dry_run] raise ArgumentError, 'please provide a suffix to keep' unless /[A-Z]/ =~ suffix_to_keep ftp.login(@user, @password) clean_up_folder(target_dir, suffix_to_keep, dry_run) end |
#clean_up_with_manifest(target_dir, manifest, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/libelule.rb', line 49 def clean_up_with_manifest(target_dir, manifest, = {}) ftp.login(@user, @password) dry_run = [:dry_run] clean_up_folder_with_manifest(target_dir, manifest, dry_run) end |
#ftp ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/libelule.rb', line 20 def ftp if @ftp.nil? || @ftp.closed? @ftp = ftp_client.send(:new, @host) @ftp.passive = true end @ftp end |
#one_way_sync_from_local_to_remote(local_dir, remote_dir) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/libelule.rb', line 28 def one_way_sync_from_local_to_remote(local_dir, remote_dir) begin ftp.login(@user, @password) log "logged in, start syncing..." sync_folder(local_dir, remote_dir) log "sync finished" return true rescue Net::FTPPermError => e log "Failed: #{e.}" return false end end |