Manage the uploading of files to an FTP account.
Create an uploader and pass it to the given block as up
. When
the block is complete, close the uploader.
# File rake/contrib/ftptools.rb, line 81 def connect(path, host, account, password) up = self.new(path, host, account, password) begin yield(up) ensure up.close end end
Create an FTP uploader targeting the directory path
on
host
using the given account and password. path
will be the root path of the uploader.
# File rake/contrib/ftptools.rb, line 94 def initialize(path, host, account, password) @created = Hash.new @path = path @ftp = Net::FTP.new(host, account, password) makedirs(@path) @ftp.chdir(@path) end
Close the uploader.
# File rake/contrib/ftptools.rb, line 125 def close @ftp.close end
Create the directory path
in the uploader root path.
# File rake/contrib/ftptools.rb, line 103 def makedirs(path) route = [] File.split(path).each do |dir| route << dir current_dir = File.join(route) if @created[current_dir].nil? @created[current_dir] = true $stderr.puts "Creating Directory #{current_dir}" if @verbose @ftp.mkdir(current_dir) rescue nil end end end