Class: Uniword::Docx::Reconciler
- Inherits:
-
Object
- Object
- Uniword::Docx::Reconciler
- Defined in:
- lib/uniword/docx/reconciler.rb
Overview
Reconciles DOCX-level invariants before serialization.
Ensures that the document’s model state is internally consistent so that the serialized output is always a valid DOCX file. Called from Docx::Package#to_zip_content before the serialization phase.
This is not an extension point – it enforces built-in invariants. For customizable validation, use Uniword::Validation::Rules instead. For user-defined requirements, use Docx::Requirement (future).
Constant Summary collapse
- CONFIG_DIR =
File.join(__dir__, "../../../config")
- IGNORABLE_PREFIXES =
All w1x/w16x extension namespace prefixes declared by namespace_scope on wordprocessingml parts. These MUST be listed in mc:Ignorable so Word doesn’t reject them as unknown extensions.
%w[ w14 w15 w16se w16cid w16 w16cex w16sdtdh w16sdtfl w16du ].freeze
- IGNORABLE_PREFIXES_DOCUMENT =
Extension prefixes used in document.xml (adds wp14 for drawing)
(IGNORABLE_PREFIXES + %w[wp14]).freeze
Instance Attribute Summary collapse
-
#applied_fixes ⇒ Object
readonly
Audit trail of fixes applied during reconciliation.
Instance Method Summary collapse
-
#initialize(package, profile: nil) ⇒ Reconciler
constructor
A new instance of Reconciler.
- #reconcile ⇒ Object
Constructor Details
#initialize(package, profile: nil) ⇒ Reconciler
Returns a new instance of Reconciler.
30 31 32 33 34 |
# File 'lib/uniword/docx/reconciler.rb', line 30 def initialize(package, profile: nil) @package = package @profile = profile @applied_fixes = [] end |
Instance Attribute Details
#applied_fixes ⇒ Object (readonly)
Audit trail of fixes applied during reconciliation. Each entry is { validity_rule:, message:, timestamp: }.
68 69 70 |
# File 'lib/uniword/docx/reconciler.rb', line 68 def applied_fixes @applied_fixes end |
Instance Method Details
#reconcile ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/uniword/docx/reconciler.rb', line 36 def reconcile # Group 1: Document body (always) reconcile_section_properties reconcile_footnotes reconcile_endnotes reconcile_note_references repair_theme # Group 2: Support parts (profile-dependent) if @profile reconcile_theme reconcile_settings reconcile_font_table reconcile_styles reconcile_numbering reconcile_web_settings reconcile_app_properties reconcile_core_properties reconcile_document_body end # Clear stored namespace plans so declare: :always scopes take effect clear_stored_namespace_plans # Group 3: Package consistency (always) reconcile_content_types reconcile_package_rels reconcile_document_rels end |