7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/ebps/preprocess/copy.rb', line 7
def self.preprocess data={}
report = ["The following files were copied"]
data['transfers'].each do |path, destination|
FileUtils.mkdir_p File.dirname(destination)
uri = ::URI.parse path
case uri.scheme
when 'ftp'
Net::FTP.open uri.host do |ftp|
ftp.login uri.user, uri.password
ftp.chdir File.dirname(uri.path)
ftp.getbinaryfile File.basename(uri.path), destination
end
else
FileUtils.cp path, destination
end
report.push sprintf(" - from %s to %s")
end
report.join "\n"
end
|