Class: Uniword::Docx::PackageIntegrityChecker
- Inherits:
-
Object
- Object
- Uniword::Docx::PackageIntegrityChecker
- Defined in:
- lib/uniword/docx/package_integrity_checker.rb
Overview
Write-time OPC package integrity gate.
Pure, non-mutating checker invoked on the in-memory ZIP content hash after reconciliation and relationship injection, before ZipPackager. MECE with the mutating Reconciler: the Reconciler repairs what it can, this checker refuses output that would produce an invalid package.
Issue codes mirror the post-hoc OpcValidator semantics (lib/uniword/validation/opc_validator.rb) where they match:
- OPC-005: every ZIP entry has a content type (Default or Override)
- OPC-006: every relationship target resolves to a package entry
- OPC-008: every emitted XML part is well-formed Codes introduced by the write-time gate:
- OPC-009: every r:id/r:embed/r:link reference in any XML part resolves to a Relationship in that part's .rels
- OPC-010: relationship IDs are unique within every .rels part
Constant Summary collapse
- RELS_NS =
Package relationships part namespace (OPC).
"http://schemas.openxmlformats.org/package/2006/relationships"- OFFICE_RELS_NS =
Office document relationship attribute namespace (r:id, r:embed...).
"http://schemas.openxmlformats.org/officeDocument/2006/relationships"- CT_NS =
[Content_Types].xml namespace.
"http://schemas.openxmlformats.org/package/2006/content-types"- R_REF_ATTRIBUTES =
Relationship attribute local names that reference rIds.
%w[id embed link].freeze
Instance Method Summary collapse
-
#check(content) ⇒ Array<Validation::Report::ValidationIssue>
Check an in-memory package content hash against every invariant.
Instance Method Details
#check(content) ⇒ Array<Validation::Report::ValidationIssue>
Check an in-memory package content hash against every invariant.
One issue-collector pass; never mutates the content hash.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/uniword/docx/package_integrity_checker.rb', line 49 def check(content) @content = content @issues = [] @parsed_parts = {} parse_all_parts # OPC-008, memoizes documents for later checks check_content_type_coverage # OPC-005 check_relationship_targets # OPC-006 check_relationship_references # OPC-009 check_rid_uniqueness # OPC-010 @issues end |