Class: Uniword::Validation::OpcValidator
- Inherits:
-
Object
- Object
- Uniword::Validation::OpcValidator
- Defined in:
- lib/uniword/validation/opc_validator.rb
Overview
OPC Package validation — validates the Open Packaging Convention structure.
Designed to be extractable into its own gem. Contains no Word-specific logic. Validates ZIP integrity, content types, relationships, and part presence per ISO/IEC 29500-2 (OPC).
Checks:
-
OPC-001: ZIP opens without error
-
OPC-002: [Content_Types].xml exists
-
OPC-003: _rels/.rels exists
-
OPC-004: word/document.xml exists
-
OPC-005: Content types cover all file extensions
-
OPC-006: Relationship targets resolve
-
OPC-007: No orphaned parts
-
OPC-008: Well-formed XML in all parts
Constant Summary collapse
- RELS_NS =
"http://schemas.openxmlformats.org/package/2006/relationships"- CT_NS =
"http://schemas.openxmlformats.org/package/2006/content-types"- REQUIRED_PARTS =
Required parts per OPC specification
%w[ [Content_Types].xml _rels/.rels ].freeze
- DOCX_REQUIRED =
Required parts for DOCX specifically
%w[ word/document.xml ].freeze
Instance Method Summary collapse
-
#validate(path) ⇒ Array<Report::ValidationIssue>
Validate an OPC package.
Instance Method Details
#validate(path) ⇒ Array<Report::ValidationIssue>
Validate an OPC package.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/uniword/validation/opc_validator.rb', line 48 def validate(path) issues = [] zip = open_zip(path, issues) return issues unless zip begin check_required_parts(zip, issues) check_content_types(zip, issues) check_relationships(zip, issues) check_xml_well_formedness(zip, issues) ensure zip.close end issues end |