lutaml-model 0.8.186 → 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.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-repos-tools-informational.json +8 -0
  3. data/.github/workflows/dependent-repos-tools.json +1 -5
  4. data/.github/workflows/dependent-tests.yml +26 -2
  5. data/Gemfile +2 -0
  6. data/Rakefile +6 -0
  7. data/exe/lutaml-lml-lsp +11 -0
  8. data/lib/compat/opal/generate_boot.rb +12 -5
  9. data/lib/compat/opal/lutaml_model_boot.rb +96 -4
  10. data/lib/lutaml/lml/association_label_resolver.rb +52 -0
  11. data/lib/lutaml/lml/data_processor/attribute_processing.rb +133 -0
  12. data/lib/lutaml/lml/data_processor/collection_processing.rb +37 -0
  13. data/lib/lutaml/lml/data_processor/instance_processing.rb +77 -0
  14. data/lib/lutaml/lml/data_processor/value_declaration_processing.rb +70 -0
  15. data/lib/lutaml/lml/data_processor/value_processing.rb +103 -0
  16. data/lib/lutaml/lml/data_processor/view_processing.rb +26 -0
  17. data/lib/lutaml/lml/data_processor.rb +66 -0
  18. data/lib/lutaml/lml/diagnostic.rb +149 -0
  19. data/lib/lutaml/lml/document_builder.rb +486 -0
  20. data/lib/lutaml/lml/entity_types.rb +31 -0
  21. data/lib/lutaml/lml/executor/adapter_helpers.rb +45 -0
  22. data/lib/lutaml/lml/executor/condition_evaluator.rb +175 -0
  23. data/lib/lutaml/lml/executor/csv_adapter.rb +89 -0
  24. data/lib/lutaml/lml/executor/format_adapter.rb +54 -0
  25. data/lib/lutaml/lml/executor/xml_adapter.rb +102 -0
  26. data/lib/lutaml/lml/executor.rb +96 -0
  27. data/lib/lutaml/lml/format/adapter/document.rb +11 -0
  28. data/lib/lutaml/lml/format/adapter/mapping.rb +31 -0
  29. data/lib/lutaml/lml/format/adapter/standard_adapter.rb +164 -0
  30. data/lib/lutaml/lml/format/adapter/transform.rb +11 -0
  31. data/lib/lutaml/lml/format.rb +34 -0
  32. data/lib/lutaml/lml/formatter/base.rb +81 -0
  33. data/lib/lutaml/lml/formatter/canonical.rb +738 -0
  34. data/lib/lutaml/lml/formatter.rb +11 -0
  35. data/lib/lutaml/lml/grammar/lml.artifact.json +14993 -0
  36. data/lib/lutaml/lml/grammar/lml.parg +389 -0
  37. data/lib/lutaml/lml/grammar.rb +60 -0
  38. data/lib/lutaml/lml/has_attributes.rb +14 -0
  39. data/lib/lutaml/lml/import_resolver.rb +96 -0
  40. data/lib/lutaml/lml/layout/engine.rb +17 -0
  41. data/lib/lutaml/lml/layout.rb +9 -0
  42. data/lib/lutaml/lml/literal_value.rb +32 -0
  43. data/lib/lutaml/lml/lsp/conversions.rb +78 -0
  44. data/lib/lutaml/lml/lsp/keywords.rb +43 -0
  45. data/lib/lutaml/lml/lsp/server.rb +380 -0
  46. data/lib/lutaml/lml/lsp/store.rb +68 -0
  47. data/lib/lutaml/lml/lsp/transport.rb +53 -0
  48. data/lib/lutaml/lml/lsp.rb +16 -0
  49. data/lib/lutaml/lml/model_compiler/enums.rb +170 -0
  50. data/lib/lutaml/lml/model_compiler/hydration.rb +122 -0
  51. data/lib/lutaml/lml/model_compiler/serialization_mappings.rb +188 -0
  52. data/lib/lutaml/lml/model_compiler/string_formats.rb +42 -0
  53. data/lib/lutaml/lml/model_compiler/validation.rb +65 -0
  54. data/lib/lutaml/lml/model_compiler.rb +329 -0
  55. data/lib/lutaml/lml/models/action.rb +10 -0
  56. data/lib/lutaml/lml/models/association.rb +31 -0
  57. data/lib/lutaml/lml/models/cardinality.rb +10 -0
  58. data/lib/lutaml/lml/models/collection.rb +11 -0
  59. data/lib/lutaml/lml/models/constraint.rb +25 -0
  60. data/lib/lutaml/lml/models/data_type.rb +43 -0
  61. data/lib/lutaml/lml/models/derived_field.rb +14 -0
  62. data/lib/lutaml/lml/models/diagram.rb +22 -0
  63. data/lib/lutaml/lml/models/document.rb +86 -0
  64. data/lib/lutaml/lml/models/enum.rb +40 -0
  65. data/lib/lutaml/lml/models/fidelity.rb +10 -0
  66. data/lib/lutaml/lml/models/group.rb +11 -0
  67. data/lib/lutaml/lml/models/instance.rb +28 -0
  68. data/lib/lutaml/lml/models/instance_collection.rb +18 -0
  69. data/lib/lutaml/lml/models/instances_export.rb +10 -0
  70. data/lib/lutaml/lml/models/instances_import.rb +11 -0
  71. data/lib/lutaml/lml/models/mapping.rb +15 -0
  72. data/lib/lutaml/lml/models/mapping_rule.rb +16 -0
  73. data/lib/lutaml/lml/models/member_field.rb +16 -0
  74. data/lib/lutaml/lml/models/namespace.rb +18 -0
  75. data/lib/lutaml/lml/models/operation.rb +28 -0
  76. data/lib/lutaml/lml/models/operation_parameter.rb +12 -0
  77. data/lib/lutaml/lml/models/package.rb +28 -0
  78. data/lib/lutaml/lml/models/primitive_type.rb +35 -0
  79. data/lib/lutaml/lml/models/reference.rb +23 -0
  80. data/lib/lutaml/lml/models/serialization_mapping.rb +21 -0
  81. data/lib/lutaml/lml/models/string_format.rb +16 -0
  82. data/lib/lutaml/lml/models/top_element_attribute.rb +118 -0
  83. data/lib/lutaml/lml/models/uml_class.rb +87 -0
  84. data/lib/lutaml/lml/models/value.rb +17 -0
  85. data/lib/lutaml/lml/models/view_filter.rb +11 -0
  86. data/lib/lutaml/lml/models/view_import.rb +11 -0
  87. data/lib/lutaml/lml/parser.rb +19 -0
  88. data/lib/lutaml/lml/pipeline.rb +73 -0
  89. data/lib/lutaml/lml/positioned.rb +13 -0
  90. data/lib/lutaml/lml/preprocessor.rb +132 -0
  91. data/lib/lutaml/lml/quoting.rb +60 -0
  92. data/lib/lutaml/lml/source.rb +49 -0
  93. data/lib/lutaml/lml/source_position.rb +20 -0
  94. data/lib/lutaml/lml/symbol_index.rb +202 -0
  95. data/lib/lutaml/lml/transform.rb +119 -0
  96. data/lib/lutaml/lml/types/text_type.rb +28 -0
  97. data/lib/lutaml/lml/types.rb +10 -0
  98. data/lib/lutaml/lml/validator.rb +460 -0
  99. data/lib/lutaml/lml/view_resolution.rb +32 -0
  100. data/lib/lutaml/lml/view_resolver.rb +48 -0
  101. data/lib/lutaml/lml/yaml_parser.rb +17 -0
  102. data/lib/lutaml/lml.rb +130 -0
  103. data/lib/lutaml/model/adapter_resolver.rb +21 -2
  104. data/lib/lutaml/model/config.rb +22 -0
  105. data/lib/lutaml/model/serialize/format_conversion.rb +8 -6
  106. data/lib/lutaml/model/version.rb +1 -1
  107. data/lib/lutaml/xml/adapter/base_adapter.rb +26 -0
  108. data/lib/lutaml/xml/adapter/moxml_adapter.rb +49 -0
  109. data/lib/lutaml/xml/adapter/xml_parser.rb +4 -4
  110. data/lib/lutaml/xml/adapter/xml_serializer.rb +1 -1
  111. data/lib/lutaml/xml/adapter.rb +5 -0
  112. data/lib/lutaml/xml/adapter_loader.rb +5 -0
  113. data/lib/lutaml/xml/format.rb +23 -2
  114. data/lib/lutaml/xml/leptris/native_emission.rb +6 -1
  115. data/lib/lutaml/xml/leptris/plan_serializer.rb +5 -1
  116. data/lib/lutaml/xml/parse_session.rb +8 -1
  117. data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
  118. data/lib/lutaml/xml/schema/builder.rb +1 -1
  119. data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
  120. data/lib/lutaml/xml/schema/vc_namespace.rb +24 -0
  121. data/lib/lutaml/xml/schema/xsd/any.rb +4 -0
  122. data/lib/lutaml/xml/schema/xsd/any_attribute.rb +4 -0
  123. data/lib/lutaml/xml/schema/xsd/base.rb +7 -0
  124. data/lib/lutaml/xml/schema/xsd/open_content.rb +2 -0
  125. data/lib/lutaml/xml/schema/xsd/restriction_simple_type.rb +3 -0
  126. data/lib/lutaml/xml/schema/xsd/schema.rb +38 -0
  127. data/lib/lutaml/xml/schema/xsd/schema_validator.rb +1 -1
  128. data/lib/lutaml/xml/schema/xsd.rb +1 -0
  129. data/lib/lutaml/xml/schema/xsd_schema.rb +1 -1
  130. data/lib/lutaml/xml/serialization/format_conversion.rb +6 -0
  131. data/lib/lutaml/xml/xsd_validator.rb +1 -1
  132. data/lutaml-model.gemspec +2 -0
  133. data/spec/lml/fixtures/dsl/broken_diagram.lutaml +34 -0
  134. data/spec/lml/fixtures/dsl/diagram.lutaml +4 -0
  135. data/spec/lml/fixtures/dsl/diagram_attributes.lutaml +6 -0
  136. data/spec/lml/fixtures/dsl/diagram_blank_definion.lutaml +6 -0
  137. data/spec/lml/fixtures/dsl/diagram_blank_entities.lutaml +8 -0
  138. data/spec/lml/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
  139. data/spec/lml/fixtures/dsl/diagram_class_fields.lutaml +25 -0
  140. data/spec/lml/fixtures/dsl/diagram_commented_includes.lutaml +5 -0
  141. data/spec/lml/fixtures/dsl/diagram_comments.lutaml +28 -0
  142. data/spec/lml/fixtures/dsl/diagram_concept_model.lutaml +132 -0
  143. data/spec/lml/fixtures/dsl/diagram_data_types.lutaml +44 -0
  144. data/spec/lml/fixtures/dsl/diagram_definitions.lutaml +25 -0
  145. data/spec/lml/fixtures/dsl/diagram_includes.lutaml +6 -0
  146. data/spec/lml/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
  147. data/spec/lml/fixtures/dsl/diagram_non_existing_include.lutaml +6 -0
  148. data/spec/lml/fixtures/dsl/shared.lutaml +5 -0
  149. data/spec/lml/fixtures/dsl/shared1.lutaml +4 -0
  150. data/spec/lml/fixtures/generated_dot/AddressClassProfile.dot +170 -0
  151. data/spec/lml/fixtures/generated_dot/AddressProfile.dot +34 -0
  152. data/spec/lml/fixtures/generated_dot/address_class_profile_with_associations.dot +127 -0
  153. data/spec/lml/fixtures/generated_dot/address_profile_with_associations.dot +28 -0
  154. data/spec/lml/fixtures/generated_dot/document.dot +28 -0
  155. data/spec/lml/fixtures/generated_dot/document.dot.backup +33 -0
  156. data/spec/lml/fixtures/generated_dot/document_with_fidelity.dot +27 -0
  157. data/spec/lml/fixtures/lml/data_s102_check.lml +79 -0
  158. data/spec/lml/fixtures/lml/data_s158_metadata.lml +28 -0
  159. data/spec/lml/fixtures/lml/iho_data_models.lml +59 -0
  160. data/spec/lml/fixtures/lml/iho_s102_check.lml +101 -0
  161. data/spec/lml/fixtures/mixed_lml/diagram.lml +26 -0
  162. data/spec/lml/fixtures/mixed_lml/instances.lml +72 -0
  163. data/spec/lml/fixtures/mixed_lml/model.lml +30 -0
  164. data/spec/lml/fixtures/real_world/basicdoc-models/AdmonitionType.lutaml +32 -0
  165. data/spec/lml/fixtures/real_world/basicdoc-models/BasicBlock.lutaml +11 -0
  166. data/spec/lml/fixtures/real_world/basicdoc-models/BasicDocument.lutaml +41 -0
  167. data/spec/lml/fixtures/real_world/basicdoc-models/BasicSection.lutaml +38 -0
  168. data/spec/lml/fixtures/real_world/basicdoc-models/BibliographicItem.lutaml +6 -0
  169. data/spec/lml/fixtures/real_world/basicdoc-models/FigureBlock.lutaml +65 -0
  170. data/spec/lml/fixtures/real_world/basicdoc-models/FormattedString.lutaml +12 -0
  171. data/spec/lml/fixtures/real_world/basicdoc-models/List.lutaml +12 -0
  172. data/spec/lml/fixtures/real_world/basicdoc-models/OrderedListType.lutaml +32 -0
  173. data/spec/lml/fixtures/real_world/basicdoc-models/Signature.lutaml +22 -0
  174. data/spec/lml/fixtures/real_world/basicdoc-models/String.lutaml +2 -0
  175. data/spec/lml/fixtures/real_world/basicdoc-models/TableBlock.lutaml +60 -0
  176. data/spec/lml/fixtures/real_world/basicdoc-models/TextElement.lutaml +13 -0
  177. data/spec/lml/fixtures/real_world/basicdoc-models/Uri.lutaml +7 -0
  178. data/spec/lml/fixtures/real_world/metanorma-model-iso/BibliographicItem.lutaml +4 -0
  179. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoAdmonitionType.lutaml +31 -0
  180. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoBibDataExtensionType.lutaml +40 -0
  181. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoSections.lutaml +30 -0
  182. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoStandardDocument.lutaml +46 -0
  183. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoTerm.lutaml +20 -0
  184. data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardBibDataExtensionType.lutaml +2 -0
  185. data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardDocument.lutaml +2 -0
  186. data/spec/lml/fixtures/rs3001/01_class_tail_comment.lml +5 -0
  187. data/spec/lml/fixtures/rs3001/02_definition_block.lml +9 -0
  188. data/spec/lml/fixtures/rs3001/03_package_ceramics.lml +20 -0
  189. data/spec/lml/fixtures/rs3001/04_attribute_definition_form.lml +10 -0
  190. data/spec/lml/fixtures/rs3001/05_attribute_cardinality_unbounded.lml +10 -0
  191. data/spec/lml/fixtures/rs3001/06_attribute_values_set.lml +10 -0
  192. data/spec/lml/fixtures/rs3001/07_attribute_pattern.lml +10 -0
  193. data/spec/lml/fixtures/rs3001/08_attribute_default_colon.lml +15 -0
  194. data/spec/lml/fixtures/rs3001/09_value_porcelain.lml +9 -0
  195. data/spec/lml/fixtures/rs3001/10_enum_glaze_technique.lml +19 -0
  196. data/spec/lml/fixtures/rs3001/11_enum_values_as_instances.lml +29 -0
  197. data/spec/lml/fixtures/rs3001/12_instance_named.lml +13 -0
  198. data/spec/lml/fixtures/rs3001/13_instances_collection_refs.lml +11 -0
  199. data/spec/lml/fixtures/rs3001/14_require_models.lml +7 -0
  200. data/spec/lml/fixtures/rs3001/15_comment_line.lml +1 -0
  201. data/spec/lml/fixtures/rs3001/16_comment_tail.lml +5 -0
  202. data/spec/lml/fixtures/rs3001/17_comment_documented_class.lml +5 -0
  203. data/spec/lml/fixtures/rs3001/18_comment_block.lml +4 -0
  204. data/spec/lml/fixtures/rs3001/19_top_level_instance_definition.lml +21 -0
  205. data/spec/lml/fixtures/rs3001/20_instance_typed_definition.lml +22 -0
  206. data/spec/lml/fixtures/rs3001/21_instance_collection_studios.lml +19 -0
  207. data/spec/lml/fixtures/rs3001/22_instance_collection_tiles.lml +15 -0
  208. data/spec/lml/fixtures/rs3001/23_reference_cross_collection.lml +11 -0
  209. data/spec/lml/fixtures/rs3001/24_null_and_empty.lml +15 -0
  210. data/spec/lml/fixtures/rs3001/25_string_escapes.lml +23 -0
  211. data/spec/lml/fixtures/rs3001/26_quoted_keys.lml +7 -0
  212. data/spec/lml/fixtures/test.lutaml +20 -0
  213. data/spec/lml/fixtures/test_data/components.csv +4 -0
  214. data/spec/lml/fixtures/test_data/products.xml +18 -0
  215. data/spec/lml/fixtures/uml/address_class_profile_with_associations.yml +58 -0
  216. data/spec/lml/fixtures/uml/address_profile_with_associations.yml +31 -0
  217. data/spec/lml/fixtures/uml/association.yml +11 -0
  218. data/spec/lml/fixtures/uml/class.yml +28 -0
  219. data/spec/lml/fixtures/uml/data_type.yml +30 -0
  220. data/spec/lml/fixtures/uml/diagram.yml +7 -0
  221. data/spec/lml/fixtures/uml/document.yml +44 -0
  222. data/spec/lml/fixtures/uml/document_with_fidelity.yml +47 -0
  223. data/spec/lml/fixtures/uml/enum.yml +14 -0
  224. data/spec/lml/fixtures/uml/operation.yml +8 -0
  225. data/spec/lml/fixtures/uml/package.yml +10 -0
  226. data/spec/lml/fixtures/uml/top_element.yml +11 -0
  227. data/spec/lml/fixtures/uml/top_element_attribute.yml +10 -0
  228. data/spec/lml/fixtures/uml/trigger.yml +12 -0
  229. data/spec/lml/fixtures/uml/value.yml +8 -0
  230. data/spec/lml/fixtures/view/cycle_a.lutaml +3 -0
  231. data/spec/lml/fixtures/view/cycle_b.lutaml +3 -0
  232. data/spec/lml/fixtures/view/import_model.lutaml +3 -0
  233. data/spec/lml/fixtures/view/import_view.lutaml +3 -0
  234. data/spec/lml/fixtures/view/import_with_hide.lutaml +4 -0
  235. data/spec/lml/fixtures/view/import_with_show.lutaml +4 -0
  236. data/spec/lml/fixtures/view/models/bar.lutaml +3 -0
  237. data/spec/lml/fixtures/view/models/baz.lutaml +3 -0
  238. data/spec/lml/fixtures/view/models/foo.lutaml +4 -0
  239. data/spec/lml/integration/instance_import_export_spec.rb +102 -0
  240. data/spec/lml/lml_spec_setup.rb +25 -0
  241. data/spec/lml/lutaml/lml/association_label_resolver_spec.rb +139 -0
  242. data/spec/lml/lutaml/lml/data_processor_spec.rb +274 -0
  243. data/spec/lml/lutaml/lml/declarations_spec.rb +337 -0
  244. data/spec/lml/lutaml/lml/document_builder_registry_spec.rb +52 -0
  245. data/spec/lml/lutaml/lml/document_builder_spec.rb +99 -0
  246. data/spec/lml/lutaml/lml/element_visibility_spec.rb +128 -0
  247. data/spec/lml/lutaml/lml/entity_types_spec.rb +56 -0
  248. data/spec/lml/lutaml/lml/enum_spec.rb +77 -0
  249. data/spec/lml/lutaml/lml/executor/adapter_helpers_spec.rb +96 -0
  250. data/spec/lml/lutaml/lml/executor/condition_evaluator_spec.rb +393 -0
  251. data/spec/lml/lutaml/lml/executor/csv_adapter_spec.rb +151 -0
  252. data/spec/lml/lutaml/lml/executor/format_adapter_spec.rb +31 -0
  253. data/spec/lml/lutaml/lml/executor/xml_adapter_spec.rb +201 -0
  254. data/spec/lml/lutaml/lml/executor_spec.rb +71 -0
  255. data/spec/lml/lutaml/lml/format_adapter_spec.rb +272 -0
  256. data/spec/lml/lutaml/lml/format_autoload_spec.rb +31 -0
  257. data/spec/lml/lutaml/lml/grammar_spec.rb +581 -0
  258. data/spec/lml/lutaml/lml/has_attributes_spec.rb +54 -0
  259. data/spec/lml/lutaml/lml/import_resolver_spec.rb +116 -0
  260. data/spec/lml/lutaml/lml/instance_hydration_spec.rb +178 -0
  261. data/spec/lml/lutaml/lml/lsp/server_spec.rb +285 -0
  262. data/spec/lml/lutaml/lml/model_compiler_spec.rb +406 -0
  263. data/spec/lml/lutaml/lml/models/association_spec.rb +40 -0
  264. data/spec/lml/lutaml/lml/models/collection_spec.rb +27 -0
  265. data/spec/lml/lutaml/lml/models/data_type_spec.rb +34 -0
  266. data/spec/lml/lutaml/lml/models/diagram_spec.rb +18 -0
  267. data/spec/lml/lutaml/lml/models/document_spec.rb +64 -0
  268. data/spec/lml/lutaml/lml/models/enum_spec.rb +42 -0
  269. data/spec/lml/lutaml/lml/models/inheritance_spec.rb +77 -0
  270. data/spec/lml/lutaml/lml/models/instance_collection_spec.rb +62 -0
  271. data/spec/lml/lutaml/lml/models/instance_spec.rb +81 -0
  272. data/spec/lml/lutaml/lml/models/instances_export_spec.rb +23 -0
  273. data/spec/lml/lutaml/lml/models/instances_import_spec.rb +28 -0
  274. data/spec/lml/lutaml/lml/models/package_spec.rb +26 -0
  275. data/spec/lml/lutaml/lml/models/primitive_type_spec.rb +34 -0
  276. data/spec/lml/lutaml/lml/models/top_element_attribute_spec.rb +153 -0
  277. data/spec/lml/lutaml/lml/models/uml_class_spec.rb +70 -0
  278. data/spec/lml/lutaml/lml/models_version_spec.rb +27 -0
  279. data/spec/lml/lutaml/lml/operations_spec.rb +59 -0
  280. data/spec/lml/lutaml/lml/parser_spec.rb +348 -0
  281. data/spec/lml/lutaml/lml/pipeline_spec.rb +93 -0
  282. data/spec/lml/lutaml/lml/preprocessor_spec.rb +174 -0
  283. data/spec/lml/lutaml/lml/property_laws_spec.rb +344 -0
  284. data/spec/lml/lutaml/lml/real_world_spec.rb +191 -0
  285. data/spec/lml/lutaml/lml/reference_spec.rb +64 -0
  286. data/spec/lml/lutaml/lml/round_trip_spec.rb +457 -0
  287. data/spec/lml/lutaml/lml/rs3001_corpus_spec.rb +83 -0
  288. data/spec/lml/lutaml/lml/rs3001_syntax_spec.rb +77 -0
  289. data/spec/lml/lutaml/lml/serialization_mapping_spec.rb +127 -0
  290. data/spec/lml/lutaml/lml/source_spec.rb +62 -0
  291. data/spec/lml/lutaml/lml/transform_spec.rb +37 -0
  292. data/spec/lml/lutaml/lml/types/text_type_spec.rb +43 -0
  293. data/spec/lml/lutaml/lml/validator_spec.rb +238 -0
  294. data/spec/lml/lutaml/lml/view_resolver_spec.rb +78 -0
  295. data/spec/lml/lutaml/lml/view_spec.rb +112 -0
  296. data/spec/lml/lutaml/parsers/dsl_spec.rb +275 -0
  297. data/spec/lml/lutaml/parsers/yaml_spec.rb +52 -0
  298. data/spec/lml/lutaml/qualified_type_spec.rb +33 -0
  299. data/spec/lutaml/model/adapter_type_unset_restore_spec.rb +61 -0
  300. data/spec/lutaml/model/custom_bibtex_adapter_spec.rb +4 -1
  301. data/spec/lutaml/xml/adapter/moxml_lane_spec.rb +112 -0
  302. data/spec/lutaml/xml/adapter_metadata_default_spec.rb +21 -2
  303. data/spec/lutaml/xml/adapter_moxml_engine_spec.rb +57 -0
  304. data/spec/lutaml/xml/leptris/native_emission_plain_model_spec.rb +50 -0
  305. data/spec/lutaml/xml/plain_model_mapping_resolution_spec.rb +88 -0
  306. data/spec/lutaml/xml/schema/xsd/vc_versioning_spec.rb +49 -0
  307. data/spec/lutaml/xml/schema/xsd/xsd_11_constructs_spec.rb +83 -0
  308. 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 Lutaml::Lml::ModelCompiler do
