Module: ComplianceEngine
- Defined in:
- lib/compliance_engine.rb,
lib/compliance_engine/version.rb,
lib/compliance_engine/tolerance.rb,
lib/compliance_engine/puppet_logger.rb
Overview
Work with compliance data
Defined Under Namespace
Modules: Tolerance Classes: CLI, Ce, Ces, Check, Checks, Collection, Component, Control, Controls, Data, DataLoader, DataVersion, EnvironmentLoader, Error, ModuleLoader, Profile, Profiles, PuppetLogger
Constant Summary collapse
- VERSION =
'0.5.0'
Class Method Summary collapse
-
.install_puppet_logger ⇒ void
Install a PuppetLogger unless a logger has already been explicitly configured.
-
.log ⇒ Logger, ComplianceEngine::PuppetLogger
Get the logger.
-
.log=(value) ⇒ Object
Set the logger.
-
.new(*paths) ⇒ ComplianceEngine::Data
Open compliance data.
-
.open(*paths) ⇒ ComplianceEngine::Data
Open compliance data.
-
.schema ⇒ Hash
Return the parsed JSON schema for SCE data files.
-
.schema_path ⇒ String
Return the path to the bundled JSON schema for SCE data files.
Class Method Details
.install_puppet_logger ⇒ void
This method returns an undefined value.
Install a PuppetLogger unless a logger has already been explicitly configured. Extracted so the behaviour can be unit-tested without reloading enforcement.rb.
88 89 90 91 92 93 |
# File 'lib/compliance_engine.rb', line 88 def self.install_puppet_logger return unless @log.nil? require_relative 'compliance_engine/puppet_logger' @log = PuppetLogger.new end |
.log ⇒ Logger, ComplianceEngine::PuppetLogger
Get the logger
31 32 33 34 35 36 37 |
# File 'lib/compliance_engine.rb', line 31 def self.log return @log unless @log.nil? @log = Logger.new($stderr) @log.level = Logger::WARN @log end |
.log=(value) ⇒ Object
Set the logger
42 43 44 |
# File 'lib/compliance_engine.rb', line 42 def self.log=(value) @log = value end |
.new(*paths) ⇒ ComplianceEngine::Data
Open compliance data
24 25 26 |
# File 'lib/compliance_engine.rb', line 24 def self.new(*paths) Data.new(*paths) end |
.open(*paths) ⇒ ComplianceEngine::Data
Open compliance data
16 17 18 |
# File 'lib/compliance_engine.rb', line 16 def self.open(*paths) Data.new(*paths) end |
.schema ⇒ Hash
Return the parsed JSON schema for SCE data files
56 57 58 59 60 61 62 63 64 |
# File 'lib/compliance_engine.rb', line 56 def self.schema require 'json' @schema ||= begin path = schema_path deep_freeze(JSON.parse(File.read(path, encoding: 'UTF-8'))) rescue Errno::ENOENT, JSON::ParserError => e raise Error, "Failed to load schema from #{path}: #{e.class}: #{e.}" end end |
.schema_path ⇒ String
Return the path to the bundled JSON schema for SCE data files
49 50 51 |
# File 'lib/compliance_engine.rb', line 49 def self.schema_path File.(File.join(__dir__, 'compliance_engine', 'sce-schema.json')) end |