Class: Uniword::Validation::VerifyOrchestrator
- Inherits:
-
Object
- Object
- Uniword::Validation::VerifyOrchestrator
- Defined in:
- lib/uniword/validation/verify_orchestrator.rb
Overview
Orchestrates the three-layer DOCX verification process.
Coordinates:
-
OPC Package validation (ZIP, content types, relationships)
-
XSD Schema validation (namespace-aware, using Moxml + Nokogiri)
-
Word Document semantic validation (extensible rule system)
Returns a VerificationReport that can be serialized to JSON/YAML or formatted for terminal output.
Instance Attribute Summary collapse
-
#xsd_validation ⇒ Object
readonly
Returns the value of attribute xsd_validation.
Instance Method Summary collapse
-
#initialize(xsd_validation: false) ⇒ VerifyOrchestrator
constructor
Initialize the orchestrator.
-
#verify(path) ⇒ Report::VerificationReport
Verify a DOCX file.
Constructor Details
#initialize(xsd_validation: false) ⇒ VerifyOrchestrator
Initialize the orchestrator.
35 36 37 |
# File 'lib/uniword/validation/verify_orchestrator.rb', line 35 def initialize(xsd_validation: false) @xsd_validation = xsd_validation end |
Instance Attribute Details
#xsd_validation ⇒ Object (readonly)
Returns the value of attribute xsd_validation.
30 31 32 |
# File 'lib/uniword/validation/verify_orchestrator.rb', line 30 def xsd_validation @xsd_validation end |
Instance Method Details
#verify(path) ⇒ Report::VerificationReport
Verify a DOCX file.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/uniword/validation/verify_orchestrator.rb', line 43 def verify(path) start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) layers = [] # Layer 1: OPC Package opc_layer = run_opc_layer(path) layers << opc_layer # Only skip downstream layers for critical OPC failures: # ZIP can't be opened (OPC-001) or word/document.xml missing (OPC-004) critical_failure = opc_layer.issues.any? do |i| %w[OPC-001 OPC-004].include?(i.code) end if critical_failure layers << Report::LayerResult.new( name: "XSD Schema", status: "skipped", duration_ms: 0, issues: [], ) layers << Report::LayerResult.new( name: "Word Document", status: "skipped", duration_ms: 0, issues: [], ) else layers << run_xsd_layer(path) layers << run_semantic_layer(path) end end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) total_ms = ((end_time - start_time) * 1000).round Report::VerificationReport.new( file_path: path, valid: layers.all?(&:pass?), duration_ms: total_ms, layers: layers, ) end |