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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea63d75c561923cb1286edc3d320fb2e24aa39ed9318a19cabbcf73659f3b9c1
4
- data.tar.gz: 7dda5b3ee35853aae9dada687a762641bddb5ced2e55dc606c22a8c87b44f451
3
+ metadata.gz: 0d74882885d43e5ff3acae984c6b3d26f33de2036d79effdfa55deb66f6d24d4
4
+ data.tar.gz: 95d002c88f4a4a28de4cea44094321afcfdb0a38f787cf4e04f9c394b857da34
5
5
  SHA512:
6
- metadata.gz: 78e413d5a78c52d788e6bcea704b4365afb081671bf2886f84deac7b9ff9e44b574ef38256632c894aa4bfb675aadf692f2b260540d3901bc3a868e39a843624
7
- data.tar.gz: 95f5e0d1466f68e79287c797b0dba6421d045df2806449e179dba73eb6d395c7eb590c031031cc842917f39f74cf80d89adf0871c4554848c680013a4efaee5d
6
+ metadata.gz: 843dde8a0001e048af6777c7829c8d4022d0ff2537c42f69a14d9b63cf190aece0362f14d94ba072e74a744e8db786f5ec2e393b5623377f2d5983f5da058922
7
+ data.tar.gz: 29cfad3f89b75b1288b17b5addc2c83cae737d6929e05ab9b903f106267d9afdd43fd1bda9ba8f106893d0f5e23d0b017da71e842d3e0c84c9034a9c5b97e79a
@@ -0,0 +1,8 @@
1
+ {
2
+ "repo": [
3
+ "metanorma/docbook",
4
+ "metanorma/rfcxml",
5
+ "metanorma/uniword",
6
+ "ukiryu/ukiryu"
7
+ ]
8
+ }
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "repo": [
3
- "metanorma/docbook",
4
- "metanorma/metanorma-cli",
5
- "metanorma/rfcxml",
6
- "metanorma/uniword",
7
- "ukiryu/ukiryu"
3
+ "metanorma/metanorma-cli"
8
4
  ]
9
5
  }
@@ -34,7 +34,7 @@ jobs:
34
34
  # the failed-example names, and a deterministic CI-only failure
35
35
  # (the glossarist/iev leg, 2026-10-31) cannot be diagnosed from
36
36
  # names alone.
37
- command: set +e; echo "spec-files=$(find spec -name '*_spec.rb' 2>/dev/null | wc -l)"; bundle exec rspec > rspec-run.log 2>&1; code=$?; echo "rspec-exit=$code"; tail -25 rspec-run.log; grep -B2 -A14 "Failure/Error" rspec-run.log | head -160; exit $code
37
+ command: set +e; echo "spec-files=$(find spec -name '*_spec.rb' 2>/dev/null | wc -l)"; echo "lutaml-model-under-test:"; bundle info lutaml-model 2>/dev/null | sed -n '1,4p'; bundle exec rspec > rspec-run.log 2>&1; code=$?; echo "rspec-exit=$code"; tail -25 rspec-run.log; grep -B2 -A14 "Failure/Error" rspec-run.log | head -160; exit $code
38
38
  repos-json-file: .github/workflows/dependent-repos.json
39
39
  matrix_ruby: '[{"version":"4.0","rubygems":"latest","bundler":"default","experimental":false}]'
40
40
  after-setup-ruby: |
@@ -46,10 +46,16 @@ jobs:
46
46
  # inkscape/imagemagick/ghostscript and raises if absent, and its
47
47
  # smoke suite exercises exiftool, yq and ffmpeg too; the metanorma
48
48
  # renderers run full document renders.
49
+ #
50
+ # Blocking tier (#1225): metanorma-cli runs against the PR branch and
51
+ # its failures gate the PR.
49
52
  rake-with-tools:
50
53
  uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
51
54
  with:
