class Busser::Command::Deserialize

Deserialize command.

@author Fletcher Nichol <fnichol@nichol.ca>

Public Instance Methods

perform() click to toggle source
# File lib/busser/command/deserialize.rb, line 39
def perform
  file = File.expand_path(options[:destination])
  contents = Base64.decode64(STDIN.read)

  FileUtils.mkdir_p(File.dirname(file))
  File.open(file, "wb") { |f| f.write(contents) }
  FileUtils.chmod(Integer(options[:perms]), file)

  if Digest::MD5.hexdigest(contents) != options[:md5sum]
    abort "Streamed file #{file} does not match source file md5"
  end
end