Class: Glossarist::ConceptValidator
- Inherits:
-
Object
- Object
- Glossarist::ConceptValidator
- Defined in:
- lib/glossarist/concept_validator.rb
Constant Summary collapse
- LANG_CODES =
Glossarist::LANG_CODES
- VALID_ENTRY_STATUSES =
%w[valid superseded withdrawn draft].freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(path) ⇒ ConceptValidator
constructor
A new instance of ConceptValidator.
- #validate_all ⇒ Object
Constructor Details
#initialize(path) ⇒ ConceptValidator
Returns a new instance of ConceptValidator.
10 11 12 13 14 |
# File 'lib/glossarist/concept_validator.rb', line 10 def initialize(path) @path = path @errors = [] @warnings = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/glossarist/concept_validator.rb', line 8 def errors @errors end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/glossarist/concept_validator.rb', line 8 def path @path end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
8 9 10 |
# File 'lib/glossarist/concept_validator.rb', line 8 def warnings @warnings end |
Instance Method Details
#validate_all ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/glossarist/concept_validator.rb', line 16 def validate_all seen_ids = {} file_idx = 0 ConceptCollector.each_concept(@path) do |concept| fname = concept_file_name(concept, file_idx) validate_concept(concept, fname, seen_ids) file_idx += 1 end if file_idx.zero? yaml_files = find_yaml_files if yaml_files.any? @errors << "YAML files found but no parseable concepts" end end ValidationResult.new(errors: @errors, warnings: @warnings) end |