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,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe "LML model subclasses" do
|
|
7
|
+
describe Lutaml::Lml::UmlClass do
|
|
8
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
9
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "has parent_class attribute" do
|
|
13
|
+
klass = described_class.new(name: "Child", parent_class: "Parent")
|
|
14
|
+
expect(klass.parent_class).to eq("Parent")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "returns :classes as entity_type" do
|
|
18
|
+
expect(described_class.entity_type).to eq(:classes)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe Lutaml::Lml::Enum do
|
|
23
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
24
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "returns :enums as entity_type" do
|
|
28
|
+
expect(described_class.entity_type).to eq(:enums)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe Lutaml::Lml::DataType do
|
|
33
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
34
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "returns :data_types as entity_type" do
|
|
38
|
+
expect(described_class.entity_type).to eq(:data_types)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe Lutaml::Lml::Package do
|
|
43
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
44
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe Lutaml::Lml::Association do
|
|
49
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
50
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe Lutaml::Lml::Cardinality do
|
|
55
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
56
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe Lutaml::Lml::Value do
|
|
61
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
62
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe Lutaml::Lml::Constraint do
|
|
67
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
68
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe Lutaml::Lml::Operation do
|
|
73
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
74
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::InstanceCollection do
|
|
7
|
+
describe "default attributes" do
|
|
8
|
+
it "has empty instances by default" do
|
|
9
|
+
ic = described_class.new
|
|
10
|
+
expect(ic.instances).to eq([])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "has empty imports by default" do
|
|
14
|
+
ic = described_class.new
|
|
15
|
+
expect(ic.imports).to eq([])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "has empty exports by default" do
|
|
19
|
+
ic = described_class.new
|
|
20
|
+
expect(ic.exports).to eq([])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "has empty collections by default" do
|
|
24
|
+
ic = described_class.new
|
|
25
|
+
expect(ic.collections).to eq([])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "with populated data" do
|
|
30
|
+
let(:ic) do
|
|
31
|
+
inst = Lutaml::Lml::Instance.new(type: "Product")
|
|
32
|
+
imp = Lutaml::Lml::InstancesImport.new(format_type: "xml", file: "data.xml")
|
|
33
|
+
exp = Lutaml::Lml::InstancesExport.new(format_type: "json")
|
|
34
|
+
coll = Lutaml::Lml::Collection.new(name: "all_products")
|
|
35
|
+
described_class.new(
|
|
36
|
+
instances: [inst],
|
|
37
|
+
imports: [imp],
|
|
38
|
+
exports: [exp],
|
|
39
|
+
collections: coll,
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "holds instances" do
|
|
44
|
+
expect(ic.instances.length).to eq(1)
|
|
45
|
+
expect(ic.instances.first.type).to eq("Product")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "holds imports" do
|
|
49
|
+
expect(ic.imports.length).to eq(1)
|
|
50
|
+
expect(ic.imports.first.format_type).to eq("xml")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "holds exports" do
|
|
54
|
+
expect(ic.exports.length).to eq(1)
|
|
55
|
+
expect(ic.exports.first.format_type).to eq("json")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "holds collection" do
|
|
59
|
+
expect(ic.collections.first.name).to eq("all_products")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::Instance do
|
|
7
|
+
describe "attributes" do
|
|
8
|
+
it "has type attribute" do
|
|
9
|
+
inst = described_class.new
|
|
10
|
+
expect(inst.type).to be_nil
|
|
11
|
+
inst.type = "MyClass"
|
|
12
|
+
expect(inst.type).to eq("MyClass")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "has attributes collection" do
|
|
16
|
+
inst = described_class.new
|
|
17
|
+
expect(inst.attributes).to be_nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "has nested instance" do
|
|
21
|
+
inst = described_class.new
|
|
22
|
+
expect(inst.instance).to be_nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "has template collection" do
|
|
26
|
+
inst = described_class.new
|
|
27
|
+
expect(inst.template).to be_nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "has parent attribute" do
|
|
31
|
+
inst = described_class.new
|
|
32
|
+
expect(inst.parent).to be_nil
|
|
33
|
+
inst.parent = "base_product"
|
|
34
|
+
expect(inst.parent).to eq("base_product")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "nested instances" do
|
|
39
|
+
it "allows deeply nested instances" do
|
|
40
|
+
inner = described_class.new(type: "Inner")
|
|
41
|
+
outer = described_class.new(type: "Outer", instance: inner)
|
|
42
|
+
expect(outer.instance.type).to eq("Inner")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "with attributes" do
|
|
47
|
+
let(:inst) do
|
|
48
|
+
attr1 = Lutaml::Lml::TopElementAttribute.new(name: "foo", type: "String")
|
|
49
|
+
attr2 = Lutaml::Lml::TopElementAttribute.new(name: "bar", type: "Integer")
|
|
50
|
+
described_class.new(type: "Product", attributes: [attr1, attr2])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "holds typed attributes" do
|
|
54
|
+
expect(inst.attributes.length).to eq(2)
|
|
55
|
+
expect(inst.attributes.map(&:name)).to eq(%w[foo bar])
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#each_attribute" do
|
|
60
|
+
it "yields (name, value, nested) triplets for each attribute" do
|
|
61
|
+
nested = described_class.new(type: "Child")
|
|
62
|
+
child_attr = Lutaml::Lml::TopElementAttribute.new(
|
|
63
|
+
name: "items", type: "Item", instances: [nested],
|
|
64
|
+
)
|
|
65
|
+
scalar_attr = Lutaml::Lml::TopElementAttribute.new(
|
|
66
|
+
name: "count", type: "Integer", value: 3,
|
|
67
|
+
)
|
|
68
|
+
inst = described_class.new(attributes: [child_attr, scalar_attr])
|
|
69
|
+
|
|
70
|
+
triplets = []
|
|
71
|
+
inst.each_attribute { |*t| triplets << t }
|
|
72
|
+
|
|
73
|
+
expect(triplets).to eq([["items", nil, [nested]], ["count", 3, []]])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "returns an Enumerator when no block is given" do
|
|
77
|
+
inst = described_class.new
|
|
78
|
+
expect(inst.each_attribute).to be_an(Enumerator)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::InstancesExport do
|
|
7
|
+
it "has format_type" do
|
|
8
|
+
exp = described_class.new(format_type: "json")
|
|
9
|
+
expect(exp.format_type).to eq("json")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "has attributes collection defaulting to empty" do
|
|
13
|
+
exp = described_class.new
|
|
14
|
+
expect(exp.attributes).to eq([])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "holds export attributes" do
|
|
18
|
+
attr = Lutaml::Lml::TopElementAttribute.new(name: "file", value: "out.xml")
|
|
19
|
+
exp = described_class.new(format_type: "xml", attributes: [attr])
|
|
20
|
+
expect(exp.attributes.length).to eq(1)
|
|
21
|
+
expect(exp.attributes.first.name).to eq("file")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::InstancesImport do
|
|
7
|
+
it "has format_type and file attributes" do
|
|
8
|
+
imp = described_class.new(format_type: "xml", file: "data/products.xml")
|
|
9
|
+
expect(imp.format_type).to eq("xml")
|
|
10
|
+
expect(imp.file).to eq("data/products.xml")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "holds attributes as TopElementAttribute collection" do
|
|
14
|
+
attrs = [
|
|
15
|
+
Lutaml::Lml::TopElementAttribute.new(name: "map_to", value: "Product"),
|
|
16
|
+
Lutaml::Lml::TopElementAttribute.new(name: "id", value: "product_id"),
|
|
17
|
+
]
|
|
18
|
+
imp = described_class.new(format_type: "csv", attributes: attrs)
|
|
19
|
+
expect(imp.attributes.length).to eq(2)
|
|
20
|
+
expect(imp.attributes[0].name).to eq("map_to")
|
|
21
|
+
expect(imp.attributes[1].name).to eq("id")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "defaults to empty attributes" do
|
|
25
|
+
imp = described_class.new(format_type: "csv")
|
|
26
|
+
expect(imp.attributes).to eq([])
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::Package do
|
|
7
|
+
describe "attribute definitions" do
|
|
8
|
+
it "has name attribute" do
|
|
9
|
+
pkg = described_class.new(name: "Core")
|
|
10
|
+
expect(pkg.name).to eq("Core")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "has default visibility" do
|
|
14
|
+
pkg = described_class.new
|
|
15
|
+
expect(pkg.visibility).to eq("public")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "has empty collections by default" do
|
|
19
|
+
pkg = described_class.new
|
|
20
|
+
expect(pkg.classes).to eq([])
|
|
21
|
+
expect(pkg.enums).to eq([])
|
|
22
|
+
expect(pkg.data_types).to eq([])
|
|
23
|
+
expect(pkg.packages).to eq([])
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::PrimitiveType do
|
|
7
|
+
describe "attribute definitions" do
|
|
8
|
+
it "has name attribute" do
|
|
9
|
+
pt = described_class.new(name: "Integer")
|
|
10
|
+
expect(pt.name).to eq("Integer")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "has default keyword" do
|
|
14
|
+
pt = described_class.new
|
|
15
|
+
expect(pt.keyword).to eq("primitive")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "has default visibility" do
|
|
19
|
+
pt = described_class.new
|
|
20
|
+
expect(pt.visibility).to eq("public")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "has default is_abstract" do
|
|
24
|
+
pt = described_class.new
|
|
25
|
+
expect(pt.is_abstract).to be(false)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe ".entity_type" do
|
|
30
|
+
it "returns :primitives" do
|
|
31
|
+
expect(described_class.entity_type).to eq(:primitives)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::TopElementAttribute do
|
|
7
|
+
describe "inheritance" do
|
|
8
|
+
it "inherits from Lutaml::Model::Serializable" do
|
|
9
|
+
expect(described_class).to be < Lutaml::Model::Serializable
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "extended attributes" do
|
|
14
|
+
it "has properties collection" do
|
|
15
|
+
attr = described_class.new
|
|
16
|
+
expect(attr.properties).to eq([])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "defaults value to nil" do
|
|
20
|
+
attr = described_class.new
|
|
21
|
+
expect(attr.value).to be_nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "has attributes collection" do
|
|
25
|
+
attr = described_class.new
|
|
26
|
+
expect(attr.attributes).to eq([])
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "has extended boolean" do
|
|
30
|
+
attr = described_class.new
|
|
31
|
+
expect(attr.extended).to be_nil
|
|
32
|
+
attr.extended = true
|
|
33
|
+
expect(attr.extended).to be(true)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "has instances collection" do
|
|
37
|
+
attr = described_class.new
|
|
38
|
+
expect(attr.instances).to eq([])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "with nested properties" do
|
|
43
|
+
it "holds nested TopElementAttribute as properties" do
|
|
44
|
+
prop = described_class.new(name: "description", value: "A description")
|
|
45
|
+
attr = described_class.new(name: "dev_id", type: "String", properties: [prop])
|
|
46
|
+
expect(attr.properties.first.name).to eq("description")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "key_value mapping" do
|
|
51
|
+
# Declaring a mapping block replaces the defaults, so an attribute added
|
|
52
|
+
# later is silently dropped from every key-value format unless it is also
|
|
53
|
+
# mapped. This is the guard for that.
|
|
54
|
+
# Each format builds its own mapping object from the one block, so every
|
|
55
|
+
# format is checked rather than trusting YAML to stand for the rest.
|
|
56
|
+
Lutaml::Model::FormatRegistry.key_value_formats.each do |format|
|
|
57
|
+
it "maps every declared attribute for #{format}" do
|
|
58
|
+
mapped = described_class.mappings_for(format).mappings.map(&:to)
|
|
59
|
+
|
|
60
|
+
expect(mapped.sort).to eq(described_class.attributes.keys.sort)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "maps each attribute under its own name for #{format}" do
|
|
64
|
+
described_class.mappings_for(format).mappings.each do |rule|
|
|
65
|
+
expect(rule.name).to eq(rule.to.to_s)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "attribute value round trip" do
|
|
72
|
+
def unwrap(value)
|
|
73
|
+
return value.map { |item| unwrap(item) } if value.is_a?(Array)
|
|
74
|
+
|
|
75
|
+
value.is_a?(Lutaml::Lml::LiteralValue) ? value.value : value
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def round_trip(name, body, format)
|
|
79
|
+
lml = "instances {\n Product \"p\" {\n #{body}\n }\n}\n"
|
|
80
|
+
doc = Lutaml::Lml::Pipeline.call(StringIO.new(lml))
|
|
81
|
+
reloaded = Lutaml::Lml::Document.public_send(
|
|
82
|
+
:"from_#{format}", doc.public_send(:"to_#{format}")
|
|
83
|
+
)
|
|
84
|
+
attr = reloaded.instances.instances.first.attributes.find { |a| a.name == name }
|
|
85
|
+
raise "no attribute named #{name.inspect}" unless attr
|
|
86
|
+
|
|
87
|
+
unwrap(attr.value)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# A map literal's value can only be boolean | reference | range | number |
|
|
91
|
+
# quoted_string (grammar `key_value_pair` -> `value`). One row per shape,
|
|
92
|
+
# because a corpus that stops one shape short is how the list case survived.
|
|
93
|
+
#
|
|
94
|
+
# Note the range row expects string bounds while the integer row expects a
|
|
95
|
+
# real Integer: range endpoints come off the parser as text and are never
|
|
96
|
+
# coerced. That asymmetry is the parser's, and these rows pin it.
|
|
97
|
+
{
|
|
98
|
+
"string" => ['id = "component_id"', { id: "component_id" }],
|
|
99
|
+
"single-quoted" => ["id = 'component_id'", { id: "component_id" }],
|
|
100
|
+
"boolean" => ["flag = true", { flag: true }],
|
|
101
|
+
"integer" => ["n = 42", { n: 42 }],
|
|
102
|
+
"float" => ["f = 1.5", { f: 1.5 }],
|
|
103
|
+
"reference" => ["r = reference:(Product.id)", { r: { reference: "Product.id" } }],
|
|
104
|
+
"range" => ["r = 1..9", { r: { range: { start: "1", end: "9" } } }],
|
|
105
|
+
"no-equals pair" => ['id "component_id"', { id: "component_id" }],
|
|
106
|
+
}.each do |shape, (pair, expected)|
|
|
107
|
+
it "reloads a map value with a #{shape} through YAML" do
|
|
108
|
+
body = "columns {\n #{pair}\n }"
|
|
109
|
+
expect(round_trip("columns", body, :yaml)).to eq(expected)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# The defect this change fixes: these raised CollectionTrueMissingError out
|
|
114
|
+
# of Document.from_yaml, which is the CLI's `-i yaml` input path.
|
|
115
|
+
reload_formats = %i[yaml json].freeze
|
|
116
|
+
{
|
|
117
|
+
"strings" => ['tags = ["a", "b"]', ["a", "b"]],
|
|
118
|
+
"mixed scalar types" => ['tags = ["a", 1, true]', ["a", 1, true]],
|
|
119
|
+
"one element" => ['tags = ["only"]', ["only"]],
|
|
120
|
+
}.each do |shape, (body, expected)|
|
|
121
|
+
reload_formats.each do |format|
|
|
122
|
+
it "reloads a list of #{shape} through #{format.upcase}" do
|
|
123
|
+
expect(round_trip("tags", body, format)).to eq(expected)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "reloads a list of references through YAML" do
|
|
129
|
+
expect(round_trip("tags", "tags = [reference:(A.b)]", :yaml))
|
|
130
|
+
.to eq([{ reference: "A.b" }])
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# lutaml-model#746 fixed the present? gate: custom from methods now
|
|
134
|
+
# receive empty values, so an empty sequence survives as a present
|
|
135
|
+
# (non-nil) value.
|
|
136
|
+
it "preserves an empty list" do
|
|
137
|
+
expect(round_trip("tags", "tags = []", :yaml)).to eq([])
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "keeps a false literal, which is not the same as an absent value" do
|
|
141
|
+
expect(round_trip("flag", "flag = false", :yaml)).to be(false)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Asserts the absence of the key, not the absence of the text. An attribute
|
|
145
|
+
# whose name merely contains "value" would defeat a substring check while
|
|
146
|
+
# the guard is working perfectly.
|
|
147
|
+
it "omits the value key entirely when there is no value" do
|
|
148
|
+
attr = described_class.new(name: "value_kind", type: "ValidationCheck")
|
|
149
|
+
|
|
150
|
+
expect(YAML.safe_load(attr.to_yaml)).not_to have_key("value")
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require_relative "../../../lml_spec_setup"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Lml::UmlClass do
|
|
7
|
+
describe "attribute definitions" do
|
|
8
|
+
it "has name attribute" do
|
|
9
|
+
klass = described_class.new(name: "Widget")
|
|
10
|
+
expect(klass.name).to eq("Widget")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "has default visibility" do
|
|
14
|
+
klass = described_class.new
|
|
15
|
+
expect(klass.visibility).to eq("public")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "has default is_abstract" do
|
|
19
|
+
klass = described_class.new
|
|
20
|
+
expect(klass.is_abstract).to be(false)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "has collection attributes with defaults" do
|
|
24
|
+
klass = described_class.new
|
|
25
|
+
expect(klass.stereotype).to eq([])
|
|
26
|
+
expect(klass.nested_classifier).to eq([])
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe ".entity_type" do
|
|
31
|
+
it "returns :classes" do
|
|
32
|
+
expect(described_class.entity_type).to eq(:classes)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe "YAML serialization" do
|
|
37
|
+
let(:klass) do
|
|
38
|
+
described_class.new(
|
|
39
|
+
name: "Person",
|
|
40
|
+
definition: "A human being",
|
|
41
|
+
is_abstract: true,
|
|
42
|
+
stereotype: ["entity"],
|
|
43
|
+
attributes: [
|
|
44
|
+
Lutaml::Lml::TopElementAttribute.new(name: "name", type: "String"),
|
|
45
|
+
Lutaml::Lml::TopElementAttribute.new(name: "age", type: "Integer"),
|
|
46
|
+
],
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "round-trips through YAML" do
|
|
51
|
+
yaml = klass.to_yaml
|
|
52
|
+
restored = described_class.from_yaml(yaml)
|
|
53
|
+
expect(restored.name).to eq("Person")
|
|
54
|
+
expect(restored.is_abstract).to be(true)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "infers owner_end in associations from_yaml" do
|
|
58
|
+
yaml = <<~YAML
|
|
59
|
+
name: Order
|
|
60
|
+
associations:
|
|
61
|
+
- name: items
|
|
62
|
+
member_end: LineItem
|
|
63
|
+
YAML
|
|
64
|
+
|
|
65
|
+
restored = described_class.from_yaml(yaml)
|
|
66
|
+
expect(restored.associations.length).to eq(1)
|
|
67
|
+
expect(restored.associations[0].owner_end).to eq("Order")
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe "models version declaration (issue #16)" do
|
|
6
|
+
it "captures the header version on the document" do
|
|
7
|
+
doc = Lutaml::Lml.parse_document(StringIO.new(<<~LML))
|
|
8
|
+
models PubidModels version "1.0.0" {
|
|
9
|
+
class IsoIdentifier { }
|
|
10
|
+
}
|
|
11
|
+
LML
|
|
12
|
+
expect(doc.model_versions).to eq("PubidModels" => "1.0.0")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "defaults to an empty version map without the declaration" do
|
|
16
|
+
doc = Lutaml::Lml.parse_document(StringIO.new("models M {\n class C { }\n}\n"))
|
|
17
|
+
expect(doc.model_versions).to eq({})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "records each models block separately" do
|
|
21
|
+
doc = Lutaml::Lml.parse_document(StringIO.new(<<~LML))
|
|
22
|
+
models A version "1.0.0" { class C1 { } }
|
|
23
|
+
models B version "2.0.0" { class C2 { } }
|
|
24
|
+
LML
|
|
25
|
+
expect(doc.model_versions).to eq("A" => "1.0.0", "B" => "2.0.0")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe "Class operations" do
|
|
6
|
+
def parse(src)
|
|
7
|
+
Lutaml::Lml.parse_document(StringIO.new(src))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:doc) do
|
|
11
|
+
parse(<<~LML)
|
|
12
|
+
class Ceramic {
|
|
13
|
+
+ getGlazeType(glazeCode: CharacterString = "123"): GlazeType[1..*] {ordered, unique, query}
|
|
14
|
+
- simpleOp(): String
|
|
15
|
+
op2()
|
|
16
|
+
multi(a: String, b: Integer = 5, in c: Boolean)
|
|
17
|
+
}
|
|
18
|
+
LML
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "parses operations onto the class" do
|
|
22
|
+
ops = doc.classes.first.operations
|
|
23
|
+
expect(ops.map(&:name)).to eq(%w[getGlazeType simpleOp op2 multi])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "maps symbol visibility prefixes" do
|
|
27
|
+
ops = doc.classes.first.operations
|
|
28
|
+
expect(ops.map(&:visibility)).to eq(%w[public private public public])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "captures the return type and property list" do
|
|
32
|
+
op = doc.classes.first.operations.first
|
|
33
|
+
expect(op.return_type).to eq("GlazeType")
|
|
34
|
+
expect(op.stereotype).to eq(%w[ordered unique query])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "captures parameters with types, defaults and directions" do
|
|
38
|
+
op = doc.classes.first.operations.first
|
|
39
|
+
expect(op.owned_parameter.map(&:name)).to eq(["glazeCode"])
|
|
40
|
+
expect(op.owned_parameter.first.type).to eq("CharacterString")
|
|
41
|
+
expect(op.owned_parameter.first.default).to eq("123")
|
|
42
|
+
multi = doc.classes.first.operations.last
|
|
43
|
+
expect(multi.owned_parameter.map { |p| [p.name, p.type, p.default, p.direction] })
|
|
44
|
+
.to eq([["a", "String", nil, "in"],
|
|
45
|
+
["b", "Integer", "5", "in"],
|
|
46
|
+
["c", "Boolean", nil, "in"]])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "coexists with attributes in one class body" do
|
|
50
|
+
doc = parse(<<~LML)
|
|
51
|
+
class Widget {
|
|
52
|
+
attribute code, String
|
|
53
|
+
+ calc(x: Integer): Integer
|
|
54
|
+
}
|
|
55
|
+
LML
|
|
56
|
+
expect(doc.classes.first.attributes.map(&:name)).to eq(["code"])
|
|
57
|
+
expect(doc.classes.first.operations.map(&:name)).to eq(["calc"])
|
|
58
|
+
end
|
|
59
|
+
end
|