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
64
65
66
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 64
def self.command_name(name = nil)
super(name) || "download"
end
|
Instance Method Details
#print_data(response) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 84
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
68
69
70
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 68
def request_options
{ :response => :raw }
end
|
#success_message ⇒ Object
77
78
79
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 77
def success_message
super + @filepath
end
|
#validate_options ⇒ Object
72
73
74
75
|
# File 'lib/hammer_cli_foreman_openscap/commands.rb', line 72
def validate_options
super
validator.option(:option_path).required
end
|