Class: Rake::FtpUploader

Class | Rake::FtpUploader
In: | lib/rake/contrib/ftptools.rb
Parent: | Object

Manage the uploading of files to an FTP account.

### Methods

close connect makedirs new upload_files

### Attributes

verbose | [RW] | Log uploads to standard output when true.

### Public Class methods

connect(path, host, account, password) {|up| ...}

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

[Source]

         # 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)

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.

[Source]

         # 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()

Close the uploader.

[Source]

         # File lib/rake/contrib/ftptools.rb, line 139
    139:     def close
    140:       @ftp.close
    141:     end

makedirs(path)

Create the directory `path` in the uploader root path.

[Source]

         # 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)

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

[Source]

         # 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

[Validate]