lutaml-model 0.8.187 → 0.8.188
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/.github/workflows/dependent-repos-tools-informational.json +8 -0
- data/.github/workflows/dependent-repos-tools.json +1 -5
- data/.github/workflows/dependent-tests.yml +26 -2
- data/Gemfile +2 -0
- data/Rakefile +6 -0
- data/exe/lutaml-lml-lsp +11 -0
- data/lib/compat/opal/generate_boot.rb +12 -5
- data/lib/compat/opal/lutaml_model_boot.rb +96 -4
- data/lib/lutaml/lml/association_label_resolver.rb +52 -0
- data/lib/lutaml/lml/data_processor/attribute_processing.rb +133 -0
- data/lib/lutaml/lml/data_processor/collection_processing.rb +37 -0
- data/lib/lutaml/lml/data_processor/instance_processing.rb +77 -0
- data/lib/lutaml/lml/data_processor/value_declaration_processing.rb +70 -0
- data/lib/lutaml/lml/data_processor/value_processing.rb +103 -0
- data/lib/lutaml/lml/data_processor/view_processing.rb +26 -0
- data/lib/lutaml/lml/data_processor.rb +66 -0
- data/lib/lutaml/lml/diagnostic.rb +149 -0
- data/lib/lutaml/lml/document_builder.rb +486 -0
- data/lib/lutaml/lml/entity_types.rb +31 -0
- data/lib/lutaml/lml/executor/adapter_helpers.rb +45 -0
- data/lib/lutaml/lml/executor/condition_evaluator.rb +175 -0
- data/lib/lutaml/lml/executor/csv_adapter.rb +89 -0
- data/lib/lutaml/lml/executor/format_adapter.rb +54 -0
- data/lib/lutaml/lml/executor/xml_adapter.rb +102 -0
- data/lib/lutaml/lml/executor.rb +96 -0
- data/lib/lutaml/lml/format/adapter/document.rb +11 -0
- data/lib/lutaml/lml/format/adapter/mapping.rb +31 -0
- data/lib/lutaml/lml/format/adapter/standard_adapter.rb +164 -0
- data/lib/lutaml/lml/format/adapter/transform.rb +11 -0
- data/lib/lutaml/lml/format.rb +34 -0
- data/lib/lutaml/lml/formatter/base.rb +81 -0
- data/lib/lutaml/lml/formatter/canonical.rb +738 -0
- data/lib/lutaml/lml/formatter.rb +11 -0
- data/lib/lutaml/lml/grammar/lml.artifact.json +14993 -0
- data/lib/lutaml/lml/grammar/lml.parg +389 -0
- data/lib/lutaml/lml/grammar.rb +60 -0
- data/lib/lutaml/lml/has_attributes.rb +14 -0
- data/lib/lutaml/lml/import_resolver.rb +96 -0
- data/lib/lutaml/lml/layout/engine.rb +17 -0
- data/lib/lutaml/lml/layout.rb +9 -0
- data/lib/lutaml/lml/literal_value.rb +32 -0
- data/lib/lutaml/lml/lsp/conversions.rb +78 -0
- data/lib/lutaml/lml/lsp/keywords.rb +43 -0
- data/lib/lutaml/lml/lsp/server.rb +380 -0
- data/lib/lutaml/lml/lsp/store.rb +68 -0
- data/lib/lutaml/lml/lsp/transport.rb +53 -0
- data/lib/lutaml/lml/lsp.rb +16 -0
- data/lib/lutaml/lml/model_compiler/enums.rb +170 -0
- data/lib/lutaml/lml/model_compiler/hydration.rb +122 -0
- data/lib/lutaml/lml/model_compiler/serialization_mappings.rb +188 -0
- data/lib/lutaml/lml/model_compiler/string_formats.rb +42 -0
- data/lib/lutaml/lml/model_compiler/validation.rb +65 -0
- data/lib/lutaml/lml/model_compiler.rb +329 -0
- data/lib/lutaml/lml/models/action.rb +10 -0
- data/lib/lutaml/lml/models/association.rb +31 -0
- data/lib/lutaml/lml/models/cardinality.rb +10 -0
- data/lib/lutaml/lml/models/collection.rb +11 -0
- data/lib/lutaml/lml/models/constraint.rb +25 -0
- data/lib/lutaml/lml/models/data_type.rb +43 -0
- data/lib/lutaml/lml/models/derived_field.rb +14 -0
- data/lib/lutaml/lml/models/diagram.rb +22 -0
- data/lib/lutaml/lml/models/document.rb +86 -0
- data/lib/lutaml/lml/models/enum.rb +40 -0
- data/lib/lutaml/lml/models/fidelity.rb +10 -0
- data/lib/lutaml/lml/models/group.rb +11 -0
- data/lib/lutaml/lml/models/instance.rb +28 -0
- data/lib/lutaml/lml/models/instance_collection.rb +18 -0
- data/lib/lutaml/lml/models/instances_export.rb +10 -0
- data/lib/lutaml/lml/models/instances_import.rb +11 -0
- data/lib/lutaml/lml/models/mapping.rb +15 -0
- data/lib/lutaml/lml/models/mapping_rule.rb +16 -0
- data/lib/lutaml/lml/models/member_field.rb +16 -0
- data/lib/lutaml/lml/models/namespace.rb +18 -0
- data/lib/lutaml/lml/models/operation.rb +28 -0
- data/lib/lutaml/lml/models/operation_parameter.rb +12 -0
- data/lib/lutaml/lml/models/package.rb +28 -0
- data/lib/lutaml/lml/models/primitive_type.rb +35 -0
- data/lib/lutaml/lml/models/reference.rb +23 -0
- data/lib/lutaml/lml/models/serialization_mapping.rb +21 -0
- data/lib/lutaml/lml/models/string_format.rb +16 -0
- data/lib/lutaml/lml/models/top_element_attribute.rb +118 -0
- data/lib/lutaml/lml/models/uml_class.rb +87 -0
- data/lib/lutaml/lml/models/value.rb +17 -0
- data/lib/lutaml/lml/models/view_filter.rb +11 -0
- data/lib/lutaml/lml/models/view_import.rb +11 -0
- data/lib/lutaml/lml/parser.rb +19 -0
- data/lib/lutaml/lml/pipeline.rb +73 -0
- data/lib/lutaml/lml/positioned.rb +13 -0
- data/lib/lutaml/lml/preprocessor.rb +132 -0
- data/lib/lutaml/lml/quoting.rb +60 -0
- data/lib/lutaml/lml/source.rb +49 -0
- data/lib/lutaml/lml/source_position.rb +20 -0
- data/lib/lutaml/lml/symbol_index.rb +202 -0
- data/lib/lutaml/lml/transform.rb +119 -0
- data/lib/lutaml/lml/types/text_type.rb +28 -0
- data/lib/lutaml/lml/types.rb +10 -0
- data/lib/lutaml/lml/validator.rb +460 -0
- data/lib/lutaml/lml/view_resolution.rb +32 -0
- data/lib/lutaml/lml/view_resolver.rb +48 -0
- data/lib/lutaml/lml/yaml_parser.rb +17 -0
- data/lib/lutaml/lml.rb +130 -0
- data/lib/lutaml/model/adapter_resolver.rb +21 -2
- data/lib/lutaml/model/config.rb +22 -0
- data/lib/lutaml/model/serialize/format_conversion.rb +8 -6
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/adapter/base_adapter.rb +26 -0
- data/lib/lutaml/xml/adapter/moxml_adapter.rb +49 -0
- data/lib/lutaml/xml/adapter/xml_parser.rb +4 -4
- data/lib/lutaml/xml/adapter/xml_serializer.rb +1 -1
- data/lib/lutaml/xml/adapter.rb +5 -0
- data/lib/lutaml/xml/adapter_loader.rb +5 -0
- data/lib/lutaml/xml/format.rb +23 -2
- data/lib/lutaml/xml/leptris/native_emission.rb +6 -1
- data/lib/lutaml/xml/leptris/plan_serializer.rb +5 -1
- data/lib/lutaml/xml/parse_session.rb +8 -1
- data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
- data/lib/lutaml/xml/schema/builder.rb +1 -1
- data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
- data/lib/lutaml/xml/schema/vc_namespace.rb +24 -0
- data/lib/lutaml/xml/schema/xsd/any.rb +4 -0
- data/lib/lutaml/xml/schema/xsd/any_attribute.rb +4 -0
- data/lib/lutaml/xml/schema/xsd/base.rb +7 -0
- data/lib/lutaml/xml/schema/xsd/schema.rb +38 -0
- data/lib/lutaml/xml/schema/xsd/schema_validator.rb +1 -1
- data/lib/lutaml/xml/schema/xsd.rb +1 -0
- data/lib/lutaml/xml/schema/xsd_schema.rb +1 -1
- data/lib/lutaml/xml/serialization/format_conversion.rb +6 -0
- data/lib/lutaml/xml/xsd_validator.rb +1 -1
- data/lutaml-model.gemspec +2 -0
- data/spec/lml/fixtures/dsl/broken_diagram.lutaml +34 -0
- data/spec/lml/fixtures/dsl/diagram.lutaml +4 -0
- data/spec/lml/fixtures/dsl/diagram_attributes.lutaml +6 -0
- data/spec/lml/fixtures/dsl/diagram_blank_definion.lutaml +6 -0
- data/spec/lml/fixtures/dsl/diagram_blank_entities.lutaml +8 -0
- data/spec/lml/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
- data/spec/lml/fixtures/dsl/diagram_class_fields.lutaml +25 -0
- data/spec/lml/fixtures/dsl/diagram_commented_includes.lutaml +5 -0
- data/spec/lml/fixtures/dsl/diagram_comments.lutaml +28 -0
- data/spec/lml/fixtures/dsl/diagram_concept_model.lutaml +132 -0
- data/spec/lml/fixtures/dsl/diagram_data_types.lutaml +44 -0
- data/spec/lml/fixtures/dsl/diagram_definitions.lutaml +25 -0
- data/spec/lml/fixtures/dsl/diagram_includes.lutaml +6 -0
- data/spec/lml/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
- data/spec/lml/fixtures/dsl/diagram_non_existing_include.lutaml +6 -0
- data/spec/lml/fixtures/dsl/shared.lutaml +5 -0
- data/spec/lml/fixtures/dsl/shared1.lutaml +4 -0
- data/spec/lml/fixtures/generated_dot/AddressClassProfile.dot +170 -0
- data/spec/lml/fixtures/generated_dot/AddressProfile.dot +34 -0
- data/spec/lml/fixtures/generated_dot/address_class_profile_with_associations.dot +127 -0
- data/spec/lml/fixtures/generated_dot/address_profile_with_associations.dot +28 -0
- data/spec/lml/fixtures/generated_dot/document.dot +28 -0
- data/spec/lml/fixtures/generated_dot/document.dot.backup +33 -0
- data/spec/lml/fixtures/generated_dot/document_with_fidelity.dot +27 -0
- data/spec/lml/fixtures/lml/data_s102_check.lml +79 -0
- data/spec/lml/fixtures/lml/data_s158_metadata.lml +28 -0
- data/spec/lml/fixtures/lml/iho_data_models.lml +59 -0
- data/spec/lml/fixtures/lml/iho_s102_check.lml +101 -0
- data/spec/lml/fixtures/mixed_lml/diagram.lml +26 -0
- data/spec/lml/fixtures/mixed_lml/instances.lml +72 -0
- data/spec/lml/fixtures/mixed_lml/model.lml +30 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/AdmonitionType.lutaml +32 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/BasicBlock.lutaml +11 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/BasicDocument.lutaml +41 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/BasicSection.lutaml +38 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/BibliographicItem.lutaml +6 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/FigureBlock.lutaml +65 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/FormattedString.lutaml +12 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/List.lutaml +12 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/OrderedListType.lutaml +32 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/Signature.lutaml +22 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/String.lutaml +2 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/TableBlock.lutaml +60 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/TextElement.lutaml +13 -0
- data/spec/lml/fixtures/real_world/basicdoc-models/Uri.lutaml +7 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/BibliographicItem.lutaml +4 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoAdmonitionType.lutaml +31 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoBibDataExtensionType.lutaml +40 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoSections.lutaml +30 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoStandardDocument.lutaml +46 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoTerm.lutaml +20 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardBibDataExtensionType.lutaml +2 -0
- data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardDocument.lutaml +2 -0
- data/spec/lml/fixtures/rs3001/01_class_tail_comment.lml +5 -0
- data/spec/lml/fixtures/rs3001/02_definition_block.lml +9 -0
- data/spec/lml/fixtures/rs3001/03_package_ceramics.lml +20 -0
- data/spec/lml/fixtures/rs3001/04_attribute_definition_form.lml +10 -0
- data/spec/lml/fixtures/rs3001/05_attribute_cardinality_unbounded.lml +10 -0
- data/spec/lml/fixtures/rs3001/06_attribute_values_set.lml +10 -0
- data/spec/lml/fixtures/rs3001/07_attribute_pattern.lml +10 -0
- data/spec/lml/fixtures/rs3001/08_attribute_default_colon.lml +15 -0
- data/spec/lml/fixtures/rs3001/09_value_porcelain.lml +9 -0
- data/spec/lml/fixtures/rs3001/10_enum_glaze_technique.lml +19 -0
- data/spec/lml/fixtures/rs3001/11_enum_values_as_instances.lml +29 -0
- data/spec/lml/fixtures/rs3001/12_instance_named.lml +13 -0
- data/spec/lml/fixtures/rs3001/13_instances_collection_refs.lml +11 -0
- data/spec/lml/fixtures/rs3001/14_require_models.lml +7 -0
- data/spec/lml/fixtures/rs3001/15_comment_line.lml +1 -0
- data/spec/lml/fixtures/rs3001/16_comment_tail.lml +5 -0
- data/spec/lml/fixtures/rs3001/17_comment_documented_class.lml +5 -0
- data/spec/lml/fixtures/rs3001/18_comment_block.lml +4 -0
- data/spec/lml/fixtures/rs3001/19_top_level_instance_definition.lml +21 -0
- data/spec/lml/fixtures/rs3001/20_instance_typed_definition.lml +22 -0
- data/spec/lml/fixtures/rs3001/21_instance_collection_studios.lml +19 -0
- data/spec/lml/fixtures/rs3001/22_instance_collection_tiles.lml +15 -0
- data/spec/lml/fixtures/rs3001/23_reference_cross_collection.lml +11 -0
- data/spec/lml/fixtures/rs3001/24_null_and_empty.lml +15 -0
- data/spec/lml/fixtures/rs3001/25_string_escapes.lml +23 -0
- data/spec/lml/fixtures/rs3001/26_quoted_keys.lml +7 -0
- data/spec/lml/fixtures/test.lutaml +20 -0
- data/spec/lml/fixtures/test_data/components.csv +4 -0
- data/spec/lml/fixtures/test_data/products.xml +18 -0
- data/spec/lml/fixtures/uml/address_class_profile_with_associations.yml +58 -0
- data/spec/lml/fixtures/uml/address_profile_with_associations.yml +31 -0
- data/spec/lml/fixtures/uml/association.yml +11 -0
- data/spec/lml/fixtures/uml/class.yml +28 -0
- data/spec/lml/fixtures/uml/data_type.yml +30 -0
- data/spec/lml/fixtures/uml/diagram.yml +7 -0
- data/spec/lml/fixtures/uml/document.yml +44 -0
- data/spec/lml/fixtures/uml/document_with_fidelity.yml +47 -0
- data/spec/lml/fixtures/uml/enum.yml +14 -0
- data/spec/lml/fixtures/uml/operation.yml +8 -0
- data/spec/lml/fixtures/uml/package.yml +10 -0
- data/spec/lml/fixtures/uml/top_element.yml +11 -0
- data/spec/lml/fixtures/uml/top_element_attribute.yml +10 -0
- data/spec/lml/fixtures/uml/trigger.yml +12 -0
- data/spec/lml/fixtures/uml/value.yml +8 -0
- data/spec/lml/fixtures/view/cycle_a.lutaml +3 -0
- data/spec/lml/fixtures/view/cycle_b.lutaml +3 -0
- data/spec/lml/fixtures/view/import_model.lutaml +3 -0
- data/spec/lml/fixtures/view/import_view.lutaml +3 -0
- data/spec/lml/fixtures/view/import_with_hide.lutaml +4 -0
- data/spec/lml/fixtures/view/import_with_show.lutaml +4 -0
- data/spec/lml/fixtures/view/models/bar.lutaml +3 -0
- data/spec/lml/fixtures/view/models/baz.lutaml +3 -0
- data/spec/lml/fixtures/view/models/foo.lutaml +4 -0
- data/spec/lml/integration/instance_import_export_spec.rb +102 -0
- data/spec/lml/lml_spec_setup.rb +25 -0
- data/spec/lml/lutaml/lml/association_label_resolver_spec.rb +139 -0
- data/spec/lml/lutaml/lml/data_processor_spec.rb +274 -0
- data/spec/lml/lutaml/lml/declarations_spec.rb +337 -0
- data/spec/lml/lutaml/lml/document_builder_registry_spec.rb +52 -0
- data/spec/lml/lutaml/lml/document_builder_spec.rb +99 -0
- data/spec/lml/lutaml/lml/element_visibility_spec.rb +128 -0
- data/spec/lml/lutaml/lml/entity_types_spec.rb +56 -0
- data/spec/lml/lutaml/lml/enum_spec.rb +77 -0
- data/spec/lml/lutaml/lml/executor/adapter_helpers_spec.rb +96 -0
- data/spec/lml/lutaml/lml/executor/condition_evaluator_spec.rb +393 -0
- data/spec/lml/lutaml/lml/executor/csv_adapter_spec.rb +151 -0
- data/spec/lml/lutaml/lml/executor/format_adapter_spec.rb +31 -0
- data/spec/lml/lutaml/lml/executor/xml_adapter_spec.rb +201 -0
- data/spec/lml/lutaml/lml/executor_spec.rb +71 -0
- data/spec/lml/lutaml/lml/format_adapter_spec.rb +272 -0
- data/spec/lml/lutaml/lml/format_autoload_spec.rb +31 -0
- data/spec/lml/lutaml/lml/grammar_spec.rb +581 -0
- data/spec/lml/lutaml/lml/has_attributes_spec.rb +54 -0
- data/spec/lml/lutaml/lml/import_resolver_spec.rb +116 -0
- data/spec/lml/lutaml/lml/instance_hydration_spec.rb +178 -0
- data/spec/lml/lutaml/lml/lsp/server_spec.rb +285 -0
- data/spec/lml/lutaml/lml/model_compiler_spec.rb +406 -0
- data/spec/lml/lutaml/lml/models/association_spec.rb +40 -0
- data/spec/lml/lutaml/lml/models/collection_spec.rb +27 -0
- data/spec/lml/lutaml/lml/models/data_type_spec.rb +34 -0
- data/spec/lml/lutaml/lml/models/diagram_spec.rb +18 -0
- data/spec/lml/lutaml/lml/models/document_spec.rb +64 -0
- data/spec/lml/lutaml/lml/models/enum_spec.rb +42 -0
- data/spec/lml/lutaml/lml/models/inheritance_spec.rb +77 -0
- data/spec/lml/lutaml/lml/models/instance_collection_spec.rb +62 -0
- data/spec/lml/lutaml/lml/models/instance_spec.rb +81 -0
- data/spec/lml/lutaml/lml/models/instances_export_spec.rb +23 -0
- data/spec/lml/lutaml/lml/models/instances_import_spec.rb +28 -0
- data/spec/lml/lutaml/lml/models/package_spec.rb +26 -0
- data/spec/lml/lutaml/lml/models/primitive_type_spec.rb +34 -0
- data/spec/lml/lutaml/lml/models/top_element_attribute_spec.rb +153 -0
- data/spec/lml/lutaml/lml/models/uml_class_spec.rb +70 -0
- data/spec/lml/lutaml/lml/models_version_spec.rb +27 -0
- data/spec/lml/lutaml/lml/operations_spec.rb +59 -0
- data/spec/lml/lutaml/lml/parser_spec.rb +348 -0
- data/spec/lml/lutaml/lml/pipeline_spec.rb +93 -0
- data/spec/lml/lutaml/lml/preprocessor_spec.rb +174 -0
- data/spec/lml/lutaml/lml/property_laws_spec.rb +344 -0
- data/spec/lml/lutaml/lml/real_world_spec.rb +191 -0
- data/spec/lml/lutaml/lml/reference_spec.rb +64 -0
- data/spec/lml/lutaml/lml/round_trip_spec.rb +457 -0
- data/spec/lml/lutaml/lml/rs3001_corpus_spec.rb +83 -0
- data/spec/lml/lutaml/lml/rs3001_syntax_spec.rb +77 -0
- data/spec/lml/lutaml/lml/serialization_mapping_spec.rb +127 -0
- data/spec/lml/lutaml/lml/source_spec.rb +62 -0
- data/spec/lml/lutaml/lml/transform_spec.rb +37 -0
- data/spec/lml/lutaml/lml/types/text_type_spec.rb +43 -0
- data/spec/lml/lutaml/lml/validator_spec.rb +238 -0
- data/spec/lml/lutaml/lml/view_resolver_spec.rb +78 -0
- data/spec/lml/lutaml/lml/view_spec.rb +112 -0
- data/spec/lml/lutaml/parsers/dsl_spec.rb +275 -0
- data/spec/lml/lutaml/parsers/yaml_spec.rb +52 -0
- data/spec/lml/lutaml/qualified_type_spec.rb +33 -0
- data/spec/lutaml/model/adapter_type_unset_restore_spec.rb +61 -0
- data/spec/lutaml/model/custom_bibtex_adapter_spec.rb +4 -1
- data/spec/lutaml/xml/adapter/moxml_lane_spec.rb +112 -0
- data/spec/lutaml/xml/adapter_metadata_default_spec.rb +21 -2
- data/spec/lutaml/xml/adapter_moxml_engine_spec.rb +57 -0
- data/spec/lutaml/xml/leptris/native_emission_plain_model_spec.rb +50 -0
- data/spec/lutaml/xml/plain_model_mapping_resolution_spec.rb +88 -0
- data/spec/lutaml/xml/schema/xsd/vc_versioning_spec.rb +49 -0
- data/spec/lutaml/xml/schema/xsd/xsd_11_constructs_spec.rb +43 -0
- metadata +286 -2
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe "DSL (.lutaml) parsing via Lutaml::Lml::Parser" do
|
|
7
|
+
def parse_dsl(fixture_name)
|
|
8
|
+
Lutaml::Lml.parse(File.new(fixtures_path("dsl/#{fixture_name}")))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "simple diagram without attributes" do
|
|
12
|
+
let(:doc) { parse_dsl("diagram.lutaml") }
|
|
13
|
+
|
|
14
|
+
it "creates a Lutaml::Lml::Document" do
|
|
15
|
+
expect(doc).to be_instance_of(Lutaml::Lml::Document)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "diagram with attributes" do
|
|
20
|
+
let(:doc) { parse_dsl("diagram_attributes.lutaml") }
|
|
21
|
+
|
|
22
|
+
it "sets document metadata", :aggregate_failures do
|
|
23
|
+
expect(doc).to be_instance_of(Lutaml::Lml::Document)
|
|
24
|
+
expect(doc.title).to eq("my diagram, another symbols: text.")
|
|
25
|
+
expect(doc.caption)
|
|
26
|
+
.to(eq("Block elements of StandardDocument, adapted from " \
|
|
27
|
+
"BasicDocument. Another - symbol"))
|
|
28
|
+
expect(doc.fontname).to eq("Arial")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "multiply classes entries" do
|
|
33
|
+
let(:doc) { parse_dsl("diagram_multiply_classes.lutaml") }
|
|
34
|
+
|
|
35
|
+
it "creates dependent classes", :aggregate_failures do
|
|
36
|
+
classes = doc.classes
|
|
37
|
+
expect(doc).to be_instance_of(Lutaml::Lml::Document)
|
|
38
|
+
expect(classes.length).to eq(4)
|
|
39
|
+
expect(by_name(classes, "NamespacedClass").stereotype).to eq(["MyNamespace"])
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "class with fields" do
|
|
44
|
+
let(:doc) { parse_dsl("diagram_class_fields.lutaml") }
|
|
45
|
+
|
|
46
|
+
it "creates the correct number of attributes", :aggregate_failures do
|
|
47
|
+
classes = doc.classes
|
|
48
|
+
expect(by_name(classes, "Component").attributes).to be_nil
|
|
49
|
+
expect(by_name(classes, "AddressClassProfile")
|
|
50
|
+
.attributes.length).to eq(1)
|
|
51
|
+
expect(by_name(classes, "AttributeProfile")
|
|
52
|
+
.attributes.length).to eq(13)
|
|
53
|
+
expect(by_name(classes, "AttributeProfile")
|
|
54
|
+
.attributes.map(&:name))
|
|
55
|
+
.to(eq(["imlicistAttributeProfile",
|
|
56
|
+
"attributeProfile",
|
|
57
|
+
"attributeProfile1",
|
|
58
|
+
"privateAttributeProfile",
|
|
59
|
+
"friendlyAttributeProfile",
|
|
60
|
+
"friendlyAttributeProfile1",
|
|
61
|
+
"protectedAttributeProfile",
|
|
62
|
+
"type/text",
|
|
63
|
+
"slashType",
|
|
64
|
+
"application/docbook+xml",
|
|
65
|
+
"application/tei+xml",
|
|
66
|
+
"text/x-asciidoc",
|
|
67
|
+
"application/x-isodoc+xml"]))
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "sets the correct visibility on attributes", :aggregate_failures do
|
|
71
|
+
attributes = by_name(doc.classes, "AttributeProfile").attributes
|
|
72
|
+
expect(by_name(attributes, "imlicistAttributeProfile").visibility)
|
|
73
|
+
.to be_nil
|
|
74
|
+
expect(by_name(attributes, "imlicistAttributeProfile").stereotype)
|
|
75
|
+
.to be_empty
|
|
76
|
+
expect(by_name(attributes, "attributeProfile").visibility)
|
|
77
|
+
.to eq("public")
|
|
78
|
+
expect(by_name(attributes, "attributeProfile").stereotype)
|
|
79
|
+
.to eq(["BasicDocument"])
|
|
80
|
+
expect(by_name(attributes, "attributeProfile1").visibility)
|
|
81
|
+
.to eq("public")
|
|
82
|
+
expect(by_name(attributes, "attributeProfile1").stereotype)
|
|
83
|
+
.to eq(["BasicDocument"])
|
|
84
|
+
expect(by_name(attributes, "privateAttributeProfile").visibility)
|
|
85
|
+
.to eq("private")
|
|
86
|
+
expect(by_name(attributes, "friendlyAttributeProfile").visibility)
|
|
87
|
+
.to eq("package")
|
|
88
|
+
expect(by_name(attributes, "friendlyAttributeProfile").stereotype)
|
|
89
|
+
.to eq(["Type"])
|
|
90
|
+
expect(by_name(attributes, "protectedAttributeProfile").visibility)
|
|
91
|
+
.to eq("protected")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe "association blocks" do
|
|
96
|
+
let(:doc) { parse_dsl("diagram_class_assocation.lutaml") }
|
|
97
|
+
|
|
98
|
+
it "creates the correct number of associations" do
|
|
99
|
+
expect(doc.associations.length).to eq(3)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
context "bidirectional association" do
|
|
103
|
+
subject(:association) do
|
|
104
|
+
by_name(doc.associations, "BidirectionalAsscoiation")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "sets correct attributes", :aggregate_failures do
|
|
108
|
+
expect(association.owner_end_type).to(eq("aggregation"))
|
|
109
|
+
expect(association.member_end_type).to(eq("direct"))
|
|
110
|
+
expect(association.owner_end).to(eq("AddressClassProfile"))
|
|
111
|
+
expect(association.owner_end_attribute_name)
|
|
112
|
+
.to(eq("addressClassProfile"))
|
|
113
|
+
expect(association.member_end).to(eq("AttributeProfile"))
|
|
114
|
+
expect(association.member_end_attribute_name)
|
|
115
|
+
.to(eq("attributeProfile"))
|
|
116
|
+
expect(association.member_end_cardinality.min).to(eq("0"))
|
|
117
|
+
expect(association.member_end_cardinality.max).to(eq("*"))
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context "direct association" do
|
|
122
|
+
subject(:association) do
|
|
123
|
+
by_name(doc.associations, "DirectAsscoiation")
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "sets correct attributes", :aggregate_failures do
|
|
127
|
+
expect(association.owner_end_type).to(be_nil)
|
|
128
|
+
expect(association.member_end_type).to(eq("direct"))
|
|
129
|
+
expect(association.owner_end).to(eq("AddressClassProfile"))
|
|
130
|
+
expect(association.owner_end_attribute_name).to(be_nil)
|
|
131
|
+
expect(association.member_end).to(eq("AttributeProfile"))
|
|
132
|
+
expect(association.member_end_attribute_name)
|
|
133
|
+
.to(eq("attributeProfile"))
|
|
134
|
+
expect(association.member_end_cardinality).to(be_nil)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
context "reverse association" do
|
|
139
|
+
subject(:association) do
|
|
140
|
+
by_name(doc.associations, "ReverseAsscoiation")
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "sets correct attributes", :aggregate_failures do
|
|
144
|
+
expect(association.owner_end_type).to(eq("aggregation"))
|
|
145
|
+
expect(association.member_end_type).to(be_nil)
|
|
146
|
+
expect(association.owner_end).to(eq("AddressClassProfile"))
|
|
147
|
+
expect(association.owner_end_attribute_name)
|
|
148
|
+
.to(eq("addressClassProfile"))
|
|
149
|
+
expect(association.member_end).to(eq("AttributeProfile"))
|
|
150
|
+
expect(association.member_end_attribute_name).to(be_nil)
|
|
151
|
+
expect(association.member_end_cardinality).to(be_nil)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
describe "data_types entries" do
|
|
157
|
+
let(:doc) { parse_dsl("diagram_data_types.lutaml") }
|
|
158
|
+
|
|
159
|
+
it "generates correct enums", :aggregate_failures do
|
|
160
|
+
enums = doc.enums
|
|
161
|
+
expect(by_name(enums, "MyEnum").attributes).to be_empty
|
|
162
|
+
expect(by_name(enums, "AddressClassProfile")
|
|
163
|
+
.attributes.length).to eq(1)
|
|
164
|
+
expect(by_name(enums, "Profile")
|
|
165
|
+
.attributes.length).to eq(5)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it "generates correct data_types" do
|
|
169
|
+
data_types = doc.data_types
|
|
170
|
+
expect(by_name(data_types, "Banking Information")
|
|
171
|
+
.attributes.map(&:name))
|
|
172
|
+
.to(eq(["art code", "CCT Number"]))
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it "generates correct primitives" do
|
|
176
|
+
expect(by_name(doc.primitives, "Integer")).not_to be_nil
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
describe "concept model" do
|
|
181
|
+
let(:doc) { parse_dsl("diagram_concept_model.lutaml") }
|
|
182
|
+
|
|
183
|
+
it "generates correct class/enums/associations", :aggregate_failures do
|
|
184
|
+
expect(doc.classes.length).to(eq(9))
|
|
185
|
+
expect(doc.enums.length).to(eq(3))
|
|
186
|
+
expect(doc.associations.length).to(eq(16))
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it "generates correct attributes", :aggregate_failures do
|
|
190
|
+
attributes = by_name(doc.classes, "ExpressionDesignation").attributes
|
|
191
|
+
expect(attributes.length).to(eq(5))
|
|
192
|
+
expect(attributes.map(&:name))
|
|
193
|
+
.to(eq(%w[text language script pronunciation grammarInfo]))
|
|
194
|
+
expect(attributes.map(&:type))
|
|
195
|
+
.to(eq(["GlossaristTextElementType",
|
|
196
|
+
"Iso639ThreeCharCode",
|
|
197
|
+
"Iso15924Code",
|
|
198
|
+
"LocalizedString",
|
|
199
|
+
"GrammarInfo"]))
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
describe "include directives" do
|
|
204
|
+
let(:doc) { parse_dsl("diagram_includes.lutaml") }
|
|
205
|
+
|
|
206
|
+
it "includes supplied files", :aggregate_failures do
|
|
207
|
+
expect(doc.classes.map(&:name))
|
|
208
|
+
.to(eq(%w[Foo Doo Koo AttributeProfile]))
|
|
209
|
+
expect(by_name(doc.classes, "AttributeProfile")
|
|
210
|
+
.attributes.map(&:name))
|
|
211
|
+
.to eq(["imlicistAttributeProfile", "attributeProfile"])
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
describe "comments" do
|
|
216
|
+
let(:doc) { parse_dsl("diagram_comments.lutaml") }
|
|
217
|
+
|
|
218
|
+
it "creates comments for document and classes", :aggregate_failures do
|
|
219
|
+
expect(doc.comments).to(eq(["My comment",
|
|
220
|
+
"this is multiline\n comment with " \
|
|
221
|
+
"{} special\n chars/\n\n +-|/"]))
|
|
222
|
+
expect(doc.classes.last.comments)
|
|
223
|
+
.to(eq(["this is attribute comment",
|
|
224
|
+
"this is another comment line\n with multiply lines"]))
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
describe "definitions" do
|
|
229
|
+
let(:doc) { parse_dsl("diagram_definitions.lutaml") }
|
|
230
|
+
let(:class_definition) do
|
|
231
|
+
"this is multiline with `ascidoc`\ncomments\nand list\n{foo} {name}"
|
|
232
|
+
end
|
|
233
|
+
let(:attribute_definition) do
|
|
234
|
+
"this is attribute definition\nwith multiply lines" \
|
|
235
|
+
"\n{foo} {name}\nend definition"
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
it "sets definitions on classes and attributes", :aggregate_failures do
|
|
239
|
+
expect(by_name(doc.classes, "AddressClassProfile").definition)
|
|
240
|
+
.to(eq(class_definition))
|
|
241
|
+
expect(by_name(doc.classes, "AttributeProfile")
|
|
242
|
+
.attributes
|
|
243
|
+
.first
|
|
244
|
+
.definition)
|
|
245
|
+
.to(eq(attribute_definition))
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
describe "edge cases" do
|
|
250
|
+
it "parses blank definitions without error" do
|
|
251
|
+
expect { parse_dsl("diagram_blank_definion.lutaml") }.not_to raise_error
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
it "parses blank entities without error" do
|
|
255
|
+
expect { parse_dsl("diagram_blank_entities.lutaml") }.not_to raise_error
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it "raises on non-existing include (no silent skipping)" do
|
|
259
|
+
expect { parse_dsl("diagram_non_existing_include.lutaml") }
|
|
260
|
+
.to raise_error(Lutaml::Lml::Error, /cannot read include/)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it "parses commented preprocessor lines without error" do
|
|
264
|
+
expect { parse_dsl("diagram_commented_includes.lutaml") }.not_to raise_error
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
describe "broken lutaml file" do
|
|
269
|
+
it "raises ParsingError with line information" do
|
|
270
|
+
expect { parse_dsl("broken_diagram.lutaml") }
|
|
271
|
+
.to(raise_error(Lutaml::Lml::ParsingError,
|
|
272
|
+
/at line 25 char 32/))
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::YamlParser do
|
|
7
|
+
describe ".parse" do
|
|
8
|
+
subject(:parse) { described_class.parse(yaml_path) }
|
|
9
|
+
|
|
10
|
+
let(:yaml_path) do
|
|
11
|
+
fixtures_path("uml/document.yml")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "creates Lutaml::Lml::Document object" do
|
|
15
|
+
expect(parse).to be_instance_of(Lutaml::Lml::Document)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "parses document metadata", :aggregate_failures do
|
|
19
|
+
expect(parse.name).to eq("TestDocument")
|
|
20
|
+
expect(parse.title).to eq("Test Document Title")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "contains nested groups", :aggregate_failures do
|
|
24
|
+
groups = parse.groups
|
|
25
|
+
expect(groups).to be_an(Array)
|
|
26
|
+
expect(groups.size).to eq(2)
|
|
27
|
+
expect(groups.first.id).to eq("TestGroup1")
|
|
28
|
+
expect(groups.first.values).to eq(["TestGroup1a", "TestGroup1b"])
|
|
29
|
+
expect(groups[1].id).to eq("TestGroup2")
|
|
30
|
+
expect(groups[1].values).to eq(["TestGroup2a", "TestGroup2b", "TestGroup2c"])
|
|
31
|
+
expect(groups[1].groups).to be_an(Array)
|
|
32
|
+
expect(groups[1].groups.size).to eq(1)
|
|
33
|
+
expect(groups[1].groups.first.id).to eq("TestSubGroup1")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "parses enums with attributes and values" do
|
|
37
|
+
enums = parse.enums
|
|
38
|
+
expect(enums.size).to eq(1)
|
|
39
|
+
expect(enums.first.name).to eq("TestEnum")
|
|
40
|
+
expect(enums.first.attributes.first.name).to eq("TestAttribute")
|
|
41
|
+
expect(enums.first.values.first.name).to eq("Test value")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "parses nested packages" do
|
|
45
|
+
packages = parse.packages
|
|
46
|
+
expect(packages.size).to eq(1)
|
|
47
|
+
expect(packages.first.name).to eq("Package")
|
|
48
|
+
expect(packages.first.packages.first.name).to eq("NestedPackage")
|
|
49
|
+
expect(packages.first.packages.first.packages.first.name).to eq("DeepNestedPackage")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe "namespace-qualified attribute types" do
|
|
7
|
+
it "parses XSD-qualified types such as xsd:date" do
|
|
8
|
+
src = <<~LML
|
|
9
|
+
diagram Test {
|
|
10
|
+
class Session {
|
|
11
|
+
+number: String[0..1]
|
|
12
|
+
+session-date: xsd:date[0..1]
|
|
13
|
+
+adopted: xsd:gYear[0..1]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
LML
|
|
17
|
+
|
|
18
|
+
require "tempfile"
|
|
19
|
+
file = Tempfile.new(["qualified", ".lutaml"])
|
|
20
|
+
file.write(src)
|
|
21
|
+
file.rewind
|
|
22
|
+
doc = Lutaml::Lml.parse(file)
|
|
23
|
+
file.close
|
|
24
|
+
file.unlink
|
|
25
|
+
|
|
26
|
+
session = doc.classes.find { |c| c.name == "Session" }
|
|
27
|
+
expect(session).not_to be_nil
|
|
28
|
+
attrs = session.attributes
|
|
29
|
+
expect(attrs.map(&:name)).to contain_exactly("number", "session-date", "adopted")
|
|
30
|
+
expect(attrs.find { |a| a.name == "session-date" }.type).to eq("xsd:date")
|
|
31
|
+
expect(attrs.find { |a| a.name == "adopted" }.type).to eq("xsd:gYear")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# The documented save/restore contract for the process-global adapter
|
|
6
|
+
# setting writes the saved reader value back through the writer
|
|
7
|
+
# (uniword's with_boot_adapter shape, #1234). The saved value is nil
|
|
8
|
+
# when no pin was set — the unset delegate form — and the writer must
|
|
9
|
+
# accept it as "return to auto-detection" instead of raising.
|
|
10
|
+
RSpec.describe "adapter type unset/restore (nil delegate form, #1234)" do
|
|
11
|
+
# Save/restore the pins themselves: a blanket AdapterResolver.reset!
|
|
12
|
+
# here wipes the resolution caches mid-suite and flips downstream
|
|
13
|
+
# lanes' engines (rdf/turtle suites run after this file).
|
|
14
|
+
around do |example|
|
|
15
|
+
saved_xml = Lutaml::Model::Config.xml_adapter_type
|
|
16
|
+
saved_json = Lutaml::Model::Config.json_adapter_type
|
|
17
|
+
saved_yaml = Lutaml::Model::Config.yaml_adapter_type
|
|
18
|
+
Lutaml::Model::Config.unset_xml_adapter_type
|
|
19
|
+
Lutaml::Model::Config.unset_json_adapter_type
|
|
20
|
+
Lutaml::Model::Config.unset_yaml_adapter_type
|
|
21
|
+
example.run
|
|
22
|
+
ensure
|
|
23
|
+
Lutaml::Model::Config.xml_adapter_type = saved_xml
|
|
24
|
+
Lutaml::Model::Config.json_adapter_type = saved_json
|
|
25
|
+
Lutaml::Model::Config.yaml_adapter_type = saved_yaml
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "accepts nil from the reader as a restore to the unset form" do
|
|
29
|
+
saved = Lutaml::Model::Config.xml_adapter_type
|
|
30
|
+
expect(saved).to be_nil
|
|
31
|
+
|
|
32
|
+
Lutaml::Model::Config.xml_adapter_type = :nokogiri
|
|
33
|
+
expect(Lutaml::Model::Config.xml_adapter_type).to eq(:nokogiri)
|
|
34
|
+
|
|
35
|
+
Lutaml::Model::Config.xml_adapter_type = saved
|
|
36
|
+
|
|
37
|
+
expect(Lutaml::Model::Config.xml_adapter_type).to be_nil
|
|
38
|
+
expect(Lutaml::Model::Config.xml_adapter).not_to be_nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "exposes the unset operation and restores auto-detection" do
|
|
42
|
+
Lutaml::Model::Config.xml_adapter_type = :leptris
|
|
43
|
+
|
|
44
|
+
Lutaml::Model::Config.unset_xml_adapter_type
|
|
45
|
+
|
|
46
|
+
expect(Lutaml::Model::Config.xml_adapter_type).to be_nil
|
|
47
|
+
expect(Lutaml::Model::Config.xml_adapter).not_to be_nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "clears only the pinned format" do
|
|
51
|
+
Lutaml::Model::Config.configure do |config|
|
|
52
|
+
config.xml_adapter_type = :nokogiri
|
|
53
|
+
config.json_adapter_type = :standard
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Lutaml::Model::Config.unset_xml_adapter_type
|
|
57
|
+
|
|
58
|
+
expect(Lutaml::Model::Config.xml_adapter_type).to be_nil
|
|
59
|
+
expect(Lutaml::Model::Config.json_adapter_type).to eq(:standard)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -182,7 +182,10 @@ module CustomBibtexAdapterSpec
|
|
|
182
182
|
class BibtexAdapter < BibtexDocument
|
|
183
183
|
def self.parse(bibtex_data, options = {})
|
|
184
184
|
mapping = options.delete(:mapping)
|
|
185
|
-
|
|
185
|
+
# Brace-delimited field values keep the scan linear: `[^{}]*`
|
|
186
|
+
# cannot overlap the surrounding quantifiers, so no ReDoS-shaped
|
|
187
|
+
# backtracking exists (CodeQL rb/redos).
|
|
188
|
+
entries = bibtex_data.scan(/@(\w+)\s*\{\s*([\w-]+),\s*((?:\s*\w+\s*=\s*\{[^{}]*\},?)+)\s*\}/).to_h do |type, key, fields|
|
|
186
189
|
[type, BibtexDocumentEntry.parse(type, key, fields, mapping)]
|
|
187
190
|
end
|
|
188
191
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml/lutaml-model#1224: the moxml lane in adapter selection —
|
|
6
|
+
# detection already delegates to moxml ("the authority on XML adapter
|
|
7
|
+
# availability"), but selection could not express the facade lane:
|
|
8
|
+
# no :moxml type, a registration-snapshot default, and no unset-pin
|
|
9
|
+
# API. The three asks:
|
|
10
|
+
#
|
|
11
|
+
# 1. a :moxml adapter type — resolution defers the ENGINE to moxml at
|
|
12
|
+
# parse time (the engine stays a deployment decision owned by
|
|
13
|
+
# moxml),
|
|
14
|
+
# 2. the xml lane's metadata default is the deferred lane,
|
|
15
|
+
# 3. Config.unset_adapter_type restores auto-detection, so a
|
|
16
|
+
# consumer can undo another gem's process-wide pin through a
|
|
17
|
+
# supported call.
|
|
18
|
+
RSpec.describe "the moxml lane in adapter selection (#1224)" do
|
|
19
|
+
# the #1212 probe shape: cross-namespace child binding is the
|
|
20
|
+
# tightest "does this selection parse correctly" signal
|
|
21
|
+
let(:s1_ns) do
|
|
22
|
+
Class.new(Lutaml::Xml::Namespace) do
|
|
23
|
+
uri "http://example/s1"
|
|
24
|
+
prefix_default "s1"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
let(:s2_ns) do
|
|
29
|
+
Class.new(Lutaml::Xml::Namespace) do
|
|
30
|
+
uri "http://example/s2"
|
|
31
|
+
prefix_default "s2"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
let(:bound_class) do
|
|
36
|
+
ns2 = s2_ns
|
|
37
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
38
|
+
attribute :lower, Lutaml::Model::Type::String
|
|
39
|
+
xml do
|
|
40
|
+
element "bound"
|
|
41
|
+
namespace ns2
|
|
42
|
+
map_element "lower", to: :lower
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
let(:wrapper_class) do
|
|
48
|
+
ns1 = s1_ns
|
|
49
|
+
bound = bound_class
|
|
50
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
51
|
+
attribute :ref, Lutaml::Model::Type::String
|
|
52
|
+
attribute :bound, bound
|
|
53
|
+
xml do
|
|
54
|
+
element "wrapper"
|
|
55
|
+
namespace ns1
|
|
56
|
+
map_attribute "ref", to: :ref
|
|
57
|
+
map_element "bound", to: :bound
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
let(:instance_xml) do
|
|
63
|
+
'<s1:wrapper xmlns:s1="http://example/s1" xmlns:s2="http://example/s2" ref="r1"><s2:bound><s2:lower>0</s2:lower></s2:bound></s1:wrapper>'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
after do
|
|
67
|
+
# restore the spec_helper default for every later example
|
|
68
|
+
Lutaml::Model::Config.xml_adapter_type = :nokogiri
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "the :moxml adapter type" do
|
|
72
|
+
it "validates as a selectable xml adapter type" do
|
|
73
|
+
expect { Lutaml::Model::AdapterResolver.resolved_adapter_class(:xml, :moxml) }
|
|
74
|
+
.not_to raise_error
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "parses through the deferred engine and binds namespaced children" do
|
|
78
|
+
Lutaml::Model::Config.xml_adapter_type = :moxml
|
|
79
|
+
|
|
80
|
+
parsed = wrapper_class.from_xml(instance_xml)
|
|
81
|
+
expect(parsed.ref).to eq("r1")
|
|
82
|
+
expect(parsed.bound&.lower).to eq("0")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "resolves lazily - the deferrer class stands in and the engine answers at call time" do
|
|
86
|
+
adapter = Lutaml::Model::AdapterResolver.resolved_adapter_class(
|
|
87
|
+
:xml, :moxml
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# the class IS the deferrer; the engine resolves per call
|
|
91
|
+
expect(adapter.name).to eq("Lutaml::Xml::Adapter::MoxmlAdapter")
|
|
92
|
+
expect(adapter).to respond_to(:parse)
|
|
93
|
+
expect(adapter.moxml_adapter_class.name)
|
|
94
|
+
.to match(/Leptris|Nokogiri/)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "the unset-pin API" do
|
|
99
|
+
it "restores auto-detection after a pin" do
|
|
100
|
+
Lutaml::Model::Config.xml_adapter_type = :ox
|
|
101
|
+
expect(Lutaml::Model::Config.xml_adapter_type).to eq(:ox)
|
|
102
|
+
|
|
103
|
+
Lutaml::Model::Config.unset_adapter_type(:xml)
|
|
104
|
+
|
|
105
|
+
# the pin is gone: configured answers nil and the resolution
|
|
106
|
+
# ladder re-runs (detection delegates to moxml s runtime engine)
|
|
107
|
+
expect(Lutaml::Model::Config.xml_adapter_type).to be_nil
|
|
108
|
+
expect(Lutaml::Model::AdapterResolver.adapter_for(:xml))
|
|
109
|
+
.to respond_to(:parse)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -2,12 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
|
-
RSpec.describe "XML adapter metadata default (#908)" do
|
|
6
|
-
|
|
5
|
+
RSpec.describe "XML adapter metadata default (#908, #1224)" do
|
|
6
|
+
# The metadata default is the DEFERRED lane (#1224): when moxml
|
|
7
|
+
# reports no preference, resolution lands on the :moxml adapter,
|
|
8
|
+
# whose engine resolves at parse time - a preference-less moxml
|
|
9
|
+
# then detects leptris (its own runtime preference), so the
|
|
10
|
+
# observable lane is unchanged from the #908 answer.
|
|
11
|
+
it "resolves to the deferred lane when moxml reports no preference" do
|
|
7
12
|
Lutaml::Model::AdapterResolver.reset!
|
|
8
13
|
|
|
9
14
|
allow(Moxml::Config).to receive(:runtime_default_adapter).and_return(nil)
|
|
10
15
|
|
|
16
|
+
adapter = Lutaml::Model::Config.adapter_for(:xml)
|
|
17
|
+
expect(adapter.name).to eq("Lutaml::Xml::Adapter::MoxmlAdapter")
|
|
18
|
+
ensure
|
|
19
|
+
Lutaml::Model::AdapterResolver.reset!
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# when moxml DOES answer, detection binds the engine directly -
|
|
23
|
+
# the #908 outcome, unchanged by the deferred lane
|
|
24
|
+
it "detects the engine directly when moxml answers" do
|
|
25
|
+
Lutaml::Model::AdapterResolver.reset!
|
|
26
|
+
|
|
27
|
+
allow(Moxml::Config).to receive(:runtime_default_adapter)
|
|
28
|
+
.and_return(:leptris)
|
|
29
|
+
|
|
11
30
|
adapter = Lutaml::Model::Config.adapter_for(:xml)
|
|
12
31
|
expect(adapter.name).to eq("Lutaml::Xml::Adapter::LeptrisAdapter")
|
|
13
32
|
ensure
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# The #1224 completion on top of the deferred lane: the schema/builder
|
|
6
|
+
# surfaces construct Moxml contexts directly and must ask for the
|
|
7
|
+
# ENGINE, not the configured type (whose :moxml lane value is not a
|
|
8
|
+
# valid Moxml adapter name); the leptris plan fast-path gates must
|
|
9
|
+
# resolve through the deferred lane to its engine.
|
|
10
|
+
RSpec.describe "the deferred lane's engine resolution seams" do
|
|
11
|
+
around do |example|
|
|
12
|
+
saved = Lutaml::Model::Config.xml_adapter_type
|
|
13
|
+
Lutaml::Model::Config.xml_adapter_type = :moxml
|
|
14
|
+
example.run
|
|
15
|
+
ensure
|
|
16
|
+
Lutaml::Model::Config.xml_adapter_type = saved
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "answers the engine Moxml deploys through the adapter seam" do
|
|
20
|
+
expect(Lutaml::Model::Config.xml_adapter.engine_adapter_class.name)
|
|
21
|
+
.to eq("Lutaml::Xml::Adapter::LeptrisAdapter")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "parses an XSD schema under the deferred lane" do
|
|
25
|
+
xsd = <<~XSD
|
|
26
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
27
|
+
<xs:complexType name="t">
|
|
28
|
+
<xs:sequence>
|
|
29
|
+
<xs:element name="a"/>
|
|
30
|
+
</xs:sequence>
|
|
31
|
+
</xs:complexType>
|
|
32
|
+
</xs:schema>
|
|
33
|
+
XSD
|
|
34
|
+
|
|
35
|
+
schema = Lutaml::Xml::Schema::Xsd.parse(xsd)
|
|
36
|
+
|
|
37
|
+
expect(schema.complex_type.first.name).to eq("t")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "keeps the leptris plan fast path under explicit :moxml selection" do
|
|
41
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
42
|
+
attribute :name, :string
|
|
43
|
+
|
|
44
|
+
xml do
|
|
45
|
+
element "probe"
|
|
46
|
+
map_element "name", to: :name
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
expect(klass.from_xml("<probe><name>x</name></probe>").name).to eq("x")
|
|
51
|
+
expect(klass.new(name: "x").to_xml).to include("<name>x</name>")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "names the engine for Moxml context construction" do
|
|
55
|
+
expect(Lutaml::Xml.moxml_engine).to eq(Moxml::Config.default.adapter_name)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# The leptris emission read `attribute_order` on every instance
|
|
6
|
+
# unconditionally; plain `model` classes did not carry the accessor,
|
|
7
|
+
# so serializing a parsed document crashed with NoMethodError while
|
|
8
|
+
# the nokogiri lane serialized the same document (#1232).
|
|
9
|
+
RSpec.describe "leptris emission vs plain model instances (#1232)" do
|
|
10
|
+
let(:plain_class) do
|
|
11
|
+
Class.new do
|
|
12
|
+
attr_accessor :title
|
|
13
|
+
|
|
14
|
+
def initialize(title = nil)
|
|
15
|
+
@title = title
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
let(:mapper) do
|
|
21
|
+
plain = plain_class
|
|
22
|
+
|
|
23
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
24
|
+
model plain
|
|
25
|
+
attribute :title, :string
|
|
26
|
+
|
|
27
|
+
xml do
|
|
28
|
+
element "pub"
|
|
29
|
+
map_attribute "title", to: :title
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "installs the attribute_order accessor on plain model classes" do
|
|
35
|
+
mapper # materialize: the accessor install runs when `model` binds
|
|
36
|
+
|
|
37
|
+
aggregate_failures do
|
|
38
|
+
expect(plain_class.method_defined?(:attribute_order)).to be(true)
|
|
39
|
+
expect(plain_class.method_defined?(:attribute_order=)).to be(true)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "serializes a parsed document through leptris without the face read crash" do
|
|
44
|
+
Lutaml::Model::Config.with_adapter(xml: :leptris) do
|
|
45
|
+
instance = mapper.from_xml(%(<pub title="hello"/>))
|
|
46
|
+
|
|
47
|
+
expect(mapper.to_xml(instance)).to include('<pub title="hello"/>')
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|