Module: EBPS::Postprocess::Copy

Defined in:
lib/ebps/postprocess/copy.rb

Class Method Summary collapse

Class Method Details

.postprocess(data = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ebps/postprocess/copy.rb', line 7

def self.postprocess data={}
  target = EBPS.config.target
  report = ["the generated Ebook %s was copied to the following locations" % File.basename(target)]
  data['targets'].each do |path|
    uri = ::URI.parse path
    case uri.scheme
    when 'ftp'
      Net::FTP.open uri.host do |ftp|
        ftp. uri.user, uri.password
        ftp.chdir File.dirname(uri.path)
        ftp.putbinaryfile target, File.basename(uri.path)
      end
    else
      FileUtils.cp target, path
    end
    report.push sprintf(" - %s", path)
  end
  report.join "\n"
end