Class: ComplianceEngine::EnvironmentLoader
- Inherits:
-
Object
- Object
- ComplianceEngine::EnvironmentLoader
- Defined in:
- lib/compliance_engine/environment_loader.rb
Overview
Load compliance engine data from a Puppet environment
Direct Known Subclasses
Defined Under Namespace
Classes: Zip
Instance Attribute Summary collapse
-
#modulepath ⇒ Object
readonly
Returns the value of attribute modulepath.
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#zipfile_path ⇒ Object
readonly
Returns the value of attribute zipfile_path.
Instance Method Summary collapse
-
#initialize(*paths, fileclass: File, dirclass: Dir, zipfile_path: nil) ⇒ EnvironmentLoader
constructor
Initialize an EnvironmentLoader from the components of a Puppet ‘modulepath`.
Constructor Details
#initialize(*paths, fileclass: File, dirclass: Dir, zipfile_path: nil) ⇒ EnvironmentLoader
Initialize an EnvironmentLoader from the components of a Puppet ‘modulepath`
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/compliance_engine/environment_loader.rb', line 14 def initialize(*paths, fileclass: File, dirclass: Dir, zipfile_path: nil) raise ArgumentError, 'No paths specified' if paths.empty? @modulepath ||= paths @zipfile_path = zipfile_path modules = paths.map do |path| dirclass.entries(path) .grep(%r{\A[a-z][a-z0-9_]*\Z}) .select { |child| fileclass.directory?(File.join(path, child)) } .map { |child| File.join(path, child) } .sort rescue [] end modules.flatten! @modules = modules.map { |path| ComplianceEngine::ModuleLoader.new(path, fileclass: fileclass, dirclass: dirclass, zipfile_path: @zipfile_path) } end |
Instance Attribute Details
#modulepath ⇒ Object (readonly)
Returns the value of attribute modulepath.
31 32 33 |
# File 'lib/compliance_engine/environment_loader.rb', line 31 def modulepath @modulepath end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
31 32 33 |
# File 'lib/compliance_engine/environment_loader.rb', line 31 def modules @modules end |
#zipfile_path ⇒ Object (readonly)
Returns the value of attribute zipfile_path.
31 32 33 |
# File 'lib/compliance_engine/environment_loader.rb', line 31 def zipfile_path @zipfile_path end |