ftp_deploy.rb
# Recursively upload a folder to a server via FTP.
Recursively upload a folder to a server via FTP.
Recursively upload a folder to a server via FTP .
def upload_folder_ftp(ftp, folder, ftp_dir, skip=[])
    Dir.entries(folder).each do |file|
        if file == "." or file == ".."
            next
        end
        file_path = File.join(folder, file)
        ftp_path = File.join(ftp_dir, file)
        if File.directory?(file_path)
            puts "Creating server directory: ".magenta + "#{ftp_path}"
            ftp.mkdir(ftp_path)
            upload_folder_ftp(ftp, file_path, ftp_path, skip)
        else
            puts "Uploading: ".magenta +  " #{file_path}" + " to ".magenta + "#{ftp_path}"
            ftp.putbinaryfile(file_path, ftp_path)
        end
    end
end
def upload_folder_ftp ( ftp , folder , ftp_dir , skip = [ ] ) Dir . entries ( folder ) . each do | file | if file == "." or file == ".." next end file_path = File . join ( folder , file ) ftp_path = File . join ( ftp_dir , file ) if File . directory? ( file_path ) puts "Creating server directory: " . magenta + "#{ftp_path}" ftp . mkdir ( ftp_path ) upload_folder_ftp ( ftp , file_path , ftp_path , skip ) else puts "Uploading: " . magenta + " #{file_path}" + " to " . magenta + "#{ftp_path}" ftp . putbinaryfile ( file_path , ftp_path ) end end end
Recursively upload a folder to a server via FTP.
Recursively upload a folder to a server via FTP .
# Iterate through the directories contents - recursively handling # directories - and upload to the server. # Skip . and .. # Create the full path
ftp
folder
ftp_dir
skip