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,457 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../lml_spec_setup"
5
+ require "tempfile"
6
+
7
+ RSpec.describe "Round-trip: class definitions and instances" do
8
+ def with_lml_file(content)
9
+ file = Tempfile.new(%w[test .lml])
10
+ file.write(content)
11
+ file.rewind
12
+ yield file
13
+ ensure
14
+ file.close!
15
+ end
16
+
17
+ describe "class definition round-trip" do
18
+ it "compiles a class, instantiates it, and the instance survives serialization" do
19
+ lml_models = <<~LML
20
+ models WidgetStore {
21
+ class Widget {
22
+ attribute name {
23
+ type String
24
+ cardinality 1
25
+ }
26
+ attribute weight {
27
+ type Float
28
+ cardinality 0..1
29
+ }
30
+ attribute tags {
31
+ type String
32
+ cardinality 0..n
33
+ }
34
+ }
35
+ }
36
+ LML
37
+
38
+ with_lml_file(lml_models) do |f|
39
+ compiled = Lutaml::Lml.compile(f)
40
+ widget_cls = compiled["Widget"]
41
+ obj = widget_cls.new(name: "Gear", weight: 3.14, tags: %w[metal heavy])
42
+ expect(obj.name).to eq("Gear")
43
+ expect(obj.weight).to eq(3.14)
44
+ expect(obj.tags).to eq(%w[metal heavy])
45
+ end
46
+ end
47
+
48
+ it "round-trips a compiled class with primitive attributes through to_lml/from_lml" do
49
+ require "lutaml/lml/format"
50
+
51
+ lml_models = <<~LML
52
+ models ProductStore {
53
+ class Product {
54
+ attribute sku {
55
+ type String
56
+ cardinality 1
57
+ }
58
+ attribute price {
59
+ type Float
60
+ cardinality 1
61
+ }
62
+ attribute discontinued {
63
+ type Boolean
64
+ cardinality 0..1
65
+ }
66
+ }
67
+ }
68
+ LML
69
+
70
+ with_lml_file(lml_models) do |f|
71
+ compiled = Lutaml::Lml.compile(f)
72
+ product_cls = compiled["Product"]
73
+
74
+ original = product_cls.new(sku: "ABC-123", price: 29.99, discontinued: false)
75
+ lml_text = original.to_lml
76
+ restored = product_cls.from_lml(lml_text)
77
+ expect(restored.sku).to eq("ABC-123")
78
+ expect(restored.price).to eq(29.99)
79
+ expect(restored.discontinued).to be(false)
80
+ end
81
+ end
82
+
83
+ # The emit side's quoting contract against the grammar's `word`
84
+ # rule: bare emission only for runs of [A-Za-z0-9_]; everything
85
+ # else must be quoted AND survive the parse back (values that the
86
+ # grammar cannot re-parse bare are quoted exactly so this
87
+ # round-trip holds).
88
+ describe "string quoting contract" do
89
+ require "lutaml/lml/format"
90
+
91
+ let(:lml_models) do
92
+ <<~LML
93
+ models QuoteStore {
94
+ class Quote {
95
+ attribute value { type String cardinality 1 }
96
+ }
97
+ }
98
+ LML
99
+ end
100
+
101
+ def round_trip(value)
102
+ with_lml_file(lml_models) do |f|
103
+ klass = Lutaml::Lml.compile(f)["Quote"]
104
+ klass.from_lml(klass.new(value: value).to_lml).value
105
+ end
106
+ end
107
+
108
+ { "bare words stay bare": %w[gear ABC123 v2_1 x42],
109
+ "non-word values are quoted and re-parsed":
110
+ ["ABC-123", "2012-03-15", "has space", "it's", 'he said "hi"', ""],
111
+ "escaped values round-trip":
112
+ ['Raku "kiln" fired', %(both " and '), "C:\\Users\\marie", "say \"hi\" and 'bye'"],
113
+ "quoted padding is content":
114
+ [" padded ", "left ", " right", " "] }.each do |label, values|
115
+ it "round-trips #{label}" do
116
+ values.each { |v| expect(round_trip(v)).to eq(v) }
117
+ end
118
+ end
119
+ end
120
+
121
+ it "compiles and instantiates nested classes" do
122
+ lml_models = <<~LML
123
+ models NestedStore {
124
+ class Address {
125
+ attribute city {
126
+ type String
127
+ cardinality 1
128
+ }
129
+ attribute country {
130
+ type String
131
+ cardinality 1
132
+ }
133
+ }
134
+ class Person {
135
+ attribute name {
136
+ type String
137
+ cardinality 1
138
+ }
139
+ attribute home {
140
+ type Address
141
+ cardinality 1
142
+ }
143
+ }
144
+ }
145
+ LML
146
+
147
+ with_lml_file(lml_models) do |f|
148
+ compiled = Lutaml::Lml.compile(f)
149
+ person_cls = compiled["Person"]
150
+ address_cls = compiled["Address"]
151
+
152
+ addr = address_cls.new(city: "Tokyo", country: "JP")
153
+ person = person_cls.new(name: "Akiko", home: addr)
154
+
155
+ expect(person.name).to eq("Akiko")
156
+ expect(person.home.city).to eq("Tokyo")
157
+ expect(person.home.country).to eq("JP")
158
+ end
159
+ end
160
+
161
+ it "round-trips an enum through compile → instantiate → value check" do
162
+ lml_models = <<~LML
163
+ models Enums {
164
+ enum Status {
165
+ active
166
+ inactive
167
+ pending
168
+ }
169
+ }
170
+ LML
171
+
172
+ with_lml_file(lml_models) do |f|
173
+ compiled = Lutaml::Lml.compile(f)
174
+ status_cls = compiled["Status"]
175
+
176
+ expect(status_cls.active.value).to eq("active")
177
+ expect(status_cls.inactive.value).to eq("inactive")
178
+ expect(status_cls.pending.value).to eq("pending")
179
+ end
180
+ end
181
+ end
182
+
183
+ describe "instance definition round-trip" do
184
+ it "parses an instance and extracts typed attributes including floats and booleans" do
185
+ lml = <<~LML
186
+ instance Sensor {
187
+ type Thermometer
188
+ location = "lab-3"
189
+ reading = 23.5
190
+ active = true
191
+ }
192
+ LML
193
+
194
+ with_lml_file(lml) do |f|
195
+ doc = Lutaml::Lml.parse_document(f)
196
+ inst = doc.instance
197
+ expect(inst.type).to eq("Sensor")
198
+
199
+ attrs = inst.attributes.to_h { |a| [a.name, a.value] }
200
+ expect(attrs["type"]).to eq("Thermometer")
201
+ expect(attrs["location"]).to eq("lab-3")
202
+ expect(attrs["reading"]).to eq(23.5)
203
+ expect(attrs["active"]).to be(true)
204
+ end
205
+ end
206
+
207
+ it "parses an instance with array values" do
208
+ lml = <<~LML
209
+ instance Checklist {
210
+ type AuditList
211
+ items = ["verify", "validate", "report"]
212
+ }
213
+ LML
214
+
215
+ with_lml_file(lml) do |f|
216
+ doc = Lutaml::Lml.parse_document(f)
217
+ inst = doc.instance
218
+ items = inst.attributes.find { |a| a.name == "items" }
219
+ expect(items.value).to eq(%w[verify validate report])
220
+ end
221
+ end
222
+
223
+ it "parses nested instances" do
224
+ lml = <<~LML
225
+ instance Container {
226
+ instance Inner {
227
+ type Config
228
+ key = "value"
229
+ }
230
+ }
231
+ LML
232
+
233
+ with_lml_file(lml) do |f|
234
+ doc = Lutaml::Lml.parse_document(f)
235
+ inner = doc.instance.instance
236
+ expect(inner.type).to eq("Inner")
237
+ inner_attrs = inner.attributes.to_h { |a| [a.name, a.value] }
238
+ expect(inner_attrs["type"]).to eq("Config")
239
+ expect(inner_attrs["key"]).to eq("value")
240
+ end
241
+ end
242
+
243
+ it "round-trips instance data through format adapter with floats and booleans" do
244
+ require "lutaml/lml/format"
245
+
246
+ model_class = Class.new(Lutaml::Model::Serializable) do
247
+ attribute :sensor_id, :string
248
+ attribute :reading, :float
249
+ attribute :active, :boolean, default: true
250
+
251
+ lml do
252
+ map :sensor_id, to: :sensor_id
253
+ map :reading, to: :reading
254
+ map :active, to: :active
255
+ end
256
+ end
257
+
258
+ original = model_class.new(sensor_id: "TH-042", reading: 21.7, active: false)
259
+ lml_text = original.to_lml
260
+
261
+ restored = model_class.from_lml(lml_text)
262
+ expect(restored.sensor_id).to eq("TH-042")
263
+ expect(restored.reading).to eq(21.7)
264
+ expect(restored.active).to be(false)
265
+ end
266
+
267
+ it "round-trips real-world instance data (data_s158_metadata)" do
268
+ require "lutaml/lml/format"
269
+
270
+ doc = Lutaml::Lml.parse_document(File.new("spec/lml/fixtures/lml/data_s158_metadata.lml"))
271
+ inner = doc.instance.instance
272
+ expect(inner.type).to eq("IhoDataModels::IhoMetadata")
273
+
274
+ attrs = inner.attributes.to_h { |a| [a.name, a.value] }
275
+ expect(attrs["document_number"]).to eq("S-158:102")
276
+ expect(attrs["title"]).to eq("Bathymetric Surface Validation Checks")
277
+ end
278
+ end
279
+
280
+ describe "compiled class + instance validation" do
281
+ let(:compiler) { Lutaml::Lml::ModelCompiler.new }
282
+
283
+ it "accepts a valid instance against a compiled class" do
284
+ lml = <<~LML
285
+ models Valid {
286
+ class Sensor {
287
+ attribute id {
288
+ type String
289
+ cardinality 1
290
+ }
291
+ attribute label {
292
+ type String
293
+ cardinality 0..1
294
+ }
295
+ }
296
+ }
297
+ LML
298
+
299
+ with_lml_file(lml) do |f|
300
+ errors = compiler.validate(f)
301
+ expect(errors).to eq([])
302
+ end
303
+ end
304
+
305
+ it "detects unknown type reference in instance" do
306
+ instance_lml = <<~LML
307
+ instance MyGadget {
308
+ type NonExistent
309
+ name = "hello"
310
+ }
311
+ LML
312
+
313
+ with_lml_file(instance_lml) do |f|
314
+ errors = compiler.validate(f)
315
+ expect(errors).to include(a_string_matching(/unknown type 'NonExistent'/))
316
+ end
317
+ end
318
+
319
+ it "detects unknown attributes on an instance" do
320
+ models_lml = <<~LML
321
+ models Strict {
322
+ class Sensor {
323
+ attribute id {
324
+ type String
325
+ cardinality 1
326
+ }
327
+ }
328
+ }
329
+ LML
330
+
331
+ instance_lml = <<~LML
332
+ instance BadSensor {
333
+ type Sensor
334
+ id = "s-001"
335
+ bogus_field = "oops"
336
+ }
337
+ LML
338
+
339
+ compiled = nil
340
+ with_lml_file(models_lml) do |f|
341
+ compiled = Lutaml::Lml.compile(f)
342
+ end
343
+
344
+ with_lml_file(instance_lml) do |f|
345
+ errors = compiler.validate(f, compiled: compiled)
346
+ expect(errors).to include(a_string_matching(/bogus_field.*not defined/))
347
+ end
348
+ end
349
+
350
+ it "detects missing required attributes" do
351
+ models_lml = <<~LML
352
+ models Required {
353
+ class Account {
354
+ attribute email {
355
+ type String
356
+ cardinality 1
357
+ }
358
+ attribute nickname {
359
+ type String
360
+ cardinality 0..1
361
+ }
362
+ }
363
+ }
364
+ LML
365
+
366
+ instance_lml = <<~LML
367
+ instance IncompleteAccount {
368
+ type Account
369
+ nickname = "bob"
370
+ }
371
+ LML
372
+
373
+ compiled = nil
374
+ with_lml_file(models_lml) do |f|
375
+ compiled = Lutaml::Lml.compile(f)
376
+ end
377
+
378
+ with_lml_file(instance_lml) do |f|
379
+ errors = compiler.validate(f, compiled: compiled)
380
+ expect(errors).to include(a_string_matching(/email.*required/))
381
+ end
382
+ end
383
+
384
+ it "validates nested instances recursively" do
385
+ models_lml = <<~LML
386
+ models Nested {
387
+ class Outer {
388
+ attribute name {
389
+ type String
390
+ cardinality 1
391
+ }
392
+ }
393
+ }
394
+ LML
395
+
396
+ instance_lml = <<~LML
397
+ instance Wrapper {
398
+ instance Inner {
399
+ type Outer
400
+ wrong_attr = "oops"
401
+ }
402
+ }
403
+ LML
404
+
405
+ compiled = nil
406
+ with_lml_file(models_lml) do |f|
407
+ compiled = Lutaml::Lml.compile(f)
408
+ end
409
+
410
+ with_lml_file(instance_lml) do |f|
411
+ errors = compiler.validate(f, compiled: compiled)
412
+ expect(errors).to include(a_string_matching(/wrong_attr.*not defined/))
413
+ end
414
+ end
415
+
416
+ it "validates against real-world fixtures" do
417
+ instance_lml = <<~LML
418
+ instance TestMeta {
419
+ type IhoMetadata
420
+ document_number = "S-101"
421
+ title = "Test Document"
422
+ unknown_field = "should fail"
423
+ }
424
+ LML
425
+
426
+ compiled = Lutaml::Lml.compile(File.new("spec/lml/fixtures/lml/iho_data_models.lml"))
427
+
428
+ with_lml_file(instance_lml) do |f|
429
+ errors = compiler.validate(f, compiled: compiled)
430
+ expect(errors).to include(a_string_matching(/unknown_field.*not defined/))
431
+ end
432
+ end
433
+ end
434
+
435
+ describe "view document YAML round trip" do
436
+ it "survives to_yaml/from_yaml with filters and imports intact" do
437
+ doc = Lutaml::Lml::Document.new(
438
+ name: "V",
439
+ title: "T",
440
+ classes: [Lutaml::Lml::UmlClass.new(name: "Foo", definition: "a \\{ b \\}")],
441
+ show_filter: Lutaml::Lml::ViewFilter.new(entity_names: ["Foo"]),
442
+ view_imports: [Lutaml::Lml::ViewImport.new(path: "m.lutaml")],
443
+ )
444
+
445
+ restored = Lutaml::Lml::Document.from_yaml(doc.to_yaml)
446
+
447
+ aggregate_failures do
448
+ expect(restored.name).to eq("V")
449
+ expect(restored.title).to eq("T")
450
+ expect(restored.classes.map(&:name)).to eq(["Foo"])
451
+ expect(restored.classes.first.definition).to eq("a { b }")
452
+ expect(restored.show_filter.entity_names).to eq(["Foo"])
453
+ expect(restored.view_imports.map(&:path)).to eq(["m.lutaml"])
454
+ end
455
+ end
456
+ end
457
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "tempfile"
5
+
6
+ # RS 3001 conformance corpus: the normative examples of
7
+ # lutaml-lang.adoc (RS 3001), vendored verbatim. Every example must
8
+ # parse and build a document. Constructs from the extension track
9
+ # (serialization mapping blocks) are intentionally absent here.
10
+ RS3001_CORPUS = Dir.glob(File.expand_path("../../fixtures/rs3001/*.lml", __dir__)).freeze
11
+
12
+ RSpec.describe "RS 3001 conformance corpus" do
13
+ # Vacuity guard: this glob once resolved to a nonexistent directory and
14
+ # the suite silently ran zero corpus examples. Every vendored fixture
15
+ # must be covered.
16
+ it "covers the full vendored corpus" do
17
+ expect(RS3001_CORPUS.size).to be > 20
18
+ end
19
+
20
+ RS3001_CORPUS.each do |path|
21
+ name = File.basename(path)
22
+
23
+ it "parses and builds #{name}" do
24
+ doc = Lutaml::Lml.parse_document(StringIO.new(File.read(path)))
25
+ expect(doc).to be_a(Lutaml::Lml::Document)
26
+ end
27
+ end
28
+
29
+ describe "semantic spot checks" do
30
+ it "bakes the package enum values shorthand into members" do
31
+ doc = Lutaml::Lml.parse_document(
32
+ StringIO.new(File.read("spec/lml/fixtures/rs3001/03_package_ceramics.lml")),
33
+ )
34
+ profile = doc.packages.first.enums.first
35
+ expect(profile.attributes.map(&:name)).to eq(%w[low medium high])
36
+ tile = doc.packages.first.classes.first
37
+ expect(tile.attributes.map(&:name)).to eq(%w[dimensions firing_profile])
38
+ end
39
+
40
+ it "captures the pattern constraint" do
41
+ doc = Lutaml::Lml.parse_document(
42
+ StringIO.new(File.read("spec/lml/fixtures/rs3001/07_attribute_pattern.lml")),
43
+ )
44
+ color = doc.classes.first.attributes.first
45
+ expect(color.pattern).to eq('\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z')
46
+ end
47
+
48
+ it "compiles colon-form defaults" do
49
+ file = Tempfile.new(%w[g .lml])
50
+ begin
51
+ file.write(File.read("spec/lml/fixtures/rs3001/08_attribute_default_colon.lml"))
52
+ file.rewind
53
+ compiler = Lutaml::Lml::ModelCompiler.new
54
+ compiler.compile(file)
55
+ glaze = compiler.compiled_classes["Glaze"]
56
+ inst = glaze.new
57
+ expect(inst.color).to eq("Clear")
58
+ expect(inst.temperature).to eq(1050)
59
+ ensure
60
+ file.close!
61
+ end
62
+ end
63
+
64
+ it "resolves collection-qualified references and names the collection" do
65
+ doc = Lutaml::Lml.parse_document(
66
+ StringIO.new(File.read("spec/lml/fixtures/rs3001/13_instances_collection_refs.lml")),
67
+ )
68
+ expect(doc.instances.name).to eq("Glazes")
69
+ tile = doc.instances.instances.find { |i| i.name == "tile_002" }
70
+ expect(tile).not_to be_nil
71
+ violations = Lutaml::Lml::Validator.violations(doc)
72
+ expect(violations).to be_empty
73
+ end
74
+
75
+ it "keeps values-as-instances data on members" do
76
+ doc = Lutaml::Lml.parse_document(
77
+ StringIO.new(File.read("spec/lml/fixtures/rs3001/11_enum_values_as_instances.lml")),
78
+ )
79
+ matte = doc.enums.first.attributes.find { |a| a.name == "matte" }
80
+ expect(matte).not_to be_nil
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ def parse_rs3001_document(src)
6
+ Lutaml::Lml.parse_document(StringIO.new(src))
7
+ end
8
+
9
+ RSpec.describe "RS 3001 syntax" do
10
+ describe "§Comment" do
11
+ it "strips // comments while preserving // inside string literals" do
12
+ doc = parse_rs3001_document(<<~LML)
13
+ // leading comment
14
+ instances {
15
+ Product "p" {
16
+ url = "http://example.com//x" // tail comment
17
+ }
18
+ }
19
+ LML
20
+ attr = doc.instances.instances.first.attributes.find { |a| a.name == "url" }
21
+ expect(attr.value.to_s).to eq("http://example.com//x")
22
+ end
23
+
24
+ it "strips multi-line /* */ block comments" do
25
+ doc = parse_rs3001_document(<<~LML)
26
+ /* block
27
+ comment */
28
+ class Materials::CeramicTile { }
29
+ LML
30
+ expect(doc.classes.map(&:name)).to eq(["Materials::CeramicTile"])
31
+ end
32
+
33
+ it "raises on an unterminated block comment" do
34
+ expect { parse_rs3001_document("class C { /* oops\n }\n") }
35
+ .to raise_error(Lutaml::Lml::Error, /unterminated block comment/)
36
+ end
37
+ end
38
+
39
+ describe "§Package" do
40
+ it "parses a package with nested classes and enums" do
41
+ doc = parse_rs3001_document(<<~LML)
42
+ // leading comment
43
+ package Ceramics {
44
+ class Tile { }
45
+ enum Glaze { celadon }
46
+ }
47
+ LML
48
+ pkg = doc.packages.first
49
+ expect(pkg.name).to eq("Ceramics")
50
+ expect(pkg.classes.map(&:name)).to eq(["Tile"])
51
+ expect(pkg.enums.map(&:name)).to eq(["Glaze"])
52
+ end
53
+ end
54
+
55
+ describe "§Instance" do
56
+ it "parses the quoted-name instance form with an explicit type" do
57
+ doc = parse_rs3001_document(<<~LML)
58
+ instances {
59
+ instance "square" Tile {
60
+ url = "http://example.com//x"
61
+ }
62
+ }
63
+ LML
64
+ inst = doc.instances.instances.first
65
+ expect(inst.type).to eq("Tile")
66
+ expect(inst.attributes.map { |a| [a.name, a.value.to_s] })
67
+ .to eq([["url", "http://example.com//x"]])
68
+ end
69
+ end
70
+
71
+ describe "§Namespacing" do
72
+ it "parses double-colon scoped class names" do
73
+ doc = parse_rs3001_document("class Materials::CeramicTile { }\n")
74
+ expect(doc.classes.map(&:name)).to eq(["Materials::CeramicTile"])
75
+ end
76
+ end
77
+ end