Parent

Rake::FtpUploader

                                                                  

Manage the uploading of files to an FTP account.

Attributes

verbose[RW]

Log uploads to standard output when true.

Public Class Methods

connect(path, host, account, password) click to toggle source

Create an uploader and pass it to the given block as up. When the block is complete, close the uploader.

     # File lib/rake/contrib/ftptools.rb, line 95
 95:       def connect(path, host, account, password)
 96:         up = self.new(path, host, account, password)
 97:         begin
 98:           yield(up)
 99:         ensure
100:           up.close
101:         end
102:       end
new(path, host, account, password) click to toggle source

Create an FTP uploader targetting the directory path on host using the given account and password. path will be the root path of the uploader.

     # File lib/rake/contrib/ftptools.rb, line 108
108:     def initialize(path, host, account, password)
109:       @created = Hash.new
110:       @path = path
111:       @ftp = Net::FTP.new(host, account, password)
112:       makedirs(@path)
113:       @ftp.chdir(@path)
114:     end

Public Instance Methods

close() click to toggle source

Close the uploader.

     # File lib/rake/contrib/ftptools.rb, line 139
139:     def close
140:       @ftp.close
141:     end
makedirs(path) click to toggle source

Create the directory path in the uploader root path.

     # File lib/rake/contrib/ftptools.rb, line 117
117:     def makedirs(path)
118:       route = []
119:       File.split(path).each do |dir|
120:         route << dir
121:         current_dir = File.join(route)
122:         if @created[current_dir].nil?
123:           @created[current_dir] = true
124:           puts "Creating Directory  #{current_dir}" if @verbose
125:           @ftp.mkdir(current_dir) rescue nil
126:         end
127:       end
128:     end
upload_files(wildcard) click to toggle source

Upload all files matching wildcard to the uploader’s root path.

     # File lib/rake/contrib/ftptools.rb, line 132
132:     def upload_files(wildcard)
133:       Dir[wildcard].each do |fn|
134:         upload(fn)
135:       end
136:     end

Private Instance Methods

upload(file) click to toggle source

Upload a single file to the uploader’s root path.

     # File lib/rake/contrib/ftptools.rb, line 146
146:     def upload(file)
147:       puts "Uploading #{file}" if @verbose
148:       dir = File.dirname(file)
149:       makedirs(dir)
150:       @ftp.putbinaryfile(file, file) unless File.directory?(file)
151:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.