Class: HammerCLIForemanOpenscap::DownloadCommand
- Inherits:
-
HammerCLIForeman::SingleResourceCommand
- Object
- HammerCLIForeman::SingleResourceCommand
- HammerCLIForemanOpenscap::DownloadCommand
show all
- Includes:
- ResolverCommons
- Defined in:
- lib/hammer_cli_foreman_openscap/commands.rb
Class Method Summary
collapse
Instance Method Summary
collapse
included
Class Method Details
.command_name(name = nil) ⇒ Object
65
66
67
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 65
def self.command_name(name = nil)
super(name) || "download"
end
|
Instance Method Details
#print_data(response) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# 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
filename = response.[: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 ⇒ Object
69
70
71
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 69
def request_options
{ :response => :raw }
end
|
#success_message ⇒ Object
78
79
80
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 78
def success_message
super + @filepath
end
|
#validate_options ⇒ Object
73
74
75
76
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 73
def validate_options
super
validator.option(:option_path).required
end
|