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 65 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 85 def print_data(response) if response.body.empty? print_message "Response success but empty body was returned - file was not saved" return end # 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) @filepath = path + filename File.write(@filepath, response.body) print_success_message(response) end
request_options()
click to toggle source
# File lib/hammer_cli_foreman_openscap/commands.rb, line 69 def request_options { :response => :raw } end
success_message()
click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman_openscap/commands.rb, line 78 def success_message super + @filepath end
validate_options()
click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman_openscap/commands.rb, line 73 def validate_options super validator.option(:option_path).required end