Class: BackupClient::Components::Ftp::Commands::FolderUpload
- Inherits:
-
Object
- Object
- BackupClient::Components::Ftp::Commands::FolderUpload
- Includes:
- Helpers::FtpHelper, Helpers::LogHelper
- Defined in:
- lib/backup_client/components/ftp/commands/folder_upload.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ftp_client, local_path, destination_folder) ⇒ FolderUpload
constructor
A new instance of FolderUpload.
Methods included from Helpers::FtpHelper
#ftp_chdir, #ftp_dir_exists?, #ftp_mkdir, #ftp_mkdir_p, #root_chdir, #to_unix_path, #upload_dir_ftp, #upload_file_ftp
Methods included from Helpers::LogHelper
Constructor Details
#initialize(ftp_client, local_path, destination_folder) ⇒ FolderUpload
Returns a new instance of FolderUpload.
11 12 13 14 15 |
# File 'lib/backup_client/components/ftp/commands/folder_upload.rb', line 11 def initialize(ftp_client, local_path, destination_folder) @ftp_client = ftp_client @local_path = local_path @destination_folder = destination_folder end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/backup_client/components/ftp/commands/folder_upload.rb', line 17 def call current_destination_folder = destination_folder + to_unix_path(local_path) ftp_mkdir_p(current_destination_folder) Dir.glob("#{local_path.gsub('\\', '/')}/**/*", File::FNM_DOTMATCH).each do |path| basename = File.basename(path) next if %w[. .. .git].include?(basename) if File.directory?(path) ::BackupClient::Components::Ftp::Commands::CreateFolder.new(ftp_client, destination_folder + path).call else upload_file_ftp(path, destination_folder) end end end |