Class: ComplianceEngine::EnvironmentLoader::Zip

Inherits:
ComplianceEngine::EnvironmentLoader show all
Defined in:
lib/compliance_engine/environment_loader/zip.rb

Overview

Load compliance engine data from a zip file containing a Puppet environment

Instance Attribute Summary

Attributes inherited from ComplianceEngine::EnvironmentLoader

#modulepath, #modules, #zipfile_path

Instance Method Summary collapse

Constructor Details

#initialize(input, root: '/'.dup, load_dotfiles: true, name: nil) ⇒ Zip

Initialize a ComplianceEngine::EnvironmentLoader::Zip object from a zip file path and an optional root directory.

Parameters:

  • input (String)

    filesystem path to a zip file

  • root (String) (defaults to: '/'.dup)

    a directory within the zip file to use as the root of the environment

  • load_dotfiles (Boolean) (defaults to: true)

    whether to load dotfiles; defaults to true to preserve the historical zip-loader behaviour of including all files

  • name (String, nil) (defaults to: nil)

    identifier used for modulepath and downstream cache keys; defaults to the full path string passed as input.



18
19
20
21
22
23
24
25
26
# File 'lib/compliance_engine/environment_loader/zip.rb', line 18

def initialize(input, root: '/'.dup, load_dotfiles: true, name: nil)
  raise ArgumentError, "input must be a String path, got #{input.class}" unless input.is_a?(String)

  zipfile = ::Zip::File.open(input)
  @modulepath = name || input.to_s
  super(root, fileclass: zipfile.file, dirclass: zipfile.dir, zipfile_path: @modulepath, load_dotfiles: load_dotfiles)
ensure
  zipfile&.close
end