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.
Instance Method Summary collapse
-
#initialize(*paths, fileclass: File, dirclass: Dir) ⇒ EnvironmentLoader
constructor
Initialize an EnvironmentLoader from the components of a Puppet ‘modulepath`.
Constructor Details
#initialize(*paths, fileclass: File, dirclass: Dir) ⇒ EnvironmentLoader
Initialize an EnvironmentLoader from the components of a Puppet ‘modulepath`
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/compliance_engine/environment_loader.rb', line 13 def initialize(*paths, fileclass: File, dirclass: Dir) raise ArgumentError, 'No paths specified' if paths.empty? @modulepath ||= paths 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) } rescue [] end modules.flatten! @modules = modules.map { |path| ComplianceEngine::ModuleLoader.new(path, fileclass: fileclass, dirclass: dirclass) } end |
Instance Attribute Details
#modulepath ⇒ Object (readonly)
Returns the value of attribute modulepath.
28 29 30 |
# File 'lib/compliance_engine/environment_loader.rb', line 28 def modulepath @modulepath end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
28 29 30 |
# File 'lib/compliance_engine/environment_loader.rb', line 28 def modules @modules end |