class Inspec::Profile
def archive(opts)
generates a archive of a folder profile
def archive(opts) # check if file exists otherwise overwrite the archive dst = archive_name(opts) if dst.exist? && !opts[:overwrite] @logger.info "Archive #{dst} exists already. Use --overwrite." return false end # remove existing archive FileUtils.rm_f(dst) if dst.exist? @logger.info "Generate archive #{dst}." # filter files that should not be part of the profile # TODO ignore all .files, but add the files to debug output # Generate temporary inspec.json for archive Inspec::Utils::JsonProfileSummary.produce_json( info: info, write_path: "#{root_path}inspec.json", suppress_output: true ) # display all files that will be part of the archive @logger.debug "Add the following files to archive:" files.each { |f| @logger.debug " " + f } @logger.debug " inspec.json" if opts[:zip] # generate zip archive require "inspec/archive/zip" zag = Inspec::Archive::ZipArchiveGenerator.new zag.archive(root_path, files.push("inspec.json"), dst) else # generate tar archive require "inspec/archive/tar" tag = Inspec::Archive::TarArchiveGenerator.new tag.archive(root_path, files.push("inspec.json"), dst) end # Cleanup FileUtils.rm_f("#{root_path}inspec.json") @logger.info "Finished archive generation." true end