12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/bbmb/util/target_dir.rb', line 12
def TargetDir.send_order(order)
content = order.to_target_format
basename = BBMB.config.tmpfile_basename
BBMB.config.order_destinations.each { |destination|
uri = URI.parse(File.join(destination, order.filename))
case uri.scheme
when "ftp"
Tempfile.open(basename) { |tmp|
tmp.puts(content)
tmp.flush
Net::FTP.open(uri.host, uri.user, uri.password) { |ftp|
ftp.put(tmp.path, uri.path)
}
}
else
path = File.expand_path(uri.path, BBMB.config.bbmb_dir)
File.open(path, 'w') { |fh|
fh.puts content
}
end
}
end
|