52
- command: set +e; echo "spec-files=$(find spec -name '*_spec.rb' 2>/dev/null | wc -l)"; bundle exec rspec; code=$?; echo "rspec-exit=$code"; exit $code
55
+ # The provenance lines pin WHICH lutaml-model the suite ran
56
+ # against (path-injected branch vs rubygems release), so a red
57
+ # dependent log is attributable at a glance (#1225).
58
+ command: set +e; echo "spec-files=$(find spec -name '*_spec.rb' 2>/dev/null | wc -l)"; echo "lutaml-model-under-test:"; bundle info lutaml-model 2>/dev/null | sed -n '1,4p'; bundle exec rspec; code=$?; echo "rspec-exit=$code"; exit $code
53
59
  repos-json-file: .github/workflows/dependent-repos-tools.json
54
60
  setup-tools: 'inkscape,ghostscript,exiftool,ffmpeg,imagemagick,yq'
55
61
  matrix_ruby: '[{"version":"4.0","rubygems":"latest","bundler":"default","experimental":false}]'
@@ -57,3 +63,21 @@ jobs:
57
63
  if [ -f frontend/package.json ]; then cd frontend && npm install && npm run build; fi
58
64
  secrets:
59
65
  pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }}
66
+
67
+ # Informational tier (#1225): these dependents carry red suites for
68
+ # their own reasons (uniword's annotated TODO.validate fixture debt,
69
+ # ukiryu's runner-tool smoke, docbook/rfcxml released-state
70
+ # breakage), so their failures are reported as notices and do not
71
+ # gate the PR. They still run the full injection; only the exit
72
+ # status is non-blocking.
73
+ rake-with-tools-informational:
74
+ uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
75
+ with:
76
+ command: set +e; echo "spec-files=$(find spec -name '*_spec.rb' 2>/dev/null | wc -l)"; echo "lutaml-model-under-test:"; bundle info lutaml-model 2>/dev/null | sed -n '1,4p'; bundle exec rspec > rspec-run.log 2>&1; code=$?; echo "informational rspec-exit=$code (non-blocking notice)"; tail -25 rspec-run.log; grep -B2 -A14 "Failure/Error" rspec-run.log | head -160; exit 0
77
+ repos-json-file: .github/workflows/dependent-repos-tools-informational.json
78
+ setup-tools: 'inkscape,ghostscript,exiftool,ffmpeg,imagemagick,yq'
79
+ matrix_ruby: '[{"version":"4.0","rubygems":"latest","bundler":"default","experimental":false}]'
80
+ after-setup-ruby: |
81
+ if [ -f frontend/package.json ]; then cd frontend && npm install && npm run build; fi
82
+ secrets:
83
+ pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }}
data/Gemfile CHANGED
@@ -39,6 +39,8 @@ gem "oj"
39
39
  gem "openssl", "~> 3.0"
40
40
  gem "ox"
41
41
  gem "rake"
42
+ # Property-based generation for the LML round-trip laws (subsumed suite)
43
+ gem "rantly", "~> 2.0"
42
44
  gem "rdf-turtle"
43
45
  gem "rexml"
44
46
  # Native engines stay development-only: every adapter detects and
data/Rakefile CHANGED
@@ -38,6 +38,12 @@ begin
38
38
  Opal.append_path compat_dir if File.directory?(compat_dir)
39
39
  end
40
40
 
41
+ # parsanol (the subsumed LML grammar machinery) is pure Ruby; its
42
+ # gem lib must be on Opal's load path for the boot's
43
+ # `require "parsanol"` to resolve.
44
+ parsanol_gem_dir = Gem::Specification.find_by_name("parsanol")&.gem_dir
45
+ Opal.append_path File.join(parsanol_gem_dir, "lib") if parsanol_gem_dir
46
+
41
47
  rexml_lib = $LOAD_PATH.find do |p|
42
48
  File.exist?(File.join(p, "rexml", "document.rb"))
43
49
  end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "lutaml/lml"
