Class: OKF::Bundle::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/okf/bundle/validator.rb,
lib/okf/bundle/validator/result.rb

Overview

Checks an OKF::Bundle against the OKF conformance rules (§11), which has three conditions — all hard errors:

§11 c1  every non-reserved file has a parseable YAML frontmatter block;
§11 c2  every such block has a non-empty `type`;
§11 c3  every index.md/log.md present follows the §8/§9 structure — a nested
     index.md has no frontmatter, a root index.md carries only okf_version,
     and log.md date headings are ISO `YYYY-MM-DD`.

Everything the spec marks as soft guidance is a warning and never makes a bundle non-conformant: missing recommended fields, non-list tags, an unparseable timestamp, broken cross-links (§6.1), and every v0.2 family shape (§5, §10). Pure — it reads nothing from disk; it works entirely on the in-memory bundle.

Warnings are machine-readable: each carries a check: id and a source: naming who states the rule — :spec for the SPEC's own words, :convention for a shape this gem asks for beyond them. Errors keep their exact two-key shape; consumers already read it.

Defined Under Namespace

Classes: Result

Constant Summary collapse

CONVENTION_CHECKS =

The warnings that state a gem convention rather than a SPEC rule. §5.1 gives usage_count no type and §10.2 marks only runtime REQUIRED; verified[].by is REQUIRED-within by analogy with generated.by, not by the SPEC's own words. A consumer that wants only the spec-normative warnings filters on source: instead of string-matching messages.

%i[
  verified_entry_by source_usage_count source_usage_window_shape
  parameter_name executor_resource attester_resource
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundle) ⇒ Validator

Returns a new instance of Validator.



39
40
41
42
# File 'lib/okf/bundle/validator.rb', line 39

def initialize(bundle)
  @bundle = bundle
  @result = Result.new
end

Class Method Details

.call(bundle) ⇒ Object



35
36
37
# File 'lib/okf/bundle/validator.rb', line 35

def self.call(bundle)
  new(bundle).call
end

Instance Method Details

#callObject



44
45
46
47
48
49
50
# File 'lib/okf/bundle/validator.rb', line 44

def call
  @existing = @bundle.paths.to_set
  @bundle.concepts.each { |concept| validate_concept(concept) }
  @bundle.reserved.each { |entry| validate_reserved(entry) }
  @bundle.unparseable.each { |entry| validate_unparseable(entry) }
  @result
end