241: def template_upload(*paths)
242: remote_path = paths.pop
243: templates = []
244: paths.collect! do |path|
245: if StringIO === path
246: path.rewind
247: template = Rye::Tpl.new(path.read, "inline-template")
248: elsif String === path
249: raise "No such file: #{Dir.pwd}/#{path}" unless File.exists?(path)
250: template = Rye::Tpl.new(File.read(path), File.basename(path))
251: end
252: template.result!(binding)
253: templates << template
254: template.path
255: end
256: paths << remote_path
257: ret = self.file_upload *paths
258: templates.each { |template|
259: tmp_path = File.join(remote_path, File.basename(template.path))
260: if file_exists?(tmp_path)
261: mv tmp_path, File.join(remote_path, template.basename)
262: end
263: template.delete
264: }
265: ret
266: end