5
+
6
+ # JSON-RPC framing is byte-oriented; text-mode newline translation would
7
+ # turn \r\n into \r\r\n and break Content-Length.
8
+ $stdin.binmode
9
+ $stdout.binmode
10
+
11
+ exit Lutaml::Lml::Lsp::Server.new.run
@@ -32,6 +32,10 @@ NATIVE_ONLY_PATTERNS = [
32
32
  # on its requires (and FFI itself does not exist under Opal); the
33
33
  # adapter probe degrades to moxml at runtime (#1008).
34
34
  %r{\Alutaml/xml/leptris},
35
+ # The CSV adapter pulls the csv bundled stdlib gem, which has no Opal
36
+ # build; CSV instance import/export is not part of the Opal surface
37
+ # (Executor's CsvAdapter autoload never fires under Opal either).
38
+ %r{\Alutaml/lml/executor/csv_adapter\z},
35
39
  ].freeze
36
40
 
37
41
  # Match `autoload :Name, "...anything..."` where the string argument may
@@ -91,7 +95,10 @@ opal_paths = paths - native_only
91
95
  # ENTRY_FILES are added unconditionally: they are top-level entry points
92
96
  # that nothing else autoloads (because they ARE the entry points users
93
97
  # require directly), so they would otherwise be missing from the list.
94
- ENTRY_FILES = %w[lutaml/model lutaml/xml].freeze
98
+ # lutaml/lml defines Lutaml::Lml and its error hierarchy — the lutaml/lml/*
99
+ # files open the namespace, but the entry file itself is only ever
100
+ # user-required, so it must be pinned here.
101
+ ENTRY_FILES = %w[lutaml/model lutaml/xml lutaml/lml].freeze
95
102
  remaining = (opal_paths - ENTRY_FILES).sort_by { |p| [p.count("/"), p] }
96
103
  ordered = ENTRY_FILES + remaining
97
104
 
@@ -110,10 +117,10 @@ out << "# - nokogiri/ox/rexml adapters (C extensions unavailable)"
110
117
  out << "# - XSD / RELAX NG schema generators (require Nokogiri)"
111
118
  out << "# - lutaml/model/cli (thor-based, runtime-irrelevant under Opal)"
112
119
  out << "#"
113
- out << "# Ordering: lutaml/model and lutaml/xml define the Lutaml::Model and"
114
- out << "# Lutaml::Xml namespaces, so they load first. Remaining paths are"
115
- out << "# ordered by depth (shallower first) so parent files declare their"
116
- out << "# child namespaces before children load."
120
+ out << "# Ordering: lutaml/model, lutaml/xml and lutaml/lml define the"
121
+ out << "# Lutaml::Model, Lutaml::Xml and Lutaml::Lml namespaces, so they load"
122
+ out << "# first. Remaining paths are ordered by depth (shallower first) so"
123
+ out << "# parent files declare their child namespaces before children load."
117
124
  out << "#"
118
125
  out << "# Loaded by the Opal Rakefile before spec_helper."
119
126
  out << ""
@@ -12,15 +12,16 @@
12
12
  # - XSD / RELAX NG schema generators (require Nokogiri)
13
13
  # - lutaml/model/cli (thor-based, runtime-irrelevant under Opal)
14
14
  #
15
- # Ordering: lutaml/model and lutaml/xml define the Lutaml::Model and
16
- # Lutaml::Xml namespaces, so they load first. Remaining paths are
17
- # ordered by depth (shallower first) so parent files declare their
18
- # child namespaces before children load.
15
+ # Ordering: lutaml/model, lutaml/xml and lutaml/lml define the
16
+ # Lutaml::Model, Lutaml::Xml and Lutaml::Lml namespaces, so they load
17
+ # first. Remaining paths are ordered by depth (shallower first) so
18
+ # parent files declare their child namespaces before children load.
19
19
  #
20
20
  # Loaded by the Opal Rakefile before spec_helper.
21
21
 
22
22
  require "lutaml/model"
23
23
  require "lutaml/xml"
