uniword 1.2.5 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +313 -0
- data/CONTRIBUTING.md +1 -1
- data/config/ooxml/schemas/shared_types.yml +5 -4
- data/data/schemas/ecma/dc.xsd +118 -0
- data/data/schemas/ecma/dcmitype.xsd +50 -0
- data/data/schemas/ecma/dcterms.xsd +331 -0
- data/data/schemas/ecma/opc-coreProperties.xsd +2 -2
- data/data/schemas/ecma/xml.xsd +117 -0
- data/lib/uniword/builder/bibliography_builder.rb +1 -1
- data/lib/uniword/builder/chart_builder.rb +22 -14
- data/lib/uniword/builder/comment_anchorer.rb +221 -0
- data/lib/uniword/builder/document_builder.rb +97 -6
- data/lib/uniword/builder/image_builder.rb +11 -10
- data/lib/uniword/builder/run_utils.rb +2 -0
- data/lib/uniword/builder.rb +1 -0
- data/lib/uniword/cli/fonts_cli.rb +52 -0
- data/lib/uniword/cli/main.rb +110 -11
- data/lib/uniword/cli/page_cli.rb +85 -0
- data/lib/uniword/cli/styles_cli.rb +204 -0
- data/lib/uniword/cli/theme_cli.rb +88 -0
- data/lib/uniword/cli/toc_cli.rb +22 -2
- data/lib/uniword/comment.rb +20 -15
- data/lib/uniword/comment_range.rb +3 -3
- data/lib/uniword/comments_part.rb +51 -19
- data/lib/uniword/configuration/configuration_loader.rb +5 -3
- data/lib/uniword/configuration.rb +93 -1
- data/lib/uniword/content_types.rb +19 -39
- data/lib/uniword/document_factory.rb +12 -18
- data/lib/uniword/document_writer.rb +16 -5
- data/lib/uniword/docx/chart_part.rb +34 -0
- data/lib/uniword/docx/custom_xml_item.rb +91 -0
- data/lib/uniword/docx/header_footer_part.rb +140 -0
- data/lib/uniword/docx/header_footer_part_collection.rb +135 -0
- data/lib/uniword/docx/header_footer_view.rb +225 -0
- data/lib/uniword/docx/id_allocator.rb +130 -36
- data/lib/uniword/docx/image_part.rb +83 -0
- data/lib/uniword/docx/package.rb +141 -333
- data/lib/uniword/docx/package_defaults.rb +83 -99
- data/lib/uniword/docx/package_integrity_checker.rb +312 -0
- data/lib/uniword/docx/package_serialization.rb +144 -233
- data/lib/uniword/docx/part.rb +125 -0
- data/lib/uniword/docx/part_collection.rb +131 -0
- data/lib/uniword/docx/part_loader/chart_loader.rb +50 -0
- data/lib/uniword/docx/part_loader/custom_xml_loader.rb +53 -0
- data/lib/uniword/docx/part_loader/embedding_loader.rb +26 -0
- data/lib/uniword/docx/part_loader/header_footer_loader.rb +101 -0
- data/lib/uniword/docx/part_loader/image_loader.rb +105 -0
- data/lib/uniword/docx/part_loader/load_context.rb +85 -0
- data/lib/uniword/docx/part_loader/raw_part_loader.rb +183 -0
- data/lib/uniword/docx/part_loader/theme_media_loader.rb +39 -0
- data/lib/uniword/docx/part_loader/xml_model_loader.rb +56 -0
- data/lib/uniword/docx/part_loader.rb +92 -0
- data/lib/uniword/docx/raw_part.rb +75 -0
- data/lib/uniword/docx/reconciler/body.rb +59 -68
- data/lib/uniword/docx/reconciler/fix.rb +46 -0
- data/lib/uniword/docx/reconciler/fix_codes.rb +37 -30
- data/lib/uniword/docx/reconciler/helpers.rb +18 -31
- data/lib/uniword/docx/reconciler/notes.rb +17 -8
- data/lib/uniword/docx/reconciler/package_structure.rb +168 -221
- data/lib/uniword/docx/reconciler/parts.rb +36 -13
- data/lib/uniword/docx/reconciler/referential_integrity.rb +222 -123
- data/lib/uniword/docx/reconciler/tables.rb +78 -16
- data/lib/uniword/docx/reconciler/theme.rb +7 -4
- data/lib/uniword/docx/reconciler.rb +36 -14
- data/lib/uniword/docx.rb +13 -0
- data/lib/uniword/drawingml/blip.rb +0 -1
- data/lib/uniword/drawingml/color_scheme.rb +5 -6
- data/lib/uniword/drawingml/font_scheme.rb +4 -8
- data/lib/uniword/drawingml/theme.rb +12 -6
- data/lib/uniword/errors.rb +8 -1
- data/lib/uniword/footer.rb +4 -0
- data/lib/uniword/header.rb +4 -0
- data/lib/uniword/hyperlink.rb +1 -1
- data/lib/uniword/image.rb +6 -6
- data/lib/uniword/images/image_manager.rb +13 -13
- data/lib/uniword/lazy_loader.rb +1 -2
- data/lib/uniword/model_attribute_access.rb +20 -4
- data/lib/uniword/ooxml/dotx_package.rb +42 -2
- data/lib/uniword/ooxml/element_order.rb +94 -0
- data/lib/uniword/ooxml/part_definition.rb +329 -0
- data/lib/uniword/ooxml/part_registry.rb +504 -0
- data/lib/uniword/ooxml/relationships/image_relationship.rb +6 -3
- data/lib/uniword/ooxml/relationships/package_relationships.rb +20 -22
- data/lib/uniword/ooxml/schema/element_serializer.rb +8 -7
- data/lib/uniword/ooxml/types/hex_color_value.rb +38 -0
- data/lib/uniword/ooxml/types/ooxml_boolean.rb +27 -14
- data/lib/uniword/ooxml/types/ooxml_boolean_optional.rb +21 -16
- data/lib/uniword/ooxml/types/theme_color_value.rb +22 -0
- data/lib/uniword/ooxml/types/unsigned_decimal_number.rb +30 -0
- data/lib/uniword/ooxml/types.rb +10 -0
- data/lib/uniword/ooxml.rb +3 -0
- data/lib/uniword/properties/alignment.rb +8 -3
- data/lib/uniword/properties/border.rb +52 -6
- data/lib/uniword/properties/cell_vertical_align.rb +4 -1
- data/lib/uniword/properties/color_value.rb +8 -3
- data/lib/uniword/properties/highlight.rb +9 -5
- data/lib/uniword/properties/shading.rb +4 -3
- data/lib/uniword/properties/tab_stop.rb +6 -1
- data/lib/uniword/properties/table_justification.rb +4 -1
- data/lib/uniword/properties/underline.rb +4 -2
- data/lib/uniword/properties/vertical_align.rb +6 -3
- data/lib/uniword/review/review_manager.rb +23 -9
- data/lib/uniword/revision.rb +9 -9
- data/lib/uniword/schema/model_generator.rb +31 -15
- data/lib/uniword/shared_types/hex_color.rb +4 -1
- data/lib/uniword/shared_types/pixel_measure.rb +4 -1
- data/lib/uniword/shared_types/point_measure.rb +4 -1
- data/lib/uniword/shared_types/text_alignment.rb +6 -1
- data/lib/uniword/shared_types/twips_measure.rb +4 -1
- data/lib/uniword/spreadsheetml/phonetic_pr.rb +1 -1
- data/lib/uniword/spreadsheetml/shared_string_table.rb +2 -2
- data/lib/uniword/spreadsheetml/table_formula.rb +1 -1
- data/lib/uniword/template/variable_resolver.rb +40 -7
- data/lib/uniword/themes/theme_transformation.rb +55 -41
- data/lib/uniword/toc/toc_generator.rb +6 -5
- data/lib/uniword/transformation/mhtml_element_renderer.rb +1 -5
- data/lib/uniword/transformation/mhtml_metadata_builder.rb +6 -6
- data/lib/uniword/validation/engine.rb +35 -0
- data/lib/uniword/validation/link_checker.rb +1 -1
- data/lib/uniword/validation/opc_validator.rb +16 -2
- data/lib/uniword/validation/report/layer_result.rb +0 -1
- data/lib/uniword/validation/report/terminal_formatter.rb +0 -1
- data/lib/uniword/validation/report/verification_report.rb +0 -2
- data/lib/uniword/validation/report.rb +20 -0
- data/lib/uniword/validation/rules/base.rb +10 -2
- data/lib/uniword/validation/rules/bookmark_pairing_rule.rb +38 -0
- data/lib/uniword/validation/rules/bookmark_uniqueness_rule.rb +48 -0
- data/lib/uniword/validation/rules/bookmarks_rule.rb +0 -2
- data/lib/uniword/validation/rules/content_types_coverage_rule.rb +0 -2
- data/lib/uniword/validation/rules/core_properties_namespace_rule.rb +0 -2
- data/lib/uniword/validation/rules/document_body_rule.rb +25 -0
- data/lib/uniword/validation/rules/document_context.rb +7 -0
- data/lib/uniword/validation/rules/empty_paragraphs_rule.rb +27 -0
- data/lib/uniword/validation/rules/font_table_signature_rule.rb +0 -2
- data/lib/uniword/validation/rules/fonts_rule.rb +0 -2
- data/lib/uniword/validation/rules/footnotes_rule.rb +0 -2
- data/lib/uniword/validation/rules/headers_footers_rule.rb +0 -2
- data/lib/uniword/validation/rules/images_rule.rb +0 -2
- data/lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb +0 -2
- data/lib/uniword/validation/rules/model_context.rb +32 -0
- data/lib/uniword/validation/rules/model_rule.rb +34 -0
- data/lib/uniword/validation/rules/numbering_preservation_rule.rb +0 -2
- data/lib/uniword/validation/rules/numbering_rule.rb +0 -2
- data/lib/uniword/validation/rules/relationship_integrity_rule.rb +0 -1
- data/lib/uniword/validation/rules/rsid_rule.rb +0 -2
- data/lib/uniword/validation/rules/section_properties_rule.rb +0 -2
- data/lib/uniword/validation/rules/settings_rule.rb +0 -2
- data/lib/uniword/validation/rules/settings_values_rule.rb +0 -2
- data/lib/uniword/validation/rules/style_references_rule.rb +0 -2
- data/lib/uniword/validation/rules/table_grid_rule.rb +27 -0
- data/lib/uniword/validation/rules/table_properties_rule.rb +27 -0
- data/lib/uniword/validation/rules/tables_rule.rb +0 -2
- data/lib/uniword/validation/rules/theme_completeness_rule.rb +0 -2
- data/lib/uniword/validation/rules/theme_rule.rb +0 -2
- data/lib/uniword/validation/rules.rb +61 -23
- data/lib/uniword/validation/schema_registry.rb +11 -0
- data/lib/uniword/validation/validators/document_semantics_validator.rb +1 -9
- data/lib/uniword/validation/validators/xml_schema_validator.rb +46 -2
- data/lib/uniword/validation/validators.rb +0 -9
- data/lib/uniword/validation/verify_orchestrator.rb +0 -7
- data/lib/uniword/validation.rb +7 -2
- data/lib/uniword/version.rb +1 -1
- data/lib/uniword/vml/imagedata.rb +0 -1
- data/lib/uniword/wordprocessingml/attached_template.rb +0 -1
- data/lib/uniword/wordprocessingml/deleted_text.rb +1 -1
- data/lib/uniword/wordprocessingml/document_root.rb +121 -122
- data/lib/uniword/wordprocessingml/document_styling.rb +246 -0
- data/lib/uniword/wordprocessingml/endnotes.rb +4 -1
- data/lib/uniword/wordprocessingml/font_replacer.rb +147 -0
- data/lib/uniword/wordprocessingml/footnotes.rb +4 -1
- data/lib/uniword/wordprocessingml/hdr_shape_defaults.rb +0 -1
- data/lib/uniword/wordprocessingml/hyperlink.rb +0 -1
- data/lib/uniword/wordprocessingml/level.rb +6 -20
- data/lib/uniword/wordprocessingml/math_pr.rb +0 -11
- data/lib/uniword/wordprocessingml/numbering_definition.rb +16 -8
- data/lib/uniword/wordprocessingml/numbering_elements.rb +0 -15
- data/lib/uniword/wordprocessingml/page_setup.rb +181 -0
- data/lib/uniword/wordprocessingml/paragraph_properties.rb +33 -28
- data/lib/uniword/wordprocessingml/rsids.rb +0 -2
- data/lib/uniword/wordprocessingml/run.rb +3 -0
- data/lib/uniword/wordprocessingml/section_properties.rb +2 -2
- data/lib/uniword/wordprocessingml/settings.rb +8 -34
- data/lib/uniword/wordprocessingml/shape_defaults.rb +0 -1
- data/lib/uniword/wordprocessingml/style.rb +2 -1
- data/lib/uniword/wordprocessingml/style_cleanup.rb +198 -0
- data/lib/uniword/wordprocessingml/table_cell_properties.rb +6 -6
- data/lib/uniword/wordprocessingml/update_fields.rb +27 -0
- data/lib/uniword/wordprocessingml/w14_attributes.rb +30 -2
- data/lib/uniword/wordprocessingml.rb +5 -2
- data/lib/uniword.rb +27 -2
- metadata +52 -19
- data/config/validation_rules.yml +0 -60
- data/config/warning_rules.yml +0 -57
- data/lib/uniword/validation/document_validator.rb +0 -272
- data/lib/uniword/validation/structural_validator.rb +0 -116
- data/lib/uniword/validation/validators/content_type_validator.rb +0 -165
- data/lib/uniword/validation/validators/file_structure_validator.rb +0 -104
- data/lib/uniword/validation/validators/ooxml_part_validator.rb +0 -128
- data/lib/uniword/validation/validators/relationship_validator.rb +0 -147
- data/lib/uniword/validation/validators/zip_integrity_validator.rb +0 -110
- data/lib/uniword/validators/element_validator.rb +0 -93
- data/lib/uniword/validators/paragraph_validator.rb +0 -116
- data/lib/uniword/validators/table_validator.rb +0 -134
- data/lib/uniword/validators.rb +0 -9
- data/lib/uniword/warnings/warning.rb +0 -130
- data/lib/uniword/warnings/warning_collector.rb +0 -234
- data/lib/uniword/warnings/warning_report.rb +0 -159
- data/lib/uniword/warnings.rb +0 -9
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uniword
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|
|
@@ -182,8 +182,6 @@ files:
|
|
|
182
182
|
- config/system_profiles.yml
|
|
183
183
|
- config/theme_mapping.yml
|
|
184
184
|
- config/transformation_rules.yml
|
|
185
|
-
- config/validation_rules.yml
|
|
186
|
-
- config/warning_rules.yml
|
|
187
185
|
- data/color_schemes/amber.yml
|
|
188
186
|
- data/color_schemes/azure.yml
|
|
189
187
|
- data/color_schemes/burgundy.yml
|
|
@@ -476,10 +474,14 @@ files:
|
|
|
476
474
|
- data/resources/document_elements/zh-TW/tables.yml
|
|
477
475
|
- data/resources/document_elements/zh-TW/watermarks.yml
|
|
478
476
|
- data/resources/font_registry.yml
|
|
477
|
+
- data/schemas/ecma/dc.xsd
|
|
478
|
+
- data/schemas/ecma/dcmitype.xsd
|
|
479
|
+
- data/schemas/ecma/dcterms.xsd
|
|
479
480
|
- data/schemas/ecma/opc-contentTypes.xsd
|
|
480
481
|
- data/schemas/ecma/opc-coreProperties.xsd
|
|
481
482
|
- data/schemas/ecma/opc-digSig.xsd
|
|
482
483
|
- data/schemas/ecma/opc-relationships.xsd
|
|
484
|
+
- data/schemas/ecma/xml.xsd
|
|
483
485
|
- data/schemas/iso/dml-chart.xsd
|
|
484
486
|
- data/schemas/iso/dml-chartDrawing.xsd
|
|
485
487
|
- data/schemas/iso/dml-diagram.xsd
|
|
@@ -631,6 +633,7 @@ files:
|
|
|
631
633
|
- lib/uniword/builder/base_builder.rb
|
|
632
634
|
- lib/uniword/builder/bibliography_builder.rb
|
|
633
635
|
- lib/uniword/builder/chart_builder.rb
|
|
636
|
+
- lib/uniword/builder/comment_anchorer.rb
|
|
634
637
|
- lib/uniword/builder/comment_builder.rb
|
|
635
638
|
- lib/uniword/builder/deterministic_id.rb
|
|
636
639
|
- lib/uniword/builder/document_builder.rb
|
|
@@ -728,15 +731,18 @@ files:
|
|
|
728
731
|
- lib/uniword/chart/y_values.rb
|
|
729
732
|
- lib/uniword/cli.rb
|
|
730
733
|
- lib/uniword/cli/diff_cli.rb
|
|
734
|
+
- lib/uniword/cli/fonts_cli.rb
|
|
731
735
|
- lib/uniword/cli/generate_cli.rb
|
|
732
736
|
- lib/uniword/cli/headers_cli.rb
|
|
733
737
|
- lib/uniword/cli/helpers.rb
|
|
734
738
|
- lib/uniword/cli/images_cli.rb
|
|
735
739
|
- lib/uniword/cli/main.rb
|
|
740
|
+
- lib/uniword/cli/page_cli.rb
|
|
736
741
|
- lib/uniword/cli/protect_cli.rb
|
|
737
742
|
- lib/uniword/cli/resources_cli.rb
|
|
738
743
|
- lib/uniword/cli/review_cli.rb
|
|
739
744
|
- lib/uniword/cli/spellcheck_cli.rb
|
|
745
|
+
- lib/uniword/cli/styles_cli.rb
|
|
740
746
|
- lib/uniword/cli/styleset_cli.rb
|
|
741
747
|
- lib/uniword/cli/template_cli.rb
|
|
742
748
|
- lib/uniword/cli/theme_cli.rb
|
|
@@ -809,14 +815,35 @@ files:
|
|
|
809
815
|
- lib/uniword/document_variables/variable_scope.rb
|
|
810
816
|
- lib/uniword/document_writer.rb
|
|
811
817
|
- lib/uniword/docx.rb
|
|
818
|
+
- lib/uniword/docx/chart_part.rb
|
|
819
|
+
- lib/uniword/docx/custom_xml_item.rb
|
|
812
820
|
- lib/uniword/docx/document_statistics.rb
|
|
821
|
+
- lib/uniword/docx/header_footer_part.rb
|
|
822
|
+
- lib/uniword/docx/header_footer_part_collection.rb
|
|
823
|
+
- lib/uniword/docx/header_footer_view.rb
|
|
813
824
|
- lib/uniword/docx/id_allocator.rb
|
|
825
|
+
- lib/uniword/docx/image_part.rb
|
|
814
826
|
- lib/uniword/docx/package.rb
|
|
815
827
|
- lib/uniword/docx/package_defaults.rb
|
|
828
|
+
- lib/uniword/docx/package_integrity_checker.rb
|
|
816
829
|
- lib/uniword/docx/package_serialization.rb
|
|
830
|
+
- lib/uniword/docx/part.rb
|
|
831
|
+
- lib/uniword/docx/part_collection.rb
|
|
832
|
+
- lib/uniword/docx/part_loader.rb
|
|
833
|
+
- lib/uniword/docx/part_loader/chart_loader.rb
|
|
834
|
+
- lib/uniword/docx/part_loader/custom_xml_loader.rb
|
|
835
|
+
- lib/uniword/docx/part_loader/embedding_loader.rb
|
|
836
|
+
- lib/uniword/docx/part_loader/header_footer_loader.rb
|
|
837
|
+
- lib/uniword/docx/part_loader/image_loader.rb
|
|
838
|
+
- lib/uniword/docx/part_loader/load_context.rb
|
|
839
|
+
- lib/uniword/docx/part_loader/raw_part_loader.rb
|
|
840
|
+
- lib/uniword/docx/part_loader/theme_media_loader.rb
|
|
841
|
+
- lib/uniword/docx/part_loader/xml_model_loader.rb
|
|
817
842
|
- lib/uniword/docx/profile.rb
|
|
843
|
+
- lib/uniword/docx/raw_part.rb
|
|
818
844
|
- lib/uniword/docx/reconciler.rb
|
|
819
845
|
- lib/uniword/docx/reconciler/body.rb
|
|
846
|
+
- lib/uniword/docx/reconciler/fix.rb
|
|
820
847
|
- lib/uniword/docx/reconciler/fix_codes.rb
|
|
821
848
|
- lib/uniword/docx/reconciler/helpers.rb
|
|
822
849
|
- lib/uniword/docx/reconciler/notes.rb
|
|
@@ -1094,8 +1121,11 @@ files:
|
|
|
1094
1121
|
- lib/uniword/ooxml/core_properties.rb
|
|
1095
1122
|
- lib/uniword/ooxml/custom_properties.rb
|
|
1096
1123
|
- lib/uniword/ooxml/dotx_package.rb
|
|
1124
|
+
- lib/uniword/ooxml/element_order.rb
|
|
1097
1125
|
- lib/uniword/ooxml/namespaces.rb
|
|
1098
1126
|
- lib/uniword/ooxml/package_file.rb
|
|
1127
|
+
- lib/uniword/ooxml/part_definition.rb
|
|
1128
|
+
- lib/uniword/ooxml/part_registry.rb
|
|
1099
1129
|
- lib/uniword/ooxml/relationships.rb
|
|
1100
1130
|
- lib/uniword/ooxml/relationships/hyperlink_relationship.rb
|
|
1101
1131
|
- lib/uniword/ooxml/relationships/image_relationship.rb
|
|
@@ -1125,10 +1155,13 @@ files:
|
|
|
1125
1155
|
- lib/uniword/ooxml/types/dcterms_created_type.rb
|
|
1126
1156
|
- lib/uniword/ooxml/types/dcterms_modified_type.rb
|
|
1127
1157
|
- lib/uniword/ooxml/types/dcterms_w3cdtf_type.rb
|
|
1158
|
+
- lib/uniword/ooxml/types/hex_color_value.rb
|
|
1128
1159
|
- lib/uniword/ooxml/types/mc_ignorable_type.rb
|
|
1129
1160
|
- lib/uniword/ooxml/types/ooxml_boolean.rb
|
|
1130
1161
|
- lib/uniword/ooxml/types/ooxml_boolean_optional.rb
|
|
1131
1162
|
- lib/uniword/ooxml/types/relationship_id.rb
|
|
1163
|
+
- lib/uniword/ooxml/types/theme_color_value.rb
|
|
1164
|
+
- lib/uniword/ooxml/types/unsigned_decimal_number.rb
|
|
1132
1165
|
- lib/uniword/ooxml/types/variant_types.rb
|
|
1133
1166
|
- lib/uniword/page_borders.rb
|
|
1134
1167
|
- lib/uniword/paragraph_border.rb
|
|
@@ -1479,28 +1512,35 @@ files:
|
|
|
1479
1512
|
- lib/uniword/validation/checkers/file_reference_checker.rb
|
|
1480
1513
|
- lib/uniword/validation/checkers/footnote_reference_checker.rb
|
|
1481
1514
|
- lib/uniword/validation/checkers/internal_link_checker.rb
|
|
1482
|
-
- lib/uniword/validation/
|
|
1515
|
+
- lib/uniword/validation/engine.rb
|
|
1483
1516
|
- lib/uniword/validation/layer_validation_result.rb
|
|
1484
1517
|
- lib/uniword/validation/layer_validator.rb
|
|
1485
1518
|
- lib/uniword/validation/link_checker.rb
|
|
1486
1519
|
- lib/uniword/validation/link_validator.rb
|
|
1487
1520
|
- lib/uniword/validation/opc_validator.rb
|
|
1521
|
+
- lib/uniword/validation/report.rb
|
|
1488
1522
|
- lib/uniword/validation/report/layer_result.rb
|
|
1489
1523
|
- lib/uniword/validation/report/terminal_formatter.rb
|
|
1490
1524
|
- lib/uniword/validation/report/validation_issue.rb
|
|
1491
1525
|
- lib/uniword/validation/report/verification_report.rb
|
|
1492
1526
|
- lib/uniword/validation/rules.rb
|
|
1493
1527
|
- lib/uniword/validation/rules/base.rb
|
|
1528
|
+
- lib/uniword/validation/rules/bookmark_pairing_rule.rb
|
|
1529
|
+
- lib/uniword/validation/rules/bookmark_uniqueness_rule.rb
|
|
1494
1530
|
- lib/uniword/validation/rules/bookmarks_rule.rb
|
|
1495
1531
|
- lib/uniword/validation/rules/content_types_coverage_rule.rb
|
|
1496
1532
|
- lib/uniword/validation/rules/core_properties_namespace_rule.rb
|
|
1533
|
+
- lib/uniword/validation/rules/document_body_rule.rb
|
|
1497
1534
|
- lib/uniword/validation/rules/document_context.rb
|
|
1535
|
+
- lib/uniword/validation/rules/empty_paragraphs_rule.rb
|
|
1498
1536
|
- lib/uniword/validation/rules/font_table_signature_rule.rb
|
|
1499
1537
|
- lib/uniword/validation/rules/fonts_rule.rb
|
|
1500
1538
|
- lib/uniword/validation/rules/footnotes_rule.rb
|
|
1501
1539
|
- lib/uniword/validation/rules/headers_footers_rule.rb
|
|
1502
1540
|
- lib/uniword/validation/rules/images_rule.rb
|
|
1503
1541
|
- lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb
|
|
1542
|
+
- lib/uniword/validation/rules/model_context.rb
|
|
1543
|
+
- lib/uniword/validation/rules/model_rule.rb
|
|
1504
1544
|
- lib/uniword/validation/rules/numbering_preservation_rule.rb
|
|
1505
1545
|
- lib/uniword/validation/rules/numbering_rule.rb
|
|
1506
1546
|
- lib/uniword/validation/rules/registry.rb
|
|
@@ -1510,26 +1550,18 @@ files:
|
|
|
1510
1550
|
- lib/uniword/validation/rules/settings_rule.rb
|
|
1511
1551
|
- lib/uniword/validation/rules/settings_values_rule.rb
|
|
1512
1552
|
- lib/uniword/validation/rules/style_references_rule.rb
|
|
1553
|
+
- lib/uniword/validation/rules/table_grid_rule.rb
|
|
1554
|
+
- lib/uniword/validation/rules/table_properties_rule.rb
|
|
1513
1555
|
- lib/uniword/validation/rules/tables_rule.rb
|
|
1514
1556
|
- lib/uniword/validation/rules/theme_completeness_rule.rb
|
|
1515
1557
|
- lib/uniword/validation/rules/theme_rule.rb
|
|
1516
1558
|
- lib/uniword/validation/schema_registry.rb
|
|
1517
|
-
- lib/uniword/validation/structural_validator.rb
|
|
1518
1559
|
- lib/uniword/validation/validation_report.rb
|
|
1519
1560
|
- lib/uniword/validation/validation_result.rb
|
|
1520
1561
|
- lib/uniword/validation/validators.rb
|
|
1521
|
-
- lib/uniword/validation/validators/content_type_validator.rb
|
|
1522
1562
|
- lib/uniword/validation/validators/document_semantics_validator.rb
|
|
1523
|
-
- lib/uniword/validation/validators/file_structure_validator.rb
|
|
1524
|
-
- lib/uniword/validation/validators/ooxml_part_validator.rb
|
|
1525
|
-
- lib/uniword/validation/validators/relationship_validator.rb
|
|
1526
1563
|
- lib/uniword/validation/validators/xml_schema_validator.rb
|
|
1527
|
-
- lib/uniword/validation/validators/zip_integrity_validator.rb
|
|
1528
1564
|
- lib/uniword/validation/verify_orchestrator.rb
|
|
1529
|
-
- lib/uniword/validators.rb
|
|
1530
|
-
- lib/uniword/validators/element_validator.rb
|
|
1531
|
-
- lib/uniword/validators/paragraph_validator.rb
|
|
1532
|
-
- lib/uniword/validators/table_validator.rb
|
|
1533
1565
|
- lib/uniword/version.rb
|
|
1534
1566
|
- lib/uniword/visitor.rb
|
|
1535
1567
|
- lib/uniword/visitor/base_visitor.rb
|
|
@@ -1594,10 +1626,6 @@ files:
|
|
|
1594
1626
|
- lib/uniword/vml_word/border_left.rb
|
|
1595
1627
|
- lib/uniword/vml_word/border_right.rb
|
|
1596
1628
|
- lib/uniword/vml_word/border_top.rb
|
|
1597
|
-
- lib/uniword/warnings.rb
|
|
1598
|
-
- lib/uniword/warnings/warning.rb
|
|
1599
|
-
- lib/uniword/warnings/warning_collector.rb
|
|
1600
|
-
- lib/uniword/warnings/warning_report.rb
|
|
1601
1629
|
- lib/uniword/watermark.rb
|
|
1602
1630
|
- lib/uniword/watermark/manager.rb
|
|
1603
1631
|
- lib/uniword/word2010_ext.rb
|
|
@@ -1654,6 +1682,7 @@ files:
|
|
|
1654
1682
|
- lib/uniword/wordprocessingml/doc_vars.rb
|
|
1655
1683
|
- lib/uniword/wordprocessingml/document_root.rb
|
|
1656
1684
|
- lib/uniword/wordprocessingml/document_root/feature_facade.rb
|
|
1685
|
+
- lib/uniword/wordprocessingml/document_styling.rb
|
|
1657
1686
|
- lib/uniword/wordprocessingml/drawing.rb
|
|
1658
1687
|
- lib/uniword/wordprocessingml/emboss.rb
|
|
1659
1688
|
- lib/uniword/wordprocessingml/endnote.rb
|
|
@@ -1666,6 +1695,7 @@ files:
|
|
|
1666
1695
|
- lib/uniword/wordprocessingml/fallback.rb
|
|
1667
1696
|
- lib/uniword/wordprocessingml/field_char.rb
|
|
1668
1697
|
- lib/uniword/wordprocessingml/font.rb
|
|
1698
|
+
- lib/uniword/wordprocessingml/font_replacer.rb
|
|
1669
1699
|
- lib/uniword/wordprocessingml/font_table.rb
|
|
1670
1700
|
- lib/uniword/wordprocessingml/fonts.rb
|
|
1671
1701
|
- lib/uniword/wordprocessingml/footer.rb
|
|
@@ -1727,6 +1757,7 @@ files:
|
|
|
1727
1757
|
- lib/uniword/wordprocessingml/page_defaults.rb
|
|
1728
1758
|
- lib/uniword/wordprocessingml/page_margins.rb
|
|
1729
1759
|
- lib/uniword/wordprocessingml/page_numbering.rb
|
|
1760
|
+
- lib/uniword/wordprocessingml/page_setup.rb
|
|
1730
1761
|
- lib/uniword/wordprocessingml/page_size.rb
|
|
1731
1762
|
- lib/uniword/wordprocessingml/paragraph.rb
|
|
1732
1763
|
- lib/uniword/wordprocessingml/paragraph_borders.rb
|
|
@@ -1782,6 +1813,7 @@ files:
|
|
|
1782
1813
|
- lib/uniword/wordprocessingml/structured_document_tag/text.rb
|
|
1783
1814
|
- lib/uniword/wordprocessingml/structured_document_tag_properties.rb
|
|
1784
1815
|
- lib/uniword/wordprocessingml/style.rb
|
|
1816
|
+
- lib/uniword/wordprocessingml/style_cleanup.rb
|
|
1785
1817
|
- lib/uniword/wordprocessingml/style_name.rb
|
|
1786
1818
|
- lib/uniword/wordprocessingml/style_pane_format_filter.rb
|
|
1787
1819
|
- lib/uniword/wordprocessingml/style_pane_sort_method.rb
|
|
@@ -1816,6 +1848,7 @@ files:
|
|
|
1816
1848
|
- lib/uniword/wordprocessingml/title_pg.rb
|
|
1817
1849
|
- lib/uniword/wordprocessingml/tr_height.rb
|
|
1818
1850
|
- lib/uniword/wordprocessingml/ui_priority.rb
|
|
1851
|
+
- lib/uniword/wordprocessingml/update_fields.rb
|
|
1819
1852
|
- lib/uniword/wordprocessingml/val_int.rb
|
|
1820
1853
|
- lib/uniword/wordprocessingml/w14_attributes.rb
|
|
1821
1854
|
- lib/uniword/wordprocessingml/w14_doc_id.rb
|
data/config/validation_rules.yml
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Document Validation Configuration
|
|
2
|
-
#
|
|
3
|
-
# Defines rules and settings for the 7-layer document validation system.
|
|
4
|
-
# Each layer validates one specific aspect of document integrity (MECE).
|
|
5
|
-
|
|
6
|
-
document_validation:
|
|
7
|
-
# General settings
|
|
8
|
-
fail_fast: true # Stop validation on first critical error
|
|
9
|
-
max_file_size: 104857600 # 100MB maximum file size
|
|
10
|
-
|
|
11
|
-
# Layer 1: File Structure Validation
|
|
12
|
-
file_structure:
|
|
13
|
-
enabled: true
|
|
14
|
-
check_extension: true
|
|
15
|
-
check_size: true
|
|
16
|
-
allowed_extensions:
|
|
17
|
-
- '.docx'
|
|
18
|
-
- '.doc'
|
|
19
|
-
|
|
20
|
-
# Layer 2: ZIP Integrity Validation
|
|
21
|
-
zip_integrity:
|
|
22
|
-
enabled: true
|
|
23
|
-
check_entries: true # Verify required entries exist
|
|
24
|
-
check_corruption: true # Test each entry for corruption
|
|
25
|
-
verify_compression: true # Validate compression method
|
|
26
|
-
|
|
27
|
-
# Layer 3: OOXML Part Validation
|
|
28
|
-
ooxml_parts:
|
|
29
|
-
enabled: true
|
|
30
|
-
require_content_types: true # [Content_Types].xml must exist
|
|
31
|
-
require_document: true # word/document.xml must exist
|
|
32
|
-
require_relationships: true # _rels/.rels must exist
|
|
33
|
-
warn_missing_optional: true # Warn about missing optional parts
|
|
34
|
-
|
|
35
|
-
# Layer 4: XML Schema Validation
|
|
36
|
-
xml_schema:
|
|
37
|
-
enabled: true
|
|
38
|
-
strict_parsing: true # Use strict XML parsing
|
|
39
|
-
check_encoding: true # Validate XML encoding
|
|
40
|
-
validate_namespaces: true # Check namespace declarations
|
|
41
|
-
|
|
42
|
-
# Layer 5: Relationship Validation
|
|
43
|
-
relationships:
|
|
44
|
-
enabled: true
|
|
45
|
-
check_targets_exist: true # Verify relationship targets exist
|
|
46
|
-
check_circular_refs: false # Check for circular references (expensive)
|
|
47
|
-
validate_types: true # Validate relationship type URIs
|
|
48
|
-
|
|
49
|
-
# Layer 6: Content Type Validation
|
|
50
|
-
content_types:
|
|
51
|
-
enabled: true
|
|
52
|
-
check_consistency: true # Verify content types are consistent
|
|
53
|
-
validate_extensions: true # Check file extensions match declarations
|
|
54
|
-
|
|
55
|
-
# Layer 7: Document Semantics Validation
|
|
56
|
-
document_semantics:
|
|
57
|
-
enabled: true
|
|
58
|
-
check_required_elements: true # Verify required elements (body, etc.)
|
|
59
|
-
validate_structure: true # Check document hierarchy
|
|
60
|
-
check_style_references: true # Validate style references (future)
|
data/config/warning_rules.yml
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Warning System Configuration
|
|
2
|
-
#
|
|
3
|
-
# Defines rules for tracking unsupported elements and features during
|
|
4
|
-
# document processing. Helps users understand what may be lost in round-trip.
|
|
5
|
-
|
|
6
|
-
warning_system:
|
|
7
|
-
enabled: true
|
|
8
|
-
log_warnings: false # Set to true to log warnings during processing
|
|
9
|
-
log_level: :warn # Log level (:info, :warn, :error)
|
|
10
|
-
|
|
11
|
-
# Critical elements (data-bearing) - severity: error
|
|
12
|
-
# These elements contain important data that will be lost
|
|
13
|
-
critical_elements:
|
|
14
|
-
- chart # Charts - data visualization
|
|
15
|
-
- smartArt # SmartArt diagrams
|
|
16
|
-
- sdt # Content controls - user data
|
|
17
|
-
- customXml # Custom XML - data binding
|
|
18
|
-
- contentPart # Content parts
|
|
19
|
-
- control # ActiveX controls
|
|
20
|
-
|
|
21
|
-
# Warning elements (important but not critical) - severity: warning
|
|
22
|
-
# These elements affect formatting/structure but not core data
|
|
23
|
-
warning_elements:
|
|
24
|
-
- drawingML # Complex drawings
|
|
25
|
-
- vmlDrawing # Legacy VML drawings
|
|
26
|
-
- fldSimple # Simple fields
|
|
27
|
-
- altChunk # Alternative content chunks
|
|
28
|
-
- subDoc # Subdocuments
|
|
29
|
-
|
|
30
|
-
# Element-specific suggestions for users
|
|
31
|
-
element_suggestions:
|
|
32
|
-
chart: "Chart elements are not yet supported. The chart will be preserved as-is but cannot be edited. Consider using image exports for charts. Support planned for v6.1."
|
|
33
|
-
|
|
34
|
-
smartArt: "SmartArt diagrams are not yet supported. Diagram will be preserved but cannot be modified. Consider converting to regular shapes. Support planned for v6.2."
|
|
35
|
-
|
|
36
|
-
sdt: "Content controls are not yet supported. Controls will be preserved but values cannot be updated programmatically. Support planned for v6.1."
|
|
37
|
-
|
|
38
|
-
customXml: "Custom XML data binding is not yet supported. XML data will be preserved but cannot be accessed or modified. Support planned for v6.3."
|
|
39
|
-
|
|
40
|
-
drawingML: "Complex DrawingML graphics may not be fully supported. Basic shapes work, but advanced features may be lost."
|
|
41
|
-
|
|
42
|
-
vmlDrawing: "Legacy VML drawings have limited support. Consider updating to modern DrawingML format."
|
|
43
|
-
|
|
44
|
-
fldSimple: "Some field types are not yet supported. Field will be preserved but may not update correctly."
|
|
45
|
-
|
|
46
|
-
control: "ActiveX controls are not supported. Controls will be preserved but not functional."
|
|
47
|
-
|
|
48
|
-
altChunk: "Alternative content chunks are not supported. Content may be lost."
|
|
49
|
-
|
|
50
|
-
subDoc: "Subdocuments are not supported. Consider consolidating into single document."
|
|
51
|
-
|
|
52
|
-
# Reporting options
|
|
53
|
-
reporting:
|
|
54
|
-
group_by_element: true # Group warnings by element type
|
|
55
|
-
include_counts: true # Include occurrence counts
|
|
56
|
-
include_suggestions: true # Include suggestions in report
|
|
57
|
-
max_warnings: 100 # Maximum warnings to collect (prevent memory issues)
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "json"
|
|
4
|
-
# All Validation classes autoloaded via lib/uniword/validation.rb and validators.rb
|
|
5
|
-
# Configuration::ConfigurationLoader autoloaded via lib/uniword.rb
|
|
6
|
-
|
|
7
|
-
module Uniword
|
|
8
|
-
module Validation
|
|
9
|
-
# Main document validator orchestrator.
|
|
10
|
-
#
|
|
11
|
-
# Responsibility: Orchestrate 7-layer document validation.
|
|
12
|
-
# Single Responsibility: Only coordinates validation layers.
|
|
13
|
-
#
|
|
14
|
-
# Validates Word documents at 7 layers (MECE):
|
|
15
|
-
# 1. File Structure - file exists, readable, valid extension
|
|
16
|
-
# 2. ZIP Integrity - valid archive, no corruption
|
|
17
|
-
# 3. OOXML Parts - required parts present
|
|
18
|
-
# 4. XML Schema - well-formed XML
|
|
19
|
-
# 5. Relationships - valid references
|
|
20
|
-
# 6. Content Types - consistent type declarations
|
|
21
|
-
# 7. Document Semantics - valid document structure
|
|
22
|
-
#
|
|
23
|
-
# External configuration: config/validation_rules.yml
|
|
24
|
-
#
|
|
25
|
-
# @example Basic validation
|
|
26
|
-
# validator = DocumentValidator.new
|
|
27
|
-
# report = validator.validate('document.docx')
|
|
28
|
-
# puts report.valid? # => true
|
|
29
|
-
#
|
|
30
|
-
# @example Custom configuration
|
|
31
|
-
# validator = DocumentValidator.new(
|
|
32
|
-
# config_file: 'custom_validation.yml'
|
|
33
|
-
# )
|
|
34
|
-
# report = validator.validate('document.docx')
|
|
35
|
-
class DocumentValidator
|
|
36
|
-
# @return [Hash] Configuration
|
|
37
|
-
attr_reader :config
|
|
38
|
-
|
|
39
|
-
# @return [Array<LayerValidator>] Validators
|
|
40
|
-
attr_reader :validators
|
|
41
|
-
|
|
42
|
-
# Initialize document validator.
|
|
43
|
-
#
|
|
44
|
-
# @param config_file [String] Path to configuration file
|
|
45
|
-
#
|
|
46
|
-
# @example Create with default config
|
|
47
|
-
# validator = DocumentValidator.new
|
|
48
|
-
#
|
|
49
|
-
# @example Create with custom config
|
|
50
|
-
# validator = DocumentValidator.new(
|
|
51
|
-
# config_file: 'config/custom_validation.yml'
|
|
52
|
-
# )
|
|
53
|
-
def initialize(config_file: nil)
|
|
54
|
-
@config = load_config(config_file)
|
|
55
|
-
@validators = initialize_validators
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Validate a document file.
|
|
59
|
-
#
|
|
60
|
-
# Runs all enabled validators in sequence. Can fail-fast on
|
|
61
|
-
# critical errors if configured.
|
|
62
|
-
#
|
|
63
|
-
# @param path [String] Path to .docx file
|
|
64
|
-
# @return [DocumentValidationReport] Validation results
|
|
65
|
-
#
|
|
66
|
-
# @example Validate a document
|
|
67
|
-
# report = validator.validate('document.docx')
|
|
68
|
-
# if report.valid?
|
|
69
|
-
# puts "Document is valid!"
|
|
70
|
-
# else
|
|
71
|
-
# puts "Errors: #{report.errors.count}"
|
|
72
|
-
# end
|
|
73
|
-
def validate(path)
|
|
74
|
-
report = DocumentValidationReport.new(path)
|
|
75
|
-
|
|
76
|
-
@validators.each do |validator|
|
|
77
|
-
next unless validator.enabled?
|
|
78
|
-
|
|
79
|
-
result = validator.validate(path)
|
|
80
|
-
report.add_layer_result(validator.layer_name, result)
|
|
81
|
-
|
|
82
|
-
# Fail fast if critical failure and configured to do so
|
|
83
|
-
break if result.critical_failures? && fail_fast?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
report
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# Quick validity check (boolean).
|
|
90
|
-
#
|
|
91
|
-
# @param path [String] Path to .docx file
|
|
92
|
-
# @return [Boolean] true if document is valid
|
|
93
|
-
#
|
|
94
|
-
# @example Quick check
|
|
95
|
-
# if validator.valid?('document.docx')
|
|
96
|
-
# # Process document
|
|
97
|
-
# end
|
|
98
|
-
def valid?(path)
|
|
99
|
-
validate(path).valid?
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
private
|
|
103
|
-
|
|
104
|
-
def load_config(config_file)
|
|
105
|
-
if config_file
|
|
106
|
-
Configuration::ConfigurationLoader.load_file(config_file)
|
|
107
|
-
else
|
|
108
|
-
# Try to load default config
|
|
109
|
-
default_path = File.join(
|
|
110
|
-
Configuration::ConfigurationLoader::CONFIG_DIR,
|
|
111
|
-
"validation_rules.yml",
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
if File.exist?(default_path)
|
|
115
|
-
Configuration::ConfigurationLoader.load("validation_rules")
|
|
116
|
-
else
|
|
117
|
-
# Use empty config with defaults
|
|
118
|
-
{ document_validation: { fail_fast: true } }
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
rescue Configuration::ConfigurationError
|
|
122
|
-
# If config fails to load, use defaults
|
|
123
|
-
{ document_validation: { fail_fast: true } }
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def initialize_validators
|
|
127
|
-
config_hash = @config[:document_validation] || @config
|
|
128
|
-
|
|
129
|
-
[
|
|
130
|
-
Validators::FileStructureValidator.new(config_hash),
|
|
131
|
-
Validators::ZipIntegrityValidator.new(config_hash),
|
|
132
|
-
Validators::OoxmlPartValidator.new(config_hash),
|
|
133
|
-
Validators::XmlSchemaValidator.new(config_hash),
|
|
134
|
-
Validators::RelationshipValidator.new(config_hash),
|
|
135
|
-
Validators::ContentTypeValidator.new(config_hash),
|
|
136
|
-
Validators::DocumentSemanticsValidator.new(config_hash),
|
|
137
|
-
]
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def fail_fast?
|
|
141
|
-
validation_config = @config[:document_validation] || {}
|
|
142
|
-
validation_config[:fail_fast] != false
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# Validation report for document validation.
|
|
147
|
-
#
|
|
148
|
-
# Aggregates results from all validation layers.
|
|
149
|
-
class DocumentValidationReport
|
|
150
|
-
# @return [String] Path to validated file
|
|
151
|
-
attr_reader :file_path
|
|
152
|
-
|
|
153
|
-
# @return [Hash<String, LayerValidationResult>] Results by layer
|
|
154
|
-
attr_reader :layer_results
|
|
155
|
-
|
|
156
|
-
# Initialize a new report.
|
|
157
|
-
#
|
|
158
|
-
# @param file_path [String] Path to validated file
|
|
159
|
-
def initialize(file_path)
|
|
160
|
-
@file_path = file_path
|
|
161
|
-
@layer_results = {}
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
# Add a layer validation result.
|
|
165
|
-
#
|
|
166
|
-
# @param layer_name [String] Name of validation layer
|
|
167
|
-
# @param result [LayerValidationResult] Validation result
|
|
168
|
-
# @return [void]
|
|
169
|
-
def add_layer_result(layer_name, result)
|
|
170
|
-
@layer_results[layer_name] = result
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# Check if document is valid overall.
|
|
174
|
-
#
|
|
175
|
-
# @return [Boolean] true if all layers passed
|
|
176
|
-
def valid?
|
|
177
|
-
@layer_results.values.all?(&:valid?)
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
# Get all errors from all layers.
|
|
181
|
-
#
|
|
182
|
-
# @return [Array<Hash>] All errors with layer info
|
|
183
|
-
def errors
|
|
184
|
-
@layer_results.flat_map do |layer, result|
|
|
185
|
-
result.errors.map { |err| err.merge(layer: layer) }
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
# Get all warnings from all layers.
|
|
190
|
-
#
|
|
191
|
-
# @return [Array<Hash>] All warnings with layer info
|
|
192
|
-
def warnings
|
|
193
|
-
@layer_results.flat_map do |layer, result|
|
|
194
|
-
result.warnings.map { |warn| warn.merge(layer: layer) }
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
# Get all info messages from all layers.
|
|
199
|
-
#
|
|
200
|
-
# @return [Array<Hash>] All info messages with layer info
|
|
201
|
-
def infos
|
|
202
|
-
@layer_results.flat_map do |layer, result|
|
|
203
|
-
result.infos.map { |info| info.merge(layer: layer) }
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
# Check if any layer has critical failures.
|
|
208
|
-
#
|
|
209
|
-
# @return [Boolean] true if critical failures exist
|
|
210
|
-
def critical_failures?
|
|
211
|
-
@layer_results.values.any?(&:critical_failures?)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
# Get summary statistics.
|
|
215
|
-
#
|
|
216
|
-
# @return [Hash] Summary data
|
|
217
|
-
def summary
|
|
218
|
-
{
|
|
219
|
-
file: @file_path,
|
|
220
|
-
valid: valid?,
|
|
221
|
-
layers_validated: @layer_results.count,
|
|
222
|
-
errors: errors.count,
|
|
223
|
-
warnings: warnings.count,
|
|
224
|
-
infos: infos.count,
|
|
225
|
-
critical: critical_failures?,
|
|
226
|
-
}
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
# Export to JSON string.
|
|
230
|
-
#
|
|
231
|
-
# @return [String] JSON representation
|
|
232
|
-
def to_json(*_args)
|
|
233
|
-
JSON.pretty_generate(
|
|
234
|
-
summary: summary,
|
|
235
|
-
layers: @layer_results.transform_values(&:to_h),
|
|
236
|
-
)
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
# Convert to string for display.
|
|
240
|
-
#
|
|
241
|
-
# @return [String] String representation
|
|
242
|
-
def to_s
|
|
243
|
-
lines = [
|
|
244
|
-
"Document Validation Report: #{@file_path}",
|
|
245
|
-
"=" * 60,
|
|
246
|
-
"",
|
|
247
|
-
]
|
|
248
|
-
|
|
249
|
-
@layer_results.each_value do |result|
|
|
250
|
-
lines << result.to_s
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
lines << ""
|
|
254
|
-
lines << "Summary:"
|
|
255
|
-
lines << " Valid: #{valid?}"
|
|
256
|
-
lines << " Errors: #{errors.count}"
|
|
257
|
-
lines << " Warnings: #{warnings.count}"
|
|
258
|
-
lines << " Info: #{infos.count}"
|
|
259
|
-
|
|
260
|
-
if errors.any?
|
|
261
|
-
lines << ""
|
|
262
|
-
lines << "Errors:"
|
|
263
|
-
errors.each do |error|
|
|
264
|
-
lines << " [#{error[:layer]}] #{error[:message]}"
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
lines.join("\n")
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
end
|