class Proxy::OpenSCAP::FetchScapFile
Public Class Methods
new(type)
click to toggle source
# File lib/smart_proxy_openscap/fetch_scap_file.rb, line 5 def initialize(type) raise "Expected one of the following symbols: #{allowed_types.join(', ')}, got: #{type}" unless allowed_types.include? type @type = type end
Public Instance Methods
allowed_types()
click to toggle source
# File lib/smart_proxy_openscap/fetch_scap_file.rb, line 37 def allowed_types [:scap_content, :tailoring_file] end
download_path()
click to toggle source
# File lib/smart_proxy_openscap/fetch_scap_file.rb, line 21 def download_path case @type when :scap_content "api/v2/compliance/policies/:policy_id/content" when :tailoring_file "api/v2/compliance/policies/:policy_id/tailoring" end end
fetch(policy_id, digest, content_dir)
click to toggle source
# File lib/smart_proxy_openscap/fetch_scap_file.rb, line 10 def fetch(policy_id, digest, content_dir) store_dir = File.join(Proxy::OpenSCAP.fullpath(content_dir), policy_id.to_s) scap_file = File.join(store_dir, file_name(policy_id, digest)) file_download_path = download_path.sub(':policy_id', policy_id) create_store_dir store_dir file = policy_content_file scap_file clean_store_folder store_dir unless file file ||= save_or_serve_scap_file scap_file, file_download_path end
file_name(policy_id, digest)
click to toggle source
# File lib/smart_proxy_openscap/fetch_scap_file.rb, line 30 def file_name(policy_id, digest) case @type when :scap_content, :tailoring_file "#{policy_id}_#{digest}.xml" end end