Class: Glossarist::GcrValidator
- Inherits:
-
Object
- Object
- Glossarist::GcrValidator
- Defined in:
- lib/glossarist/gcr_validator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(on_progress: nil, relations: nil) ⇒ GcrValidator
constructor
N-ary relations live in per-file relation store (see Glossarist::V3::RelationLoader), not inside the GCR.
- #validate(zip_path) ⇒ Object
Constructor Details
#initialize(on_progress: nil, relations: nil) ⇒ GcrValidator
N-ary relations live in per-file relation store (see
Glossarist::V3::RelationLoader), not inside the GCR. For GCR
validation, callers can pass a relations: hash keyed by
concept_id; the validator passes the per-concept list to each
concept's context. Without it, relations are not validated
here — only the concepts themselves.
13 14 15 16 |
# File 'lib/glossarist/gcr_validator.rb', line 13 def initialize(on_progress: nil, relations: nil) @on_progress = on_progress @relations = relations end |
Class Method Details
.validate(zip_path, relations: nil, **opts) ⇒ Object
18 19 20 |
# File 'lib/glossarist/gcr_validator.rb', line 18 def self.validate(zip_path, relations: nil, **opts) new(**opts, relations: relations).validate(zip_path) end |
Instance Method Details
#validate(zip_path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/glossarist/gcr_validator.rb', line 22 def validate(zip_path) result = ValidationResult.new unless File.exist?(zip_path) result.add_error("File not found: #{zip_path}") return result end begin zip_entries = Zip::File.open(zip_path) { |zf| zf.entries.to_set(&:name) } rescue StandardError => e result.add_error("Failed to read ZIP: #{e.}") return result end unless zip_entries.include?("metadata.yaml") result.add_error("Missing metadata.yaml") return result end context, all_concepts = load_gcr_context(zip_path, result) return result if all_concepts.nil? validate_concepts(context, all_concepts, result) validate_collection(context, result) result end |