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, load_dotfiles: false) ⇒ EnvironmentLoader
constructor
Initialize an EnvironmentLoader from the components of a Puppet ‘modulepath`.
Constructor Details
#initialize(*paths, fileclass: File, dirclass: Dir, zipfile_path: nil, load_dotfiles: false) ⇒ EnvironmentLoader
Initialize an EnvironmentLoader from the components of a Puppet ‘modulepath`
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/compliance_engine/environment_loader.rb', line 16 def initialize(*paths, fileclass: File, dirclass: Dir, zipfile_path: nil, load_dotfiles: false) 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 StandardError [] end modules.flatten! @modules = modules.map { |path| ComplianceEngine::ModuleLoader.new(path, fileclass: fileclass, dirclass: dirclass, zipfile_path: @zipfile_path, load_dotfiles: load_dotfiles) } end |
Instance Attribute Details
#modulepath ⇒ Object (readonly)
Returns the value of attribute modulepath.
34 35 36 |
# File 'lib/compliance_engine/environment_loader.rb', line 34 def modulepath @modulepath end |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
34 35 36 |
# File 'lib/compliance_engine/environment_loader.rb', line 34 def modules @modules end |
#zipfile_path ⇒ Object (readonly)
Returns the value of attribute zipfile_path.
34 35 36 |
# File 'lib/compliance_engine/environment_loader.rb', line 34 def zipfile_path @zipfile_path end |