7
+ let(:compiler) { described_class.new }
8
+ let(:model_input) do
9
+ <<~LML
10
+ models T {
11
+ enum Color {
12
+ red {
13
+ description "Red color"
14
+ }
15
+ blue {
16
+ description "Blue color"
17
+ }
18
+ }
19
+ class Item {
20
+ attribute color {
21
+ type Color
22
+ cardinality 1
23
+ }
24
+ }
25
+ }
26
+ LML
27
+ end
28
+ let(:compiled) do
29
+ require "tempfile"
30
+ file = Tempfile.new(["m", ".lml"])
31
+ file.write(model_input)
32
+ file.rewind
33
+ compiler.compile(file)
34
+ ensure
35
+ file.close!
36
+ end
37
+
38
+ it "exposes enum value names and descriptions" do
39
+ color = compiled["Color"]
40
+ expect(color.values.map(&:name)).to eq %w[red blue]
41
+ expect(color.values.map(&:description)).to eq ["Red color", "Blue color"]
42
+ end
43
+
44
+ it "builds enum instances carrying descriptions" do
45
+ color = compiled["Color"]
46
+ red = color.red
47
+ expect(red.value).to eq "red"
48
+ expect(red.description).to eq "Red color"
49
+ end
50
+
51
+ it "hydrates enum-typed attributes from bare and qualified values" do
52
+ compiled
53
+ data = Tempfile.new(["d", ".lml"])
54
+ data.write(<<~LML)
55
+ instance X {
56
+ isa Item
57
+ color = Color::red
58
+ }
59
+ LML
60
+ data.rewind
61
+ item = compiler.hydrate(data)
62
+ expect(item.color).to be_a(compiled["Color"])
63
+ expect(item.color.value).to eq "red"
64
+ expect(item.color.description).to eq "Red color"
65
+ ensure
66
+ data.close!
67
+ end
68
+
69
+ it "validates instances referencing qualified model types" do
70
+ compiler.compile(File.open("spec/lml/fixtures/lml/iho_s102_check.lml"))
71
+ errors = compiler.validate(
72
+ File.open("spec/lml/fixtures/lml/data_s102_check.lml"),
73
+ compiled: compiler.compiled_classes,
74
+ )
75
+ expect(errors).to be_empty
76
+ end
77
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+ require "lutaml/lml/executor"
6
+
7
+ # A lightweight Struct mirroring the TopElementAttribute interface
8
+ # (`.name` and `.value` accessors), so the helpers can be tested in
9
+ # isolation without coupling to model setup.
10
+ AdapterHelpersAttr = Struct.new(:name, :value, keyword_init: true)
11
+
12
+ RSpec.describe Lutaml::Lml::Executor::AdapterHelpers do
13
+ # Use a lightweight host class so we can test the helpers in isolation.
14
+ let(:host) do
15
+ Class.new do
16
+ extend Lutaml::Lml::Executor::AdapterHelpers
17
+ end
18
+ end
19
+
20
+ describe "#resolve_target_class" do
21
+ it "returns the compiled class named by the map_to attribute" do
22
+ compiled = { "Product" => String }
23
+ attributes = [AdapterHelpersAttr.new(name: "map_to", value: "Product")]
24
+ expect(host.resolve_target_class(attributes, compiled)).to eq(String)
25
+ end
26
+
27
+ it "returns nil when map_to is absent" do
28
+ compiled = { "Product" => String }
29
+ attributes = [AdapterHelpersAttr.new(name: "where", value: "/x")]
30
+ expect(host.resolve_target_class(attributes, compiled)).to be_nil
31
+ end
32
+
33
+ it "returns nil when the named class is not compiled" do
34
+ compiled = {}
35
+ attributes = [AdapterHelpersAttr.new(name: "map_to", value: "Missing")]
36
+ expect(host.resolve_target_class(attributes, compiled)).to be_nil
37
+ end
38
+
39
+ it "returns nil when attributes is nil" do
40
+ expect(host.resolve_target_class(nil, {})).to be_nil
41
+ end
42
+ end
43
+
44
+ describe "#attribute_value" do
45
+ it "returns the string value of the named attribute" do
46
+ attributes = [AdapterHelpersAttr.new(name: "where", value: "/Products/Product")]
47
+ expect(host.attribute_value(attributes, "where")).to eq("/Products/Product")
48
+ end
49
+
50
+ it "returns nil when the attribute is absent" do
51
+ attributes = [AdapterHelpersAttr.new(name: "other", value: "x")]
52
+ expect(host.attribute_value(attributes, "where")).to be_nil
53
+ end
54
+
55
+ it "returns nil when attributes is nil" do
56
+ expect(host.attribute_value(nil, "where")).to be_nil
57
+ end
58
+
59
+ it "stringifies non-string values" do
60
+ attributes = [AdapterHelpersAttr.new(name: "indent", value: true)]
61
+ expect(host.attribute_value(attributes, "indent")).to eq("true")
62
+ end
63
+ end
64
+
65
+ describe "#find_attribute" do
66
+ it "returns the matching attribute object" do
67
+ target = AdapterHelpersAttr.new(name: "where", value: "/x")
68
+ attributes = [AdapterHelpersAttr.new(name: "map_to", value: "X"), target]
69
+ expect(host.find_attribute(attributes, "where")).to eq(target)
70
+ end
71
+
72
+ it "returns nil when no match" do
73
+ attributes = [AdapterHelpersAttr.new(name: "map_to", value: "X")]
74
+ expect(host.find_attribute(attributes, "where")).to be_nil
75
+ end
76
+ end
77
+
78
+ describe "#find_class_for_instance" do
79
+ let(:product_class) { Class.new }
80
+ let(:order_class) { Class.new }
81
+ let(:compiled) do
82
+ { "Product" => product_class, "Order" => order_class }
83
+ end
84
+
85
+ it "returns [name, klass] for the matching class" do
86
+ instance = product_class.new
87
+ result = host.find_class_for_instance(instance, compiled)
88
+ expect(result).to eq(["Product", product_class])
89
+ end
90
+
91
+ it "returns nil when no class matches" do
92
+ instance = Object.new
93
+ expect(host.find_class_for_instance(instance, compiled)).to be_nil
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,393 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+ require "lutaml/lml/executor"
6
+
7
+ RSpec.describe Lutaml::Lml::Executor::ConditionEvaluator do
8
+ let(:item_class) { Struct.new(:id) }
9
+
10
+ describe ".evaluate" do
11
+ it "passes when count >= N is satisfied" do
12
+ collection = Lutaml::Lml::Collection.new(
13
+ name: "test",
14
+ validations: ["count >= 2"],
15
+ )
16
+ instances = [item_class.new(1), item_class.new(2)]
17
+ errors = described_class.evaluate(collection, instances)
18
+ expect(errors).to eq([])
19
+ end
20
+
21
+ it "fails when count >= N is not satisfied" do
22
+ collection = Lutaml::Lml::Collection.new(
23
+ name: "test",
24
+ validations: ["count >= 5"],
25
+ )
26
+ instances = [item_class.new(1), item_class.new(2)]
27
+ errors = described_class.evaluate(collection, instances)
28
+ expect(errors.length).to eq(1)
29
+ expect(errors.first).to include("count >= 5")
30
+ expect(errors.first).to include("got 2")
31
+ end
32
+
33
+ it "passes when count == N" do
34
+ collection = Lutaml::Lml::Collection.new(
35
+ name: "test",
36
+ validations: ["count == 3"],
37
+ )
38
+ instances = [item_class.new(1), item_class.new(2), item_class.new(3)]
39
+ errors = described_class.evaluate(collection, instances)
40
+ expect(errors).to eq([])
41
+ end
42
+
43
+ it "passes when count <= N" do
44
+ collection = Lutaml::Lml::Collection.new(
45
+ name: "test",
46
+ validations: ["count <= 10"],
47
+ )
48
+ instances = [item_class.new(1), item_class.new(2)]
49
+ errors = described_class.evaluate(collection, instances)
50
+ expect(errors).to eq([])
51
+ end
52
+
53
+ it "returns empty array when no validations" do
54
+ collection = Lutaml::Lml::Collection.new(name: "test")
55
+ errors = described_class.evaluate(collection, [])
56
+ expect(errors).to eq([])
57
+ end
58
+
59
+ it "raises for unsupported condition forms" do
60
+ collection = Lutaml::Lml::Collection.new(
61
+ name: "test",
62
+ validations: ["unknown_thing"],
63
+ )
64
+ errors = described_class.evaluate(collection, [])
65
+ expect(errors.length).to eq(1)
66
+ expect(errors.first).to include("Unsupported condition")
67
+ end
68
+ end
69
+
70
+ describe "block conditions (all?/any?)" do
71
+ let(:item_class) { Struct.new(:name, :components) }
72
+
73
+ it "passes when all instances satisfy the predicate" do
74
+ collection = Lutaml::Lml::Collection.new(
75
+ name: "test",
76
+ validations: ["all? { |i| i.components.count > 0 }"],
77
+ )
78
+ instances = [
79
+ item_class.new("A", [1]),
80
+ item_class.new("B", [1, 2]),
81
+ ]
82
+ errors = described_class.evaluate(collection, instances)
83
+ expect(errors).to eq([])
84
+ end
85
+
86
+ it "fails when any instance does not satisfy the predicate" do
87
+ collection = Lutaml::Lml::Collection.new(
88
+ name: "test",
89
+ validations: ["all? { |i| i.components.count > 0 }"],
90
+ )
91
+ instances = [
92
+ item_class.new("A", [1]),
93
+ item_class.new("B", []),
94
+ ]
95
+ errors = described_class.evaluate(collection, instances)
96
+ expect(errors.length).to eq(1)
97
+ expect(errors.first).to include("failed for at least one instance")
98
+ end
99
+
100
+ it "passes any? when at least one instance matches" do
101
+ collection = Lutaml::Lml::Collection.new(
102
+ name: "test",
103
+ validations: ['any? { |i| i.name == "B" }'],
104
+ )
105
+ instances = [
106
+ item_class.new("A", [1]),
107
+ item_class.new("B", [2]),
108
+ ]
109
+ errors = described_class.evaluate(collection, instances)
110
+ expect(errors).to eq([])
111
+ end
112
+
113
+ it "fails any? when no instances match" do
114
+ collection = Lutaml::Lml::Collection.new(
115
+ name: "test",
116
+ validations: ['any? { |i| i.name == "Z" }'],
117
+ )
118
+ instances = [item_class.new("A", [1]), item_class.new("B", [2])]
119
+ errors = described_class.evaluate(collection, instances)
120
+ expect(errors.length).to eq(1)
121
+ end
122
+
123
+ it "supports numeric, string, boolean, and nil literals" do
124
+ collection = Lutaml::Lml::Collection.new(
125
+ name: "test",
126
+ validations: [
127
+ "all? { |i| i.components.count >= 1 }",
128
+ 'all? { |i| i.name != "X" }',
129
+ ],
130
+ )
131
+ instances = [item_class.new("A", [1])]
132
+ errors = described_class.evaluate(collection, instances)
133
+ expect(errors).to eq([])
134
+ end
135
+
136
+ it "reports malformed block conditions" do
137
+ collection = Lutaml::Lml::Collection.new(
138
+ name: "test",
139
+ validations: ["all? { we fubar }"],
140
+ )
141
+ errors = described_class.evaluate(collection, [])
142
+ expect(errors.length).to eq(1)
143
+ expect(errors.first).to include("Invalid block condition")
144
+ end
145
+ end
146
+
147
+ describe "count comparison operators" do
148
+ it "passes when count > N is strictly satisfied" do
149
+ collection = Lutaml::Lml::Collection.new(
150
+ name: "test",
151
+ validations: ["count > 2"],
152
+ )
153
+ instances = [item_class.new(1), item_class.new(2), item_class.new(3)]
154
+ expect(described_class.evaluate(collection, instances)).to eq([])
155
+ end
156
+
157
+ it "fails when count > N is only equal" do
158
+ collection = Lutaml::Lml::Collection.new(
159
+ name: "test",
160
+ validations: ["count > 2"],
161
+ )
162
+ instances = [item_class.new(1), item_class.new(2)]
163
+ errors = described_class.evaluate(collection, instances)
164
+ expect(errors.length).to eq(1)
165
+ expect(errors.first).to include("count > 2")
166
+ end
167
+
168
+ it "passes when count < N" do
169
+ collection = Lutaml::Lml::Collection.new(
170
+ name: "test",
171
+ validations: ["count < 5"],
172
+ )
173
+ instances = [item_class.new(1), item_class.new(2)]
174
+ expect(described_class.evaluate(collection, instances)).to eq([])
175
+ end
176
+
177
+ it "fails when count < N is not satisfied" do
178
+ collection = Lutaml::Lml::Collection.new(
179
+ name: "test",
180
+ validations: ["count < 2"],
181
+ )
182
+ instances = [item_class.new(1), item_class.new(2), item_class.new(3)]
183
+ errors = described_class.evaluate(collection, instances)
184
+ expect(errors.length).to eq(1)
185
+ expect(errors.first).to include("count < 2")
186
+ end
187
+
188
+ it "raises Unsupported condition for count != N (! is not in count operator charset)" do
189
+ collection = Lutaml::Lml::Collection.new(
190
+ name: "test",
191
+ validations: ["count != 3"],
192
+ )
193
+ errors = described_class.evaluate(collection, [item_class.new(1)])
194
+ expect(errors.length).to eq(1)
195
+ expect(errors.first).to include("Unsupported condition")
196
+ end
197
+ end
198
+
199
+ describe "block comparison operators" do
200
+ let(:item_class) { Struct.new(:value) }
201
+
202
+ it "supports > strict greater-than" do
203
+ collection = Lutaml::Lml::Collection.new(
204
+ name: "test",
205
+ validations: ["all? { |i| i.value > 5 }"],
206
+ )
207
+ passing = [item_class.new(10), item_class.new(6)]
208
+ expect(described_class.evaluate(collection, passing)).to eq([])
209
+
210
+ failing = [item_class.new(5), item_class.new(10)]
211
+ expect(described_class.evaluate(collection, failing).length).to eq(1)
212
+ end
213
+
214
+ it "supports < strict less-than" do
215
+ collection = Lutaml::Lml::Collection.new(
216
+ name: "test",
217
+ validations: ["all? { |i| i.value < 100 }"],
218
+ )
219
+ passing = [item_class.new(1), item_class.new(99)]
220
+ expect(described_class.evaluate(collection, passing)).to eq([])
221
+
222
+ failing = [item_class.new(100), item_class.new(99)]
223
+ expect(described_class.evaluate(collection, failing).length).to eq(1)
224
+ end
225
+
226
+ it "supports <= less-than-or-equal" do
227
+ collection = Lutaml::Lml::Collection.new(
228
+ name: "test",
229
+ validations: ["all? { |i| i.value <= 10 }"],
230
+ )
231
+ passing = [item_class.new(10), item_class.new(5)]
232
+ expect(described_class.evaluate(collection, passing)).to eq([])
233
+ end
234
+
235
+ it "supports != not-equal" do
236
+ collection = Lutaml::Lml::Collection.new(
237
+ name: "test",
238
+ validations: ["all? { |i| i.value != 0 }"],
239
+ )
240
+ passing = [item_class.new(1), item_class.new(2)]
241
+ expect(described_class.evaluate(collection, passing)).to eq([])
242
+
243
+ failing = [item_class.new(0), item_class.new(2)]
244
+ expect(described_class.evaluate(collection, failing).length).to eq(1)
245
+ end
246
+ end
247
+
248
+ describe "literal types" do
249
+ let(:item_class) { Struct.new(:score, :label, :active, :parent) }
250
+
251
+ it "parses float literals" do
252
+ collection = Lutaml::Lml::Collection.new(
253
+ name: "test",
254
+ validations: ["all? { |i| i.score >= 1.5 }"],
255
+ )
256
+ instances = [item_class.new(2.0), item_class.new(1.5)]
257
+ expect(described_class.evaluate(collection, instances)).to eq([])
258
+ end
259
+
260
+ it "parses single-quoted string literals" do
261
+ collection = Lutaml::Lml::Collection.new(
262
+ name: "test",
263
+ validations: ["all? { |i| i.label == 'ready' }"],
264
+ )
265
+ instances = [item_class.new(nil, "ready"), item_class.new(nil, "ready")]
266
+ expect(described_class.evaluate(collection, instances)).to eq([])
267
+ end
268
+
269
+ it "parses true literal" do
270
+ collection = Lutaml::Lml::Collection.new(
271
+ name: "test",
272
+ validations: ["all? { |i| i.active == true }"],
273
+ )
274
+ instances = [item_class.new(nil, nil, true), item_class.new(nil, nil, true)]
275
+ expect(described_class.evaluate(collection, instances)).to eq([])
276
+ end
277
+
278
+ it "parses false literal" do
279
+ collection = Lutaml::Lml::Collection.new(
280
+ name: "test",
281
+ validations: ["all? { |i| i.active == false }"],
282
+ )
283
+ instances = [item_class.new(nil, nil, false)]
284
+ expect(described_class.evaluate(collection, instances)).to eq([])
285
+ end
286
+
287
+ it "parses nil literal" do
288
+ collection = Lutaml::Lml::Collection.new(
289
+ name: "test",
290
+ validations: ["all? { |i| i.parent == nil }"],
291
+ )
292
+ instances = [item_class.new(nil, nil, nil, nil)]
293
+ expect(described_class.evaluate(collection, instances)).to eq([])
294
+ end
295
+
296
+ it "parses null as an alias for nil" do
297
+ collection = Lutaml::Lml::Collection.new(
298
+ name: "test",
299
+ validations: ["all? { |i| i.parent == null }"],
300
+ )
301
+ instances = [item_class.new(nil, nil, nil, nil)]
302
+ expect(described_class.evaluate(collection, instances)).to eq([])
303
+ end
304
+
305
+ it "parses negative integer literals" do
306
+ collection = Lutaml::Lml::Collection.new(
307
+ name: "test",
308
+ validations: ["all? { |i| i.score > -1 }"],
309
+ )
310
+ instances = [item_class.new(0)]
311
+ expect(described_class.evaluate(collection, instances)).to eq([])
312
+ end
313
+ end
314
+
315
+ describe "nested attribute paths" do
316
+ let(:inner) { Struct.new(:name) }
317
+ let(:middle) { Struct.new(:inner) }
318
+ let(:outer) { Struct.new(:middle) }
319
+ let(:item_class) { Struct.new(:outer) }
320
+
321
+ it "walks i.outer.middle.inner.name" do
322
+ collection = Lutaml::Lml::Collection.new(
323
+ name: "test",
324
+ validations: ['all? { |i| i.outer.middle.inner.name == "leaf" }'],
325
+ )
326
+ instances = [
327
+ item_class.new(outer.new(middle.new(inner.new("leaf")))),
328
+ ]
329
+ expect(described_class.evaluate(collection, instances)).to eq([])
330
+ end
331
+
332
+ it "fails when a nested value does not match" do
333
+ collection = Lutaml::Lml::Collection.new(
334
+ name: "test",
335
+ validations: ['all? { |i| i.outer.middle.inner.name == "leaf" }'],
336
+ )
337
+ instances = [
338
+ item_class.new(outer.new(middle.new(inner.new("other")))),
339
+ ]
340
+ expect(described_class.evaluate(collection, instances).length).to eq(1)
341
+ end
342
+ end
343
+
344
+ describe "error paths" do
345
+ let(:item_class) { Struct.new(:value) }
346
+
347
+ it "raises Unsupported predicate when the operator is missing" do
348
+ collection = Lutaml::Lml::Collection.new(
349
+ name: "test",
350
+ validations: ['all? { |i| i.value "missing-op" }'],
351
+ )
352
+ errors = described_class.evaluate(collection, [item_class.new(1)])
353
+ expect(errors.length).to eq(1)
354
+ expect(errors.first).to include("Unsupported predicate")
355
+ end
356
+
357
+ it "raises Unsupported literal for bareword tokens" do
358
+ collection = Lutaml::Lml::Collection.new(
359
+ name: "test",
360
+ validations: ["all? { |i| i.value == bareword }"],
361
+ )
362
+ errors = described_class.evaluate(collection, [item_class.new(1)])
363
+ expect(errors.length).to eq(1)
364
+ expect(errors.first).to include("Unsupported literal")
365
+ end
366
+
367
+ it "raises when the block var is not i" do
368
+ collection = Lutaml::Lml::Collection.new(
369
+ name: "test",
370
+ validations: ["all? { |x| x.value > 5 }"],
371
+ )
372
+ errors = described_class.evaluate(collection, [item_class.new(10)])
373
+ expect(errors.length).to eq(1)
374
+ expect(errors.first).to include("must reference i")
375
+ end
376
+
377
+ # Object.new specifically: the type guard has to run before the
378
+ # validations call, so the argument must not respond to `validations`.
379
+ it "returns no errors for an argument that is not a Collection" do
380
+ expect(described_class.evaluate(Object.new, [])).to eq([])
381
+ end
382
+
383
+ it "rescues NoMethodError on undefined instance attributes" do
384
+ collection = Lutaml::Lml::Collection.new(
385
+ name: "test",
386
+ validations: ["all? { |i| i.missing_attribute == 1 }"],
387
+ )
388
+ errors = described_class.evaluate(collection, [item_class.new(1)])
389
+ expect(errors.length).to eq(1)
390
+ expect(errors.first).to include("failed for at least one instance")
391
+ end
392
+ end
393
+ end