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 81
    81:       def connect(path, host, account, password)
    82:         up = self.new(path, host, account, password)
    83:         begin
    84:           yield(up)
    85:         ensure
    86:           up.close
    87:         end
    88:       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 94
     94:     def initialize(path, host, account, password)
     95:       @created = Hash.new
     96:       @path = path
     97:       @ftp = Net::FTP.new(host, account, password)
     98:       makedirs(@path)
     99:       @ftp.chdir(@path)
    100:     end

### Public Instance methods

close()

Close the uploader.

[Source]

         # File lib/rake/contrib/ftptools.rb, line 125
    125:     def close
    126:       @ftp.close
    127:     end

makedirs(path)

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

[Source]

         # File lib/rake/contrib/ftptools.rb, line 103
    103:     def makedirs(path)
    104:       route = []
    105:       File.split(path).each do |dir|
    106:         route << dir
    107:         current_dir = File.join(route)
    108:         if @created[current_dir].nil?
    109:           @created[current_dir] = true
    110:           puts "Creating Directory  #{current_dir}" if @verbose
    111:           @ftp.mkdir(current_dir) rescue nil
    112:         end
    113:       end
    114:     end

upload_files(wildcard)

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

[Source]

         # File lib/rake/contrib/ftptools.rb, line 118
    118:     def upload_files(wildcard)
    119:       Dir[wildcard].each do |fn|
    120:         upload(fn)
    121:       end
    122:     end

[Validate]