24
+ require "lutaml/lml"
24
25
  require "lutaml/jsonld"
25
26
  require "lutaml/turtle"
26
27
  require "lutaml/yamlld"
@@ -39,6 +40,36 @@ require "lutaml/key_value/mapping_rule"
39
40
  require "lutaml/key_value/transform"
40
41
  require "lutaml/key_value/transformation"
41
42
  require "lutaml/key_value/transformation_builder"
43
+ require "lutaml/lml/association_label_resolver"
44
+ require "lutaml/lml/data_processor"
45
+ require "lutaml/lml/diagnostic"
46
+ require "lutaml/lml/document_builder"
47
+ require "lutaml/lml/entity_types"
48
+ require "lutaml/lml/executor"
49
+ require "lutaml/lml/format"
50
+ require "lutaml/lml/formatter"
51
+ require "lutaml/lml/grammar"
52
+ require "lutaml/lml/has_attributes"
53
+ require "lutaml/lml/import_resolver"
54
+ require "lutaml/lml/layout"
55
+ require "lutaml/lml/literal_value"
56
+ require "lutaml/lml/lsp"
57
+ require "lutaml/lml/model_compiler"
58
+ require "lutaml/lml/parser"
59
+ require "lutaml/lml/pipeline"
60
+ require "lutaml/lml/positioned"
61
+ require "lutaml/lml/preprocessor"
62
+ require "lutaml/lml/quoting"
63
+ require "lutaml/lml/source"
64
+ require "lutaml/lml/source_position"
65
+ require "lutaml/lml/symbol_index"
66
+ require "lutaml/lml/transform"
67
+ require "lutaml/lml/types"
68
+ require "lutaml/lml/validator"
69
+ require "lutaml/lml/version"
70
+ require "lutaml/lml/view_resolution"
71
+ require "lutaml/lml/view_resolver"
72
+ require "lutaml/lml/yaml_parser"
42
73
  require "lutaml/model/adapter_resolver"
43
74
  require "lutaml/model/adapter_scope"
44
75
  require "lutaml/model/attribute"
@@ -224,6 +255,62 @@ require "lutaml/key_value/data_model/element"
224
255
  require "lutaml/key_value/transformation/collection_serializer"
225
256
  require "lutaml/key_value/transformation/rule_compiler"
226
257
  require "lutaml/key_value/transformation/value_serializer"
258
+ require "lutaml/lml/data_processor/attribute_processing"
259
+ require "lutaml/lml/data_processor/collection_processing"
260
+ require "lutaml/lml/data_processor/instance_processing"
261
+ require "lutaml/lml/data_processor/value_declaration_processing"
262
+ require "lutaml/lml/data_processor/value_processing"
263
+ require "lutaml/lml/data_processor/view_processing"
264
+ require "lutaml/lml/executor/adapter_helpers"
265
+ require "lutaml/lml/executor/condition_evaluator"
266
+ require "lutaml/lml/executor/format_adapter"
267
+ require "lutaml/lml/executor/xml_adapter"
268
+ require "lutaml/lml/formatter/base"
269
+ require "lutaml/lml/formatter/canonical"
270
+ require "lutaml/lml/layout/engine"
271
+ require "lutaml/lml/lsp/conversions"
272
+ require "lutaml/lml/lsp/keywords"
273
+ require "lutaml/lml/lsp/server"
274
+ require "lutaml/lml/lsp/store"
275
+ require "lutaml/lml/lsp/transport"
276
+ require "lutaml/lml/model_compiler/enums"
277
+ require "lutaml/lml/model_compiler/hydration"
278
+ require "lutaml/lml/model_compiler/serialization_mappings"
279
+ require "lutaml/lml/model_compiler/string_formats"
280
+ require "lutaml/lml/model_compiler/validation"
281
+ require "lutaml/lml/models/action"
282
+ require "lutaml/lml/models/association"
283
+ require "lutaml/lml/models/cardinality"
284
+ require "lutaml/lml/models/collection"
285
+ require "lutaml/lml/models/constraint"
286
+ require "lutaml/lml/models/data_type"
287
+ require "lutaml/lml/models/derived_field"
288
+ require "lutaml/lml/models/diagram"
289
+ require "lutaml/lml/models/document"
290
+ require "lutaml/lml/models/enum"
291
+ require "lutaml/lml/models/fidelity"
292
+ require "lutaml/lml/models/group"
293
+ require "lutaml/lml/models/instance"
294
+ require "lutaml/lml/models/instance_collection"
295
+ require "lutaml/lml/models/instances_export"
296
+ require "lutaml/lml/models/instances_import"
297
+ require "lutaml/lml/models/mapping"
298
+ require "lutaml/lml/models/mapping_rule"
299
+ require "lutaml/lml/models/member_field"
300
+ require "lutaml/lml/models/namespace"
301
+ require "lutaml/lml/models/operation"
302
+ require "lutaml/lml/models/operation_parameter"
303
+ require "lutaml/lml/models/package"
304
+ require "lutaml/lml/models/primitive_type"
305
+ require "lutaml/lml/models/reference"
306
+ require "lutaml/lml/models/serialization_mapping"
307
+ require "lutaml/lml/models/string_format"
308
+ require "lutaml/lml/models/top_element_attribute"
309
+ require "lutaml/lml/models/uml_class"
310
+ require "lutaml/lml/models/value"
311
+ require "lutaml/lml/models/view_filter"
312
+ require "lutaml/lml/models/view_import"
313
+ require "lutaml/lml/types/text_type"
227
314
  require "lutaml/model/cached_type_resolver/mutex_hash_cache"
228
315
  require "lutaml/model/consolidation/engine"
229
316
  require "lutaml/model/consolidation_rule/dispatch_block"
@@ -388,6 +475,7 @@ require "lutaml/toml/adapter/mapping_rule"
388
475
  require "lutaml/toml/adapter/transform"
389
476
  require "lutaml/xml/adapter/adapter_helpers"
390
477
  require "lutaml/xml/adapter/base_adapter"
478
+ require "lutaml/xml/adapter/moxml_adapter"
391
479
  require "lutaml/xml/adapter/namespace_data"
392
480
  require "lutaml/xml/adapter/namespace_uri_collector"
393
481
  require "lutaml/xml/adapter/oga_adapter"
@@ -476,6 +564,10 @@ require "lutaml/key_value/adapter/yamls/mapping"
476
564
  require "lutaml/key_value/adapter/yamls/mapping_rule"
477
565
  require "lutaml/key_value/adapter/yamls/standard_adapter"
478
566
  require "lutaml/key_value/adapter/yamls/transform"
567
+ require "lutaml/lml/format/adapter/document"
568
+ require "lutaml/lml/format/adapter/mapping"
569
+ require "lutaml/lml/format/adapter/standard_adapter"
570
+ require "lutaml/lml/format/adapter/transform"
479
571
  require "lutaml/model/error/register/not_registrable_class_error"
480
572
  require "lutaml/model/error/type/invalid_value_error"
481
573
  require "lutaml/model/error/type/max_bound_error"
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class AssociationLabelResolver
6
+ def enrich(document)
7
+ class_index = build_class_index(document)
8
+ document.associations.each do |assoc|
9
+ enrich_owner_end(assoc, class_index)
10
+ enrich_member_end(assoc, class_index)
11
+ end
12
+ document
13
+ end
14
+
15
+ private
16
+
17
+ def build_class_index(document)
18
+ document.all_classes.to_h { |klass| [klass.name, klass] }
19
+ end
20
+
21
+ def enrich_owner_end(assoc, class_index)
22
+ return if assoc.owner_end_attribute_name
23
+
24
+ owner_class = class_index[assoc.owner_end.to_s]
25
+ return unless owner_class
26
+
27
+ attr = find_attribute_by_type(owner_class, assoc.member_end.to_s)
28
+ return unless attr
29
+
30
+ assoc.owner_end_attribute_name = attr.name
31
+ assoc.owner_end_cardinality = attr.cardinality if attr.cardinality
32
+ end
33
+
34
+ def enrich_member_end(assoc, class_index)
35
+ return if assoc.member_end_attribute_name
36
+
37
+ member_class = class_index[assoc.member_end.to_s]
38
+ return unless member_class
39
+
40
+ attr = find_attribute_by_type(member_class, assoc.owner_end.to_s)
41
+ return unless attr
42
+
43
+ assoc.member_end_attribute_name = attr.name
44
+ assoc.member_end_cardinality = attr.cardinality if attr.cardinality
45
+ end
46
+
47
+ def find_attribute_by_type(klass, target_type_name)
48
+ klass.attributes&.find { |a| a.type == target_type_name }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,133 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class DataProcessor
6
+ # Normalizes attribute entries from the parse tree: merges
7
+ # comma-form groups, extracts names/types/values, and applies the
8
+ # nested attribute/property structure.
9
+ module AttributeProcessing
10
+ EXCLUDED_PASS_THROUGH_KEYS = %i[key value comments add attributes properties type_literal].freeze
11
+
12
+ def process_attributes(obj)
13
+ case obj
14
+ when Array then process_attributes_array(obj)
15
+ when Hash then process_attributes_hash(obj)
16
+ end
17
+ end
18
+
19
+ def process_attributes_array(obj)
20
+ return [] if obj.empty?
21
+ return obj.map { |item| process_attributes(item) } unless named_attribute_entries?(obj)
22
+ return merge_named_entries(obj) unless single_key_hashes?(obj)
23
+
24
+ obj.each_with_object({}) { |item, hash| append_uniform_entry(hash, item) }
25
+ end
26
+
27
+ def append_uniform_entry(hash, item)
28
+ hash[:properties] ||= []
29
+ if item.key?(:properties)
30
+ hash[:properties] << process_attributes(item[:properties])
31
+ else
32
+ hash.merge!(process_attributes(item))
33
+ end
34
+ end
35
+
36
+ # Attribute-definition groups split across capture depths (e.g. the
37
+ # comma form: {name, type} beside a nested {value_set}) combine into
38
+ # one attribute entry. Key/value pair lists (import/export maps)
39
+ # carry :key and are never merged.
40
+ def named_attribute_entries?(obj)
41
+ obj.any? { |e| e.is_a?(Hash) && e.key?(:name) } &&
42
+ obj.all? { |e| e.is_a?(Hash) && !e.key?(:key) }
43
+ end
44
+
45
+ COLLECTION_KEYS = %i[properties attributes instances].freeze
46
+
47
+ def merge_named_entries(obj)
48
+ obj.each_with_object({}) do |item, hash|
49
+ process_attributes(item).each do |key, value|
50
+ hash[key] = merge_attribute_value(hash[key], key, value)
51
+ end
52
+ end
53
+ end
54
+
55
+ def merge_attribute_value(existing, key, value)
56
+ return merge_collection_value(existing, value) if COLLECTION_KEYS.include?(key)
57
+ return existing + value if existing.is_a?(Array) && value.is_a?(Array)
58
+
59
+ value
60
+ end
61
+
62
+ def merge_collection_value(existing, value)
63
+ current = if existing.is_a?(Array)
64
+ existing
65
+ else
66
+ (existing ? [existing] : [])
67
+ end
68
+ current + (value.is_a?(Array) ? value : [value])
69
+ end
70
+
71
+ def process_attributes_hash(obj)
72
+ result = extract_name_and_value(obj)
73
+ convert_instance_type(result)
74
+ result[:extended] = !obj[:add].nil? if obj.key?(:add)
75
+ result[:literal] = true if obj.key?(:type_literal)
76
+ apply_nested_attributes(result, obj)
77
+ apply_remaining_keys(result, obj)
78
+ translate_values_argument(result)
79
+ result
80
+ end
81
+
82
+ def single_key_hashes?(arr)
83
+ arr.all? { |e| e.is_a?(Hash) && e.keys.size == 1 }
84
+ end
85
+
86
+ def extract_name_and_value(obj)
87
+ result = {}
88
+ result[:name] = strip_argument_colon(obj[:key]) if obj.key?(:key)
89
+
90
+ if obj.key?(:comments)
91
+ result[:name] = "Comment"
92
+ result[:value] = process_value(obj[:comments]).last
93
+ elsif obj.key?(:value)
94
+ result[:type], result[:value] = process_value(obj[:value])
95
+ end
96
+
97
+ result
98
+ end
99
+
100
+ def convert_instance_type(result)
101
+ return unless result[:type]&.start_with?("Instance")
102
+
103
+ value = result.delete(:value)
104
+ result[:instances] = value.is_a?(Array) ? value : [value]
105
+ result.delete(:type)
106
+ end
107
+
108
+ def apply_nested_attributes(result, obj)
109
+ result[:attributes] = process_attributes(obj[:attributes]) if obj.key?(:attributes)
110
+ result[:properties] = process_attributes(obj[:properties]) if obj.key?(:properties)
111
+ end
112
+
113
+ def apply_remaining_keys(result, obj)
114
+ obj.each do |key, value|
115
+ next if EXCLUDED_PASS_THROUGH_KEYS.include?(key)
116
+
117
+ value = strip_argument_colon(value) if key == :name
118
+ result[key] = value unless result.key?(key)
119
+ end
120
+ end
121
+
122
+ # `default: "Clear"` uses the colon separator (RS 3001 §Attribute);
123
+ # the colon lands in the captured name and must not. A quoted key
124
+ # is verbatim, so a trailing colon there is content.
125
+ def strip_argument_colon(name)
126
+ return name[:string] if name.is_a?(Hash) && name.key?(:string)
127
+
128
+ name.to_s.delete_suffix(":")
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class DataProcessor
6
+ module CollectionProcessing
7
+ def process_collections(obj)
8
+ obj.each_with_object({}) do |(key, value), result|
9
+ result[key] = process_value(value).last
10
+ end
11
+ end
12
+
13
+ def process_imports(obj)
14
+ process_io_definitions(obj)
15
+ end
16
+
17
+ def process_exports(obj)
18
+ process_io_definitions(obj)
19
+ end
20
+
21
+ private
22
+
23
+ def process_io_definitions(obj)
24
+ obj.map do |item|
25
+ item.each_with_object({}) do |(key, value), result|
26
+ result[key] = if key == :attributes
27
+ process_attributes(value)
28
+ else
29
+ process_value(value).last
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class DataProcessor
6
+ module InstanceProcessing
7
+ INSTANCE_KEY_HANDLERS = {
8
+ instance: :process_instance,
9
+ collections: :process_collections,
10
+ imports: :process_imports,
11
+ exports: :process_exports,
12
+ }.freeze
13
+
14
+ INSTANCE_FIELD_HANDLERS = {
15
+ instance_type: :handle_instance_type,
16
+ isa: :handle_instance_isa,
17
+ instance: :handle_instance_nested,
18
+ attributes: :handle_instance_attributes,
19
+ template: :handle_instance_template,
20
+ }.freeze
21
+
22
+ def process_instances(obj)
23
+ return [] unless obj.is_a?(Array)
24
+
25
+ obj.each_with_object({}) do |instance, acc|
26
+ acc[:instances] ||= []
27
+ key = INSTANCE_KEY_HANDLERS.keys.find { |k| instance.key?(k) }
28
+ next unless key
29
+
30
+ append_result(acc, key, public_send(INSTANCE_KEY_HANDLERS[key], instance[key]))
31
+ end
32
+ end
33
+
34
+ def process_instance(hash)
35
+ hash.each_with_object({}) do |(key, value), result|
36
+ handler = INSTANCE_FIELD_HANDLERS[key]
37
+ if handler
38
+ public_send(handler, value, result)
39
+ else
40
+ result[key] = process_value(value).last
41
+ end
42
+ end
43
+ end
44
+
45
+ def handle_instance_type(value, result)
46
+ result[:type] = process_value(value).last
47
+ end
48
+
49
+ def handle_instance_isa(value, result)
50
+ result[:isa] = process_value(value).last
51
+ end
52
+
53
+ def handle_instance_nested(value, result)
54
+ result[:instance] = process_instance(value)
55
+ end
56
+
57
+ def handle_instance_attributes(value, result)
58
+ result[:attributes] = process_attributes(value)
59
+ end
60
+
61
+ def handle_instance_template(value, result)
62
+ result[:template] = process_attributes(value[:attributes])
63
+ end
64
+
65
+ private
66
+
67
+ def append_result(acc, key, result)
68
+ case key
69
+ when :instance then acc[:instances] << result
70
+ when :collections then (acc[:collections] ||= []) << result
71
+ else (acc[key] ||= []).concat(result)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class DataProcessor
6
+ # RS 3001 §Value/§Attribute argument normalization: the canonical
7
+ # `value` construct and the attribute `values` argument.
8
+ module ValueDeclarationProcessing
9
+ # `value <name> { block }` is the canonical enum member; the bare
10
+ # identifier member is its documented shortcut. Normalize into the
11
+ # member shape the shortcut produces: the value block's `definition`
12
+ # lines become the member description and its attribute pairs become
13
+ # member payload properties.
14
+ def process_value_declaration(decl)
15
+ inner = { name: unwrap_string(decl[:value_name]) }
16
+ inner[:position] = decl[:position] if decl[:position]
17
+ Array(decl[:members]).each do |member|
18
+ normalize_value_member(inner, member)
19
+ end
20
+ { attributes: inner }
21
+ end
22
+
23
+ # `values <enum>` types the attribute with the named enum;
24
+ # `values { v1, v2 }` carries an inline value set that the compiler
25
+ # expands into an anonymous enum.
26
+ def translate_values_argument(result)
27
+ if result.key?(:value_set_ref)
28
+ ref = unwrap_string(result.delete(:value_set_ref))
29
+ result[:type] = ref unless result[:type]
30
+ end
31
+ return unless result.key?(:value_set)
32
+
33
+ result[:value_set] = Array(result[:value_set][:items]).map { |item| unwrap_data_value(item[:item]) }
34
+ end
35
+
36
+ private
37
+
38
+ def normalize_value_member(inner, member)
39
+ if member.key?(:definition)
40
+ (inner[:attributes] ||= []) << { name: "description", type: unwrap_string(member[:definition]) }
41
+ elsif member.key?(:instance)
42
+ # The bare `instance { ... }` capture is the instance-body
43
+ # hash; it must go through instance processing so its
44
+ # members become attribute entries, not raw pairs.
45
+ bodies = member[:instance].is_a?(Hash) ? [member[:instance]] : Array(member[:instance])
46
+ bodies.each do |body|
47
+ entry = body.is_a?(Hash) ? process_instance(body) : body
48
+ (inner[:instances] ||= []) << entry
49
+ end
50
+ elsif member.key?(:attributes)
51
+ (inner[:properties] ||= []) << member[:attributes]
52
+ elsif member.key?(:key)
53
+ (inner[:properties] ||= []) << extract_name_and_value(member)
54
+ end
55
+ end
56
+
57
+ def unwrap_data_value(item)
58
+ return item unless item.is_a?(Hash)
59
+
60
+ item[:string] || item[:number] || item[:float] ||
61
+ item[:boolean] || item[:name] || item
62
+ end
63
+
64
+ def unwrap_string(value)
65
+ value.is_a?(Hash) && value.key?(:string) ? value[:string] : value
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end