[RW] |
verbose |
Log uploads to standard output when true.
|
Create an uploader and pass it to the given block as up. When the
block is complete, close the
uploader.
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
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.
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
125: def close
126: @ftp.close
127: end
Create the directory path in the uploader root path.
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 all files matching wildcard to the uploader‘s root
path.
118: def upload_files(wildcard)
119: Dir[wildcard].each do |fn|
120: upload(fn)
121: end
122: end