class HammerCLIForemanOpenscap::DownloadCommand
Public Class Methods
command_name(name = nil)
click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman_openscap/commands.rb, line 36 def self.command_name(name = nil) super(name) || "download" end
Public Instance Methods
print_data(response)
click to toggle source
# File lib/hammer_cli_foreman_openscap/commands.rb, line 44 def print_data(response) # get file name from header, remove leading and trailing quotes filename = response.headers[:content_disposition].match(/filename=(.*)/)[1].chop.reverse.chop.reverse path = option_path.dup || '.' path << '/' unless path.end_with? '/' raise HammerCLIForemanOpenscap::DownloadError.new "Cannot save file: #{path} does not exist" unless File.directory?(path) File.write(path + filename, response.body) end
request_options()
click to toggle source
# File lib/hammer_cli_foreman_openscap/commands.rb, line 40 def request_options { :response => :raw } end