Class: Uniword::Docx::PartLoader::RawPartLoader
- Inherits:
-
Object
- Object
- Uniword::Docx::PartLoader::RawPartLoader
- Defined in:
- lib/uniword/docx/part_loader/raw_part_loader.rb
Overview
Fallback loader: preserves ZIP entries no registry definition claims as raw parts (RawPart) on the package, so unmodelled parts (docProps/meta.xml, glossary documents, VBA projects, unmodelled .rels sidecars, ...) round-trip byte-for-byte with their content types and relationships intact.
Runs last (load_priority 130 on the :raw_parts definition), so the registry claims every path it models first and this loader carries only the remainder — no double emission. A path is claimed when any PartDefinition matches it (loadable or not), when it is the resolved main document part (or its rels sidecar) at a non-standard location, or when it is a customXml item rels sidecar consumed by CustomXmlLoader.
Bytes are re-read from the original ZIP when available (the extracted hash may carry corrupted UTF-8 binary); content types come from the loaded [Content_Types].xml model.
Constant Summary collapse
- CUSTOM_XML_ITEM_RELS =
customXml item rels sidecars are consumed by CustomXmlLoader together with their item part (captured group: item index).
%r{\AcustomXml/_rels/item(\d+)\.xml\.rels\z}
Instance Method Summary collapse
Instance Method Details
#load(context, _definition) ⇒ void
This method returns an undefined value.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/uniword/docx/part_loader/raw_part_loader.rb', line 34 def load(context, _definition) paths = unclaimed_paths(context) return if paths.empty? bytes = raw_bytes(context, paths) paths.each do |path| next unless bytes[path] context.package.raw_parts[path] = build_part( context.package, path, bytes[path] ) end end |