Class: Busser::Command::Deserialize

Inherits:
Thor::BaseGroup show all
Defined in:
lib/busser/command/deserialize.rb

Overview

Deserialize command.

Author:

Instance Method Summary collapse

Methods included from UI

banner, die, fatal, handle_command, info, run!, run_ruby_script!, status, warn

Methods included from Helpers

chef_apply, install_gem, root_path, suite_path, vendor_path

Instance Method Details

#performObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/busser/command/deserialize.rb', line 40

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