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,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../lml_spec_setup"
5
+ require "lutaml/lml"
6
+ require "lutaml/lml/executor"
7
+ require "tmpdir"
8
+
9
+ RSpec.describe "End-to-end instance import/export", type: :integration do
10
+ let(:models_lml) do
11
+ <<~LML
12
+ models Catalog {
13
+ class Product {
14
+ attribute id { type String }
15
+ attribute name { type String }
16
+ attribute price { type String }
17
+ }
18
+ }
19
+ LML
20
+ end
21
+
22
+ let(:input_xml) do
23
+ <<~XML
24
+ <?xml version="1.0" encoding="UTF-8"?>
25
+ <Products>
26
+ <Product>
27
+ <id>P001</id>
28
+ <name>Widget</name>
29
+ <price>9.99</price>
30
+ </Product>
31
+ <Product>
32
+ <id>P002</id>
33
+ <name>Gadget</name>
34
+ <price>14.50</price>
35
+ </Product>
36
+ </Products>
37
+ XML
38
+ end
39
+
40
+ let(:workdir) { Dir.mktmpdir("lml-integration-") }
41
+
42
+ after do
43
+ FileUtils.rm_rf(workdir)
44
+ end
45
+
46
+ it "compiles models, imports XML, validates, and exports XML" do
47
+ compiled = Lutaml::Lml.compile(StringIO.new(models_lml))
48
+ expect(compiled).to include("Product")
49
+
50
+ product_class = compiled["Product"]
51
+ expect(product_class).to respond_to(:from_xml)
52
+ expect(product_class.instance_method(:to_xml)).to be_an(UnboundMethod)
53
+
54
+ input_path = File.join(workdir, "products.xml")
55
+ output_path = File.join(workdir, "products_out.xml")
56
+ File.write(input_path, input_xml)
57
+
58
+ instances_lml = <<~LML
59
+ instances {
60
+ collection "all_products" {
61
+ validation {
62
+ condition "count >= 2"
63
+ }
64
+ }
65
+
66
+ import {
67
+ xml "#{input_path}" {
68
+ map_to Product
69
+ where "/Products/Product"
70
+ }
71
+ }
72
+
73
+ export {
74
+ format xml {
75
+ file "#{output_path}"
76
+ root "Products"
77
+ indent true
78
+ }
79
+ }
80
+ }
81
+ LML
82
+
83
+ doc = Lutaml::Lml.parse_document(StringIO.new(instances_lml))
84
+
85
+ instances = Lutaml::Lml::Executor.run(doc, compiled: compiled)
86
+
87
+ expect(instances.length).to eq(2)
88
+ expect(instances[0]).to be_a(product_class)
89
+ expect(instances[0].id).to eq("P001")
90
+ expect(instances[0].name).to eq("Widget")
91
+ expect(instances[1].id).to eq("P002")
92
+
93
+ expect(File.exist?(output_path)).to be true
94
+ output = File.read(output_path)
95
+ expect(output).to include("<Products>")
96
+ expect(output).to include("<id>P001</id>")
97
+ expect(output).to include("<name>Widget</name>")
98
+ expect(output).to include("<id>P002</id>")
99
+ expect(output).to include("<name>Gadget</name>")
100
+ expect(output).to include("</Products>")
101
+ end
102
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # LML (subsumed language core) spec setup. Loaded alongside the gem-level
4
+ # spec_helper by the LML specs.
5
+
6
+ require "lutaml/lml"
7
+
8
+ RSpec.configure do |config|
9
+ config.define_derived_metadata(file_path: %r{elk_layout_spec}) do |metadata|
10
+
11
+ metadata[:skip] = "elkrb gem not available" unless (require "elkrb"
12
+ true)
13
+ rescue StandardError
14
+ false
15
+
16
+ end
17
+ end
18
+
19
+ def fixtures_path(path)
20
+ File.join(File.expand_path("fixtures", __dir__), path)
21
+ end
22
+
23
+ def by_name(entries, name)
24
+ entries.detect { |n| n.name == name }
25
+ end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::AssociationLabelResolver do
7
+ let(:resolver) { described_class.new }
8
+
9
+ describe "#enrich" do
10
+ it "populates owner_end_attribute_name from matching class attribute type" do
11
+ attr = Lutaml::Lml::TopElementAttribute.new(
12
+ name: "docIdentifier", type: "IsoDocumentId",
13
+ )
14
+ klass = Lutaml::Lml::UmlClass.new(
15
+ name: "IsoBibliographicItem", attributes: [attr],
16
+ )
17
+ assoc = Lutaml::Lml::Association.new(
18
+ owner_end: "IsoBibliographicItem", member_end: "IsoDocumentId",
19
+ )
20
+ doc = Lutaml::Lml::Document.new(
21
+ classes: [klass], associations: [assoc],
22
+ )
23
+
24
+ resolver.enrich(doc)
25
+
26
+ expect(assoc.owner_end_attribute_name).to eq("docIdentifier")
27
+ end
28
+
29
+ it "populates owner_end_cardinality when attribute has cardinality" do
30
+ card = Lutaml::Lml::Cardinality.new(min: "0", max: "1")
31
+ attr = Lutaml::Lml::TopElementAttribute.new(
32
+ name: "type", type: "IsoDocumentType", cardinality: card,
33
+ )
34
+ klass = Lutaml::Lml::UmlClass.new(
35
+ name: "IsoBibliographicItem", attributes: [attr],
36
+ )
37
+ assoc = Lutaml::Lml::Association.new(
38
+ owner_end: "IsoBibliographicItem", member_end: "IsoDocumentType",
39
+ )
40
+ doc = Lutaml::Lml::Document.new(
41
+ classes: [klass], associations: [assoc],
42
+ )
43
+
44
+ resolver.enrich(doc)
45
+
46
+ expect(assoc.owner_end_attribute_name).to eq("type")
47
+ expect(assoc.owner_end_cardinality.min).to eq("0")
48
+ expect(assoc.owner_end_cardinality.max).to eq("1")
49
+ end
50
+
51
+ it "does not overwrite existing owner_end_attribute_name" do
52
+ attr = Lutaml::Lml::TopElementAttribute.new(
53
+ name: "override_me", type: "IsoDocumentId",
54
+ )
55
+ klass = Lutaml::Lml::UmlClass.new(
56
+ name: "IsoBibliographicItem", attributes: [attr],
57
+ )
58
+ assoc = Lutaml::Lml::Association.new(
59
+ owner_end: "IsoBibliographicItem", member_end: "IsoDocumentId",
60
+ owner_end_attribute_name: "explicit_name"
61
+ )
62
+ doc = Lutaml::Lml::Document.new(
63
+ classes: [klass], associations: [assoc],
64
+ )
65
+
66
+ resolver.enrich(doc)
67
+
68
+ expect(assoc.owner_end_attribute_name).to eq("explicit_name")
69
+ end
70
+
71
+ it "populates member_end_attribute_name from matching attribute on member class" do
72
+ attr = Lutaml::Lml::TopElementAttribute.new(
73
+ name: "bibItem", type: "IsoBibliographicItem",
74
+ )
75
+ member_class = Lutaml::Lml::UmlClass.new(
76
+ name: "IsoDocumentId", attributes: [attr],
77
+ )
78
+ assoc = Lutaml::Lml::Association.new(
79
+ owner_end: "IsoBibliographicItem", member_end: "IsoDocumentId",
80
+ )
81
+ doc = Lutaml::Lml::Document.new(
82
+ classes: [member_class], associations: [assoc],
83
+ )
84
+
85
+ resolver.enrich(doc)
86
+
87
+ expect(assoc.member_end_attribute_name).to eq("bibItem")
88
+ end
89
+
90
+ it "skips association when owner class is not in document" do
91
+ assoc = Lutaml::Lml::Association.new(
92
+ owner_end: "MissingClass", member_end: "IsoDocumentId",
93
+ )
94
+ doc = Lutaml::Lml::Document.new(classes: [], associations: [assoc])
95
+
96
+ resolver.enrich(doc)
97
+
98
+ expect(assoc.owner_end_attribute_name).to be_nil
99
+ end
100
+
101
+ it "skips when no attribute type matches member_end" do
102
+ attr = Lutaml::Lml::TopElementAttribute.new(
103
+ name: "name", type: "String",
104
+ )
105
+ klass = Lutaml::Lml::UmlClass.new(
106
+ name: "Foo", attributes: [attr],
107
+ )
108
+ assoc = Lutaml::Lml::Association.new(
109
+ owner_end: "Foo", member_end: "Bar",
110
+ )
111
+ doc = Lutaml::Lml::Document.new(
112
+ classes: [klass], associations: [assoc],
113
+ )
114
+
115
+ resolver.enrich(doc)
116
+
117
+ expect(assoc.owner_end_attribute_name).to be_nil
118
+ end
119
+
120
+ it "searches enums and data_types in addition to classes" do
121
+ attr = Lutaml::Lml::TopElementAttribute.new(
122
+ name: "status", type: "Status",
123
+ )
124
+ enum = Lutaml::Lml::Enum.new(
125
+ name: "MyClass", attributes: [attr],
126
+ )
127
+ assoc = Lutaml::Lml::Association.new(
128
+ owner_end: "MyClass", member_end: "Status",
129
+ )
130
+ doc = Lutaml::Lml::Document.new(
131
+ enums: [enum], associations: [assoc],
132
+ )
133
+
134
+ resolver.enrich(doc)
135
+
136
+ expect(assoc.owner_end_attribute_name).to eq("status")
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,274 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::DataProcessor do
7
+ let(:processor) { described_class.new }
8
+
9
+ describe ".process" do
10
+ it "processes data without requiring a mixin" do
11
+ input = { name: "test" }
12
+ result = described_class.process(input)
13
+ expect(result).to eq({ name: "test" })
14
+ end
15
+
16
+ it "processes key handlers via class method" do
17
+ input = { attributes: [{ key: "name", value: { string: "test" } }] }
18
+ result = described_class.process(input)
19
+ expect(result[:attributes].first[:name]).to eq("name")
20
+ end
21
+ end
22
+
23
+ describe "#process_data" do
24
+ it "passes through non-hash/array values" do
25
+ expect(processor.process_data("hello")).to eq("hello")
26
+ expect(processor.process_data(42)).to eq(42)
27
+ end
28
+
29
+ it "recursively processes arrays" do
30
+ input = [{ name: "test" }, { key: "value" }]
31
+ result = processor.process_data(input)
32
+ expect(result).to be_an(Array)
33
+ end
34
+
35
+ it "recursively processes hashes" do
36
+ input = { name: "test", nested: { key: "val" } }
37
+ result = processor.process_data(input)
38
+ expect(result).to be_a(Hash)
39
+ end
40
+
41
+ it "does not mutate the input hash" do
42
+ original = { requires: [{ require: { string: "file.lml" } }], name: "test" }
43
+ original_frozen = original.dup
44
+ processor.process_data(original)
45
+ expect(original).to eq(original_frozen)
46
+ end
47
+ end
48
+
49
+ describe "#process_value" do
50
+ it "returns empty array for nil" do
51
+ expect(processor.process_value(nil)).to eq([])
52
+ end
53
+
54
+ it "processes string hash" do
55
+ result = processor.process_value({ string: "hello" })
56
+ expect(result).to eq(["String", "hello"])
57
+ end
58
+
59
+ it "processes boolean hash with true" do
60
+ result = processor.process_value({ boolean: "true" })
61
+ expect(result).to eq(["Boolean", true])
62
+ end
63
+
64
+ it "processes boolean hash with false" do
65
+ result = processor.process_value({ boolean: "false" })
66
+ expect(result).to eq(["Boolean", false])
67
+ end
68
+
69
+ it "processes number hash" do
70
+ result = processor.process_value({ number: "42" })
71
+ expect(result).to eq(["Number", 42])
72
+ end
73
+
74
+ it "processes list hash" do
75
+ result = processor.process_value({ list: [{ string: "a" }, { string: "b" }] })
76
+ expect(result[0]).to eq("String[]")
77
+ expect(result[1]).to eq(%w[a b])
78
+ end
79
+
80
+ it "processes key_value_map" do
81
+ input = {
82
+ key_value_map: [
83
+ { key: "name", value: { string: "test" } },
84
+ { key: "count", value: { number: "5" } },
85
+ ],
86
+ }
87
+ result = processor.process_value(input)
88
+ expect(result[0]).to eq("Hash")
89
+ expect(result[1][:name]).to eq("test")
90
+ expect(result[1][:count]).to eq(5)
91
+ end
92
+
93
+ it "processes instance values" do
94
+ result = processor.process_value({ instance: { instance_type: "MyClass" } })
95
+ expect(result[0]).to eq("Instance")
96
+ expect(result[1]).to be_a(Hash)
97
+ end
98
+
99
+ it "processes condition values by unwrapping" do
100
+ result = processor.process_value({ condition: { string: "x > 0" } })
101
+ expect(result).to eq(["String", "x > 0"])
102
+ end
103
+
104
+ it "processes require values by unwrapping" do
105
+ result = processor.process_value({ require: { string: "file.lml" } })
106
+ expect(result).to eq(["String", "file.lml"])
107
+ end
108
+
109
+ it "processes plain arrays" do
110
+ result = processor.process_value([{ string: "a" }, { string: "b" }])
111
+ expect(result[0]).to eq("String[]")
112
+ expect(result[1]).to eq(%w[a b])
113
+ end
114
+
115
+ it "falls back to class name for unknown types" do
116
+ result = processor.process_value(3.14)
117
+ expect(result).to eq(["Float", 3.14])
118
+ end
119
+ end
120
+
121
+ describe "#process_instance" do
122
+ it "converts instance_type to type" do
123
+ result = processor.process_instance({ instance_type: "MyClass" })
124
+ expect(result[:type]).to eq("MyClass")
125
+ end
126
+
127
+ it "preserves nested instance" do
128
+ input = {
129
+ instance_type: "Parent",
130
+ instance: { instance_type: "Child" },
131
+ }
132
+ result = processor.process_instance(input)
133
+ expect(result[:type]).to eq("Parent")
134
+ expect(result[:instance][:type]).to eq("Child")
135
+ end
136
+
137
+ it "processes attributes" do
138
+ input = {
139
+ instance_type: "MyClass",
140
+ attributes: [
141
+ { key: "name", value: { string: "test" } },
142
+ ],
143
+ }
144
+ result = processor.process_instance(input)
145
+ expect(result[:type]).to eq("MyClass")
146
+ expect(result[:attributes]).to be_an(Array)
147
+ expect(result[:attributes].first[:name]).to eq("name")
148
+ end
149
+
150
+ it "processes template" do
151
+ input = {
152
+ instance_type: "MyClass",
153
+ template: {
154
+ attributes: [{ key: "component", value: { string: "cpu" } }],
155
+ },
156
+ }
157
+ result = processor.process_instance(input)
158
+ expect(result[:template]).to be_an(Array)
159
+ expect(result[:template].first[:name]).to eq("component")
160
+ end
161
+ end
162
+
163
+ describe "#process_attributes" do
164
+ it "converts key to name in hash form" do
165
+ result = processor.process_attributes_hash({ key: "foo", value: { string: "bar" } })
166
+ expect(result[:name]).to eq("foo")
167
+ expect(result[:value]).to eq("bar")
168
+ end
169
+
170
+ it "converts comments to Comment name/value" do
171
+ result = processor.process_attributes_hash({ comments: { string: "note" } })
172
+ expect(result[:name]).to eq("Comment")
173
+ expect(result[:value]).to eq("note")
174
+ end
175
+
176
+ it "sets extended flag from add key" do
177
+ result = processor.process_attributes_hash({ key: "prop", value: { string: "x" }, add: "true" })
178
+ expect(result[:extended]).to be(true)
179
+ end
180
+
181
+ it "converts Instance type values to instances" do
182
+ result = processor.process_attributes_hash({
183
+ key: "items",
184
+ value: { instance: { instance_type: "Item" } },
185
+ })
186
+ expect(result).to have_key(:instances)
187
+ expect(result[:instances].length).to eq(1)
188
+ end
189
+
190
+ it "returns an empty array for an empty attributes body" do
191
+ expect(processor.process_attributes_array([])).to eq([])
192
+ end
193
+ end
194
+
195
+ describe "#process_requires" do
196
+ it "extracts string values from require entries" do
197
+ result = processor.process_requires([{ require: { string: "file1.lml" } }])
198
+ expect(result).to eq(["file1.lml"])
199
+ end
200
+ end
201
+
202
+ describe "#process_collections" do
203
+ it "processes collection values" do
204
+ input = { name: { string: "suite1" }, includes: [{ string: "a" }, { string: "b" }] }
205
+ result = processor.process_collections(input)
206
+ expect(result[:name]).to eq("suite1")
207
+ end
208
+ end
209
+
210
+ describe "#process_imports" do
211
+ it "processes import entries with attributes" do
212
+ input = [{
213
+ format_type: "xml",
214
+ file: "data.xml",
215
+ attributes: [{ key: "map_to", value: { string: "Product" } }],
216
+ }]
217
+ result = processor.process_imports(input)
218
+ expect(result.length).to eq(1)
219
+ expect(result[0][:format_type]).to eq("xml")
220
+ expect(result[0][:file]).to eq("data.xml")
221
+ end
222
+ end
223
+
224
+ describe "#process_exports" do
225
+ it "processes export entries" do
226
+ input = [{
227
+ format_type: "json",
228
+ attributes: [{ key: "indent", value: { boolean: "true" } }],
229
+ }]
230
+ result = processor.process_exports(input)
231
+ expect(result[0][:format_type]).to eq("json")
232
+ end
233
+ end
234
+
235
+ describe "#process_instances" do
236
+ it "accumulates repeated collection, import, and export blocks" do
237
+ input = [
238
+ { collections: { name: { string: "c1" }, includes: [{ string: "x" }] } },
239
+ { collections: { name: { string: "c2" }, includes: [{ string: "y" }] } },
240
+ { imports: [{ format_type: "xml", file: "a.xml" }] },
241
+ { imports: [{ format_type: "csv", file: "b.csv" }] },
242
+ { exports: [{ format_type: "xml" }] },
243
+ { exports: [{ format_type: "step" }] },
244
+ ]
245
+
246
+ result = processor.process_instances(input)
247
+
248
+ expect(result[:collections].map { |c| c[:name] }).to eq(%w[c1 c2])
249
+ expect(result[:imports].map { |i| i[:file] }).to eq(%w[a.xml b.csv])
250
+ expect(result[:exports].map { |e| e[:format_type] }).to eq(%w[xml step])
251
+ end
252
+ end
253
+
254
+ describe "ViewProcessing" do
255
+ describe "#process_show_list" do
256
+ it "extracts entity names from array of hashes" do
257
+ result = processor.process_show_list([{ entity_name: "Foo" }, { entity_name: "Bar" }])
258
+ expect(result).to eq(["Foo", "Bar"])
259
+ end
260
+
261
+ it "handles single entity name" do
262
+ result = processor.process_show_list({ entity_name: "Baz" })
263
+ expect(result).to eq(["Baz"])
264
+ end
265
+ end
266
+
267
+ describe "#process_hide_list" do
268
+ it "extracts entity names from array" do
269
+ result = processor.process_hide_list([{ entity_name: "Secret" }])
270
+ expect(result).to eq(["Secret"])
271
+ end
272
+ end
273
+ end
274
+ end