class Puppet::Pops::Validation::Factory

This class is an abstract base implementation of a _model validation factory_ that creates a validator instance and associates it with a fully configured DiagnosticProducer.

A validator is responsible for validating a model. There may be different versions of validation available for one and the same model; e.g. different semantics for different puppet versions, or different types of validation configuration depending on the context/type of validation that should be performed (static, vs. runtime, etc.).

This class is abstract and must be subclassed. The subclass must implement the methods {label_provider} and {checker}. It is also expected that the sublcass will override the #severity_producer and configure the issues that should be reported as errors (i.e. if they should be ignored, produce a warning, or a deprecation warning).

@abstract Subclass must implement {checker}, and {label_provider} @api public

Public Instance Methods

checker(diagnostic_producer) click to toggle source

Produces the checker to use.

@abstract

@api public

# File lib/puppet/pops/validation.rb, line 68
def checker(diagnostic_producer)
  raise NoMethodError, "checker"
end
diagnostic_producer(acceptor) click to toggle source

Produces the diagnostics producer to use given an acceptor of issues.

@param acceptor [Acceptor] the acceptor is the receiver of all detected issues @return [DiagnosticProducer] a detector of issues

@api public

# File lib/puppet/pops/validation.rb, line 47
def diagnostic_producer(acceptor)
  Puppet::Pops::Validation::DiagnosticProducer.new(acceptor, severity_producer(), label_provider())
end
label_provider() click to toggle source

Produces the label provider to use.

@abstract

@api public

# File lib/puppet/pops/validation.rb, line 78
def label_provider
  raise NoMethodError, "label_provider"
end
severity_producer() click to toggle source

Produces the SeverityProducer to use Subclasses should implement and add specific overrides

@return [SeverityProducer] a severity producer producing error, warning or ignore per issue

@api public

# File lib/puppet/pops/validation.rb, line 58
def severity_producer
  Puppet::Pops::Validation::SeverityProducer.new
end
validator(acceptor) click to toggle source

Produces a validator with the given acceptor as the recipient of produced diagnostics. The acceptor is where detected issues are received (and typically collected).

@param acceptor [Acceptor] the acceptor is the receiver of all detected issues @return [validate] a validator responding to `validate(model)`

@api public

# File lib/puppet/pops/validation.rb, line 36
def validator(acceptor)
  checker(diagnostic_producer(acceptor))
end