class Crowbar::Client::Command::Batch::Export
Implementation for the batch export command
Public Instance Methods
execute()
click to toggle source
# File lib/crowbar/client/command/batch/export.rb, line 39 def execute request.process do |request| case request.code when 200 if write(request.parsed_response) say "Successfully exported batch" else err "Failed to export batch" end else err request.parsed_response["error"] end end end
request()
click to toggle source
# File lib/crowbar/client/command/batch/export.rb, line 28 def request args.easy_merge!( includes: options.includes, excludes: options.excludes ) @request ||= Request::Batch::Export.new( args ) end
Protected Instance Methods
path(name = nil)
click to toggle source
# File lib/crowbar/client/command/batch/export.rb, line 71 def path(name = nil) @path ||= case args.file when "-" stdout.to_io when File args.file else File.new( args.file || name, File::CREAT | File::TRUNC | File::RDWR ) end end
write(body)
click to toggle source
# File lib/crowbar/client/command/batch/export.rb, line 56 def write(body) path(body["name"]).tap do |path| path.binmode path.write( Base64.decode64( body["file"] ) ) true end rescue false end