lutaml-model 0.8.187 → 0.8.188

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) 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/schema.rb +38 -0
  125. data/lib/lutaml/xml/schema/xsd/schema_validator.rb +1 -1
  126. data/lib/lutaml/xml/schema/xsd.rb +1 -0
  127. data/lib/lutaml/xml/schema/xsd_schema.rb +1 -1
  128. data/lib/lutaml/xml/serialization/format_conversion.rb +6 -0
  129. data/lib/lutaml/xml/xsd_validator.rb +1 -1
  130. data/lutaml-model.gemspec +2 -0
  131. data/spec/lml/fixtures/dsl/broken_diagram.lutaml +34 -0
  132. data/spec/lml/fixtures/dsl/diagram.lutaml +4 -0
  133. data/spec/lml/fixtures/dsl/diagram_attributes.lutaml +6 -0
  134. data/spec/lml/fixtures/dsl/diagram_blank_definion.lutaml +6 -0
  135. data/spec/lml/fixtures/dsl/diagram_blank_entities.lutaml +8 -0
  136. data/spec/lml/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
  137. data/spec/lml/fixtures/dsl/diagram_class_fields.lutaml +25 -0
  138. data/spec/lml/fixtures/dsl/diagram_commented_includes.lutaml +5 -0
  139. data/spec/lml/fixtures/dsl/diagram_comments.lutaml +28 -0
  140. data/spec/lml/fixtures/dsl/diagram_concept_model.lutaml +132 -0
  141. data/spec/lml/fixtures/dsl/diagram_data_types.lutaml +44 -0
  142. data/spec/lml/fixtures/dsl/diagram_definitions.lutaml +25 -0
  143. data/spec/lml/fixtures/dsl/diagram_includes.lutaml +6 -0
  144. data/spec/lml/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
  145. data/spec/lml/fixtures/dsl/diagram_non_existing_include.lutaml +6 -0
  146. data/spec/lml/fixtures/dsl/shared.lutaml +5 -0
  147. data/spec/lml/fixtures/dsl/shared1.lutaml +4 -0
  148. data/spec/lml/fixtures/generated_dot/AddressClassProfile.dot +170 -0
  149. data/spec/lml/fixtures/generated_dot/AddressProfile.dot +34 -0
  150. data/spec/lml/fixtures/generated_dot/address_class_profile_with_associations.dot +127 -0
  151. data/spec/lml/fixtures/generated_dot/address_profile_with_associations.dot +28 -0
  152. data/spec/lml/fixtures/generated_dot/document.dot +28 -0
  153. data/spec/lml/fixtures/generated_dot/document.dot.backup +33 -0
  154. data/spec/lml/fixtures/generated_dot/document_with_fidelity.dot +27 -0
  155. data/spec/lml/fixtures/lml/data_s102_check.lml +79 -0
  156. data/spec/lml/fixtures/lml/data_s158_metadata.lml +28 -0
  157. data/spec/lml/fixtures/lml/iho_data_models.lml +59 -0
  158. data/spec/lml/fixtures/lml/iho_s102_check.lml +101 -0
  159. data/spec/lml/fixtures/mixed_lml/diagram.lml +26 -0
  160. data/spec/lml/fixtures/mixed_lml/instances.lml +72 -0
  161. data/spec/lml/fixtures/mixed_lml/model.lml +30 -0
  162. data/spec/lml/fixtures/real_world/basicdoc-models/AdmonitionType.lutaml +32 -0
  163. data/spec/lml/fixtures/real_world/basicdoc-models/BasicBlock.lutaml +11 -0
  164. data/spec/lml/fixtures/real_world/basicdoc-models/BasicDocument.lutaml +41 -0
  165. data/spec/lml/fixtures/real_world/basicdoc-models/BasicSection.lutaml +38 -0
  166. data/spec/lml/fixtures/real_world/basicdoc-models/BibliographicItem.lutaml +6 -0
  167. data/spec/lml/fixtures/real_world/basicdoc-models/FigureBlock.lutaml +65 -0
  168. data/spec/lml/fixtures/real_world/basicdoc-models/FormattedString.lutaml +12 -0
  169. data/spec/lml/fixtures/real_world/basicdoc-models/List.lutaml +12 -0
  170. data/spec/lml/fixtures/real_world/basicdoc-models/OrderedListType.lutaml +32 -0
  171. data/spec/lml/fixtures/real_world/basicdoc-models/Signature.lutaml +22 -0
  172. data/spec/lml/fixtures/real_world/basicdoc-models/String.lutaml +2 -0
  173. data/spec/lml/fixtures/real_world/basicdoc-models/TableBlock.lutaml +60 -0
  174. data/spec/lml/fixtures/real_world/basicdoc-models/TextElement.lutaml +13 -0
  175. data/spec/lml/fixtures/real_world/basicdoc-models/Uri.lutaml +7 -0
  176. data/spec/lml/fixtures/real_world/metanorma-model-iso/BibliographicItem.lutaml +4 -0
  177. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoAdmonitionType.lutaml +31 -0
  178. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoBibDataExtensionType.lutaml +40 -0
  179. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoSections.lutaml +30 -0
  180. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoStandardDocument.lutaml +46 -0
  181. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoTerm.lutaml +20 -0
  182. data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardBibDataExtensionType.lutaml +2 -0
  183. data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardDocument.lutaml +2 -0
  184. data/spec/lml/fixtures/rs3001/01_class_tail_comment.lml +5 -0
  185. data/spec/lml/fixtures/rs3001/02_definition_block.lml +9 -0
  186. data/spec/lml/fixtures/rs3001/03_package_ceramics.lml +20 -0
  187. data/spec/lml/fixtures/rs3001/04_attribute_definition_form.lml +10 -0
  188. data/spec/lml/fixtures/rs3001/05_attribute_cardinality_unbounded.lml +10 -0
  189. data/spec/lml/fixtures/rs3001/06_attribute_values_set.lml +10 -0
  190. data/spec/lml/fixtures/rs3001/07_attribute_pattern.lml +10 -0
  191. data/spec/lml/fixtures/rs3001/08_attribute_default_colon.lml +15 -0
  192. data/spec/lml/fixtures/rs3001/09_value_porcelain.lml +9 -0
  193. data/spec/lml/fixtures/rs3001/10_enum_glaze_technique.lml +19 -0
  194. data/spec/lml/fixtures/rs3001/11_enum_values_as_instances.lml +29 -0
  195. data/spec/lml/fixtures/rs3001/12_instance_named.lml +13 -0
  196. data/spec/lml/fixtures/rs3001/13_instances_collection_refs.lml +11 -0
  197. data/spec/lml/fixtures/rs3001/14_require_models.lml +7 -0
  198. data/spec/lml/fixtures/rs3001/15_comment_line.lml +1 -0
  199. data/spec/lml/fixtures/rs3001/16_comment_tail.lml +5 -0
  200. data/spec/lml/fixtures/rs3001/17_comment_documented_class.lml +5 -0
  201. data/spec/lml/fixtures/rs3001/18_comment_block.lml +4 -0
  202. data/spec/lml/fixtures/rs3001/19_top_level_instance_definition.lml +21 -0
  203. data/spec/lml/fixtures/rs3001/20_instance_typed_definition.lml +22 -0
  204. data/spec/lml/fixtures/rs3001/21_instance_collection_studios.lml +19 -0
  205. data/spec/lml/fixtures/rs3001/22_instance_collection_tiles.lml +15 -0
  206. data/spec/lml/fixtures/rs3001/23_reference_cross_collection.lml +11 -0
  207. data/spec/lml/fixtures/rs3001/24_null_and_empty.lml +15 -0
  208. data/spec/lml/fixtures/rs3001/25_string_escapes.lml +23 -0
  209. data/spec/lml/fixtures/rs3001/26_quoted_keys.lml +7 -0
  210. data/spec/lml/fixtures/test.lutaml +20 -0
  211. data/spec/lml/fixtures/test_data/components.csv +4 -0
  212. data/spec/lml/fixtures/test_data/products.xml +18 -0
  213. data/spec/lml/fixtures/uml/address_class_profile_with_associations.yml +58 -0
  214. data/spec/lml/fixtures/uml/address_profile_with_associations.yml +31 -0
  215. data/spec/lml/fixtures/uml/association.yml +11 -0
  216. data/spec/lml/fixtures/uml/class.yml +28 -0
  217. data/spec/lml/fixtures/uml/data_type.yml +30 -0
  218. data/spec/lml/fixtures/uml/diagram.yml +7 -0
  219. data/spec/lml/fixtures/uml/document.yml +44 -0
  220. data/spec/lml/fixtures/uml/document_with_fidelity.yml +47 -0
  221. data/spec/lml/fixtures/uml/enum.yml +14 -0
  222. data/spec/lml/fixtures/uml/operation.yml +8 -0
  223. data/spec/lml/fixtures/uml/package.yml +10 -0
  224. data/spec/lml/fixtures/uml/top_element.yml +11 -0
  225. data/spec/lml/fixtures/uml/top_element_attribute.yml +10 -0
  226. data/spec/lml/fixtures/uml/trigger.yml +12 -0
  227. data/spec/lml/fixtures/uml/value.yml +8 -0
  228. data/spec/lml/fixtures/view/cycle_a.lutaml +3 -0
  229. data/spec/lml/fixtures/view/cycle_b.lutaml +3 -0
  230. data/spec/lml/fixtures/view/import_model.lutaml +3 -0
  231. data/spec/lml/fixtures/view/import_view.lutaml +3 -0
  232. data/spec/lml/fixtures/view/import_with_hide.lutaml +4 -0
  233. data/spec/lml/fixtures/view/import_with_show.lutaml +4 -0
  234. data/spec/lml/fixtures/view/models/bar.lutaml +3 -0
  235. data/spec/lml/fixtures/view/models/baz.lutaml +3 -0
  236. data/spec/lml/fixtures/view/models/foo.lutaml +4 -0
  237. data/spec/lml/integration/instance_import_export_spec.rb +102 -0
  238. data/spec/lml/lml_spec_setup.rb +25 -0
  239. data/spec/lml/lutaml/lml/association_label_resolver_spec.rb +139 -0
  240. data/spec/lml/lutaml/lml/data_processor_spec.rb +274 -0
  241. data/spec/lml/lutaml/lml/declarations_spec.rb +337 -0
  242. data/spec/lml/lutaml/lml/document_builder_registry_spec.rb +52 -0
  243. data/spec/lml/lutaml/lml/document_builder_spec.rb +99 -0
  244. data/spec/lml/lutaml/lml/element_visibility_spec.rb +128 -0
  245. data/spec/lml/lutaml/lml/entity_types_spec.rb +56 -0
  246. data/spec/lml/lutaml/lml/enum_spec.rb +77 -0
  247. data/spec/lml/lutaml/lml/executor/adapter_helpers_spec.rb +96 -0
  248. data/spec/lml/lutaml/lml/executor/condition_evaluator_spec.rb +393 -0
  249. data/spec/lml/lutaml/lml/executor/csv_adapter_spec.rb +151 -0
  250. data/spec/lml/lutaml/lml/executor/format_adapter_spec.rb +31 -0
  251. data/spec/lml/lutaml/lml/executor/xml_adapter_spec.rb +201 -0
  252. data/spec/lml/lutaml/lml/executor_spec.rb +71 -0
  253. data/spec/lml/lutaml/lml/format_adapter_spec.rb +272 -0
  254. data/spec/lml/lutaml/lml/format_autoload_spec.rb +31 -0
  255. data/spec/lml/lutaml/lml/grammar_spec.rb +581 -0
  256. data/spec/lml/lutaml/lml/has_attributes_spec.rb +54 -0
  257. data/spec/lml/lutaml/lml/import_resolver_spec.rb +116 -0
  258. data/spec/lml/lutaml/lml/instance_hydration_spec.rb +178 -0
  259. data/spec/lml/lutaml/lml/lsp/server_spec.rb +285 -0
  260. data/spec/lml/lutaml/lml/model_compiler_spec.rb +406 -0
  261. data/spec/lml/lutaml/lml/models/association_spec.rb +40 -0
  262. data/spec/lml/lutaml/lml/models/collection_spec.rb +27 -0
  263. data/spec/lml/lutaml/lml/models/data_type_spec.rb +34 -0
  264. data/spec/lml/lutaml/lml/models/diagram_spec.rb +18 -0
  265. data/spec/lml/lutaml/lml/models/document_spec.rb +64 -0
  266. data/spec/lml/lutaml/lml/models/enum_spec.rb +42 -0
  267. data/spec/lml/lutaml/lml/models/inheritance_spec.rb +77 -0
  268. data/spec/lml/lutaml/lml/models/instance_collection_spec.rb +62 -0
  269. data/spec/lml/lutaml/lml/models/instance_spec.rb +81 -0
  270. data/spec/lml/lutaml/lml/models/instances_export_spec.rb +23 -0
  271. data/spec/lml/lutaml/lml/models/instances_import_spec.rb +28 -0
  272. data/spec/lml/lutaml/lml/models/package_spec.rb +26 -0
  273. data/spec/lml/lutaml/lml/models/primitive_type_spec.rb +34 -0
  274. data/spec/lml/lutaml/lml/models/top_element_attribute_spec.rb +153 -0
  275. data/spec/lml/lutaml/lml/models/uml_class_spec.rb +70 -0
  276. data/spec/lml/lutaml/lml/models_version_spec.rb +27 -0
  277. data/spec/lml/lutaml/lml/operations_spec.rb +59 -0
  278. data/spec/lml/lutaml/lml/parser_spec.rb +348 -0
  279. data/spec/lml/lutaml/lml/pipeline_spec.rb +93 -0
  280. data/spec/lml/lutaml/lml/preprocessor_spec.rb +174 -0
  281. data/spec/lml/lutaml/lml/property_laws_spec.rb +344 -0
  282. data/spec/lml/lutaml/lml/real_world_spec.rb +191 -0
  283. data/spec/lml/lutaml/lml/reference_spec.rb +64 -0
  284. data/spec/lml/lutaml/lml/round_trip_spec.rb +457 -0
  285. data/spec/lml/lutaml/lml/rs3001_corpus_spec.rb +83 -0
  286. data/spec/lml/lutaml/lml/rs3001_syntax_spec.rb +77 -0
  287. data/spec/lml/lutaml/lml/serialization_mapping_spec.rb +127 -0
  288. data/spec/lml/lutaml/lml/source_spec.rb +62 -0
  289. data/spec/lml/lutaml/lml/transform_spec.rb +37 -0
  290. data/spec/lml/lutaml/lml/types/text_type_spec.rb +43 -0
  291. data/spec/lml/lutaml/lml/validator_spec.rb +238 -0
  292. data/spec/lml/lutaml/lml/view_resolver_spec.rb +78 -0
  293. data/spec/lml/lutaml/lml/view_spec.rb +112 -0
  294. data/spec/lml/lutaml/parsers/dsl_spec.rb +275 -0
  295. data/spec/lml/lutaml/parsers/yaml_spec.rb +52 -0
  296. data/spec/lml/lutaml/qualified_type_spec.rb +33 -0
  297. data/spec/lutaml/model/adapter_type_unset_restore_spec.rb +61 -0
  298. data/spec/lutaml/model/custom_bibtex_adapter_spec.rb +4 -1
  299. data/spec/lutaml/xml/adapter/moxml_lane_spec.rb +112 -0
  300. data/spec/lutaml/xml/adapter_metadata_default_spec.rb +21 -2
  301. data/spec/lutaml/xml/adapter_moxml_engine_spec.rb +57 -0
  302. data/spec/lutaml/xml/leptris/native_emission_plain_model_spec.rb +50 -0
  303. data/spec/lutaml/xml/plain_model_mapping_resolution_spec.rb +88 -0
  304. data/spec/lutaml/xml/schema/xsd/vc_versioning_spec.rb +49 -0
  305. data/spec/lutaml/xml/schema/xsd/xsd_11_constructs_spec.rb +43 -0
  306. metadata +286 -2
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../lml_spec_setup"
5
+ require "tmpdir"
6
+ require "fileutils"
7
+
8
+ RSpec.describe Lutaml::Lml::ImportResolver do
9
+ describe "#resolve" do
10
+ it "resolves glob patterns to model files" do
11
+ dir = Dir.mktmpdir
12
+ File.write(File.join(dir, "foo.lutaml"), "class Foo { name: String }")
13
+ File.write(File.join(dir, "bar.lutaml"), "class Bar { count: Integer }")
14
+
15
+ doc = Lutaml::Lml::Document.new(
16
+ view_imports: [Lutaml::Lml::ViewImport.new(path: File.join(dir, "*.lutaml"))],
17
+ )
18
+ resolver = described_class.new(nil)
19
+ entities, _associations = resolver.resolve(doc)
20
+
21
+ expect(entities.values.map(&:name)).to include("Foo", "Bar")
22
+ ensure
23
+ FileUtils.rm_rf(dir)
24
+ end
25
+
26
+ it "imports a model file whose comment mentions view (no sniffing)" do
27
+ dir = Dir.mktmpdir
28
+ model = File.join(dir, "model.lutaml")
29
+ File.write(model, "// this is a view of the sensor domain\nclass Sensor {}")
30
+
31
+ doc = Lutaml::Lml::Document.new(
32
+ view_imports: [Lutaml::Lml::ViewImport.new(path: model)],
33
+ )
34
+ resolver = described_class.new(nil)
35
+ entities, = resolver.resolve(doc)
36
+ expect(entities.keys).to eq(["Sensor"])
37
+ ensure
38
+ FileUtils.rm_rf(dir)
39
+ end
40
+
41
+ it "raises when a glob matches no files" do
42
+ doc = Lutaml::Lml::Document.new(
43
+ view_imports: [Lutaml::Lml::ViewImport.new(path: "/nonexistent/path/*.lutaml")],
44
+ )
45
+ resolver = described_class.new(nil)
46
+ expect { resolver.resolve(doc) }
47
+ .to raise_error(Lutaml::Lml::ImportError, /matched no files/)
48
+ end
49
+
50
+ it "silently deduplicates identical entities imported twice" do
51
+ dir = Dir.mktmpdir
52
+ File.write(File.join(dir, "a.lutaml"), "class Foo { x: String }")
53
+ File.write(File.join(dir, "b.lutaml"), "class Foo { x: String }")
54
+
55
+ doc = Lutaml::Lml::Document.new(
56
+ view_imports: [Lutaml::Lml::ViewImport.new(path: File.join(dir, "*.lutaml"))],
57
+ )
58
+ resolver = described_class.new(nil)
59
+ entities, = resolver.resolve(doc)
60
+
61
+ expect(entities.keys).to eq(["Foo"])
62
+ ensure
63
+ FileUtils.rm_rf(dir)
64
+ end
65
+
66
+ it "raises when the same name is defined differently in two imports" do
67
+ dir = Dir.mktmpdir
68
+ File.write(File.join(dir, "a.lutaml"), "class Foo { x: String }")
69
+ File.write(File.join(dir, "b.lutaml"), "class Foo { y: Integer }")
70
+
71
+ doc = Lutaml::Lml::Document.new(
72
+ view_imports: [Lutaml::Lml::ViewImport.new(path: File.join(dir, "*.lutaml"))],
73
+ )
74
+ resolver = described_class.new(nil)
75
+
76
+ expect { resolver.resolve(doc) }
77
+ .to raise_error(Lutaml::Lml::ImportError, /'Foo' is defined differently/)
78
+ ensure
79
+ FileUtils.rm_rf(dir)
80
+ end
81
+
82
+ it "resolves relative to base_path" do
83
+ dir = Dir.mktmpdir
84
+ File.write(File.join(dir, "model.lutaml"), "class Baz {}")
85
+
86
+ view_file = File.join(dir, "view.lutaml")
87
+ File.write(view_file, "view V { import \"model.lutaml\" }")
88
+
89
+ doc = Lutaml::Lml.parse(File.new(view_file))
90
+ expect(doc.classes.map(&:name)).to include("Baz")
91
+ ensure
92
+ FileUtils.rm_rf(dir)
93
+ end
94
+
95
+ it "raises on unreadable files" do
96
+ skip "Unix file modes not enforced on Windows" if Gem.win_platform?
97
+ dir = Dir.mktmpdir
98
+ path = File.join(dir, "unreadable.lutaml")
99
+ File.write(path, "class Foo {}")
100
+ FileUtils.chmod(0o000, path)
101
+ doc = Lutaml::Lml::Document.new(
102
+ view_imports: [Lutaml::Lml::ViewImport.new(path: path)],
103
+ )
104
+ resolver = described_class.new(nil)
105
+ expect { resolver.resolve(doc) }
106
+ .to raise_error(Lutaml::Lml::ImportError, /cannot read import/)
107
+ ensure
108
+ begin
109
+ FileUtils.chmod(0o644, File.join(dir, "unreadable.lutaml"))
110
+ rescue StandardError
111
+ nil
112
+ end
113
+ FileUtils.rm_rf(dir)
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,178 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "stringio"
5
+
6
+ LAYOUT_LML = <<~LML
7
+ models M {
8
+ class Outer {
9
+ attribute inner, Inner { cardinality 1 }
10
+ attribute inners, Inner { cardinality 0..n }
11
+ }
12
+ class Inner {
13
+ attribute x, String
14
+ }
15
+ }
16
+ instance Outer {
17
+ inner = instance Inner { x = "one" }
18
+ inners = [instance Inner { x = "a" }]
19
+ }
20
+ LML
21
+
22
+ def compile_and_hydrate(lml)
23
+ source = StringIO.new(lml)
24
+ compiler = Lutaml::Lml::ModelCompiler.new
25
+ compiler.compile(source)
26
+ source.rewind
27
+ compiler.hydrate(source)
28
+ end
29
+
30
+ # RS 3001 §String values / §Instance: an explicit null assignment
31
+ # denotes the null value; an unassigned optional attribute is absent;
32
+ # both hydrate to nil, and a present empty string stays empty.
33
+ RSpec.describe "instance hydration semantics" do
34
+ describe "null and absence semantics" do
35
+ it "hydrates explicit null, absent, and present-empty distinctly" do
36
+ require "lutaml/lml/format"
37
+ compiled = Lutaml::Lml.compile(StringIO.new(<<~LML))
38
+ models NullSemantics {
39
+ class Fields {
40
+ attribute null_note { type String cardinality 0..1 }
41
+ attribute empty_note { type String cardinality 0..1 }
42
+ attribute absent_note { type String cardinality 0..1 }
43
+ }
44
+ }
45
+ LML
46
+ klass = compiled["Fields"]
47
+ inst = klass.from_lml(<<~LML)
48
+ instance Data {
49
+ null_note = null
50
+ empty_note = ""
51
+ }
52
+ LML
53
+ expect(inst.null_note).to be_nil
54
+ expect(inst.empty_note).to eq("")
55
+ expect(inst.absent_note).to be_nil
56
+ end
57
+ end
58
+
59
+ describe "nested instances (issue #17)" do
60
+ it "hydrates nested instances under collection attributes as arrays" do
61
+ hydrated = compile_and_hydrate(LAYOUT_LML)
62
+ expect(hydrated.inners).to be_an(Array)
63
+ expect(hydrated.inners.first.x).to eq("a")
64
+ end
65
+
66
+ it "hydrates a scalar attribute with one nested instance as the object" do
67
+ hydrated = compile_and_hydrate(LAYOUT_LML)
68
+ expect(hydrated.inner.x).to eq("one")
69
+ expect(hydrated.inner).not_to be_an(Array)
70
+ expect(hydrated.inners).to be_an(Array)
71
+ end
72
+
73
+ it "materializes inline maps as a Hash at the parse level (not corrupt text)" do
74
+ doc = Lutaml::Lml.parse_document(StringIO.new(<<~LML))
75
+ instance Cfg {
76
+ settings = { a = "1"; b = "2" }
77
+ }
78
+ LML
79
+ attr = doc.instance.attributes.first
80
+ cargo = attr.value.respond_to?(:value) ? attr.value.value : attr.value
81
+ expect(cargo).to eq(a: "1", b: "2")
82
+ end
83
+
84
+ it "accumulates repeated instances blocks" do
85
+ doc = Lutaml::Lml.parse_document(StringIO.new(<<~LML))
86
+ instances {
87
+ collection "A" {
88
+ validation { condition "count >= 0" }
89
+ }
90
+ }
91
+ instances {
92
+ collection "B" {
93
+ validation { condition "count >= 0" }
94
+ }
95
+ }
96
+ LML
97
+ expect(doc.instances.collections.map(&:name)).to eq(%w[A B])
98
+ end
99
+
100
+ it "errors on duplicate collection names across instances blocks" do
101
+ duplicate = "instances { collection \"A\" { } }\ninstances { collection \"A\" { } }\n"
102
+ expect { Lutaml::Lml.parse_document(StringIO.new(duplicate)) }
103
+ .to raise_error(Lutaml::Lml::Error, /duplicate collection name 'A'/)
104
+ end
105
+
106
+ # An untyped nested instance takes the enclosing attribute's type;
107
+ # the raw-hash path would leave a `_name` key on the value and defeat
108
+ # union member key-coverage.
109
+ it "hydrates an untyped nested instance under a typed attribute as the attribute class" do
110
+ hydrated = compile_and_hydrate(<<~LML)
111
+ models M {
112
+ class Outer {
113
+ attribute inner, Inner { cardinality 1 }
114
+ attribute inners, Inner { cardinality 0..n }
115
+ }
116
+ class Inner {
117
+ attribute x, String
118
+ }
119
+ }
120
+ instance Outer {
121
+ inner = instance { x = "one" }
122
+ inners = [instance { x = "a" }, instance { x = "b" }]
123
+ }
124
+ LML
125
+ expect(hydrated.inner).not_to be_a(Hash)
126
+ expect(hydrated.inner.x).to eq("one")
127
+ expect(hydrated.inners).to be_an(Array)
128
+ expect(hydrated.inners.map(&:x)).to eq(%w[a b])
129
+ end
130
+
131
+ it "hydrates an untyped nested instance under a union attribute via member key coverage" do
132
+ compiler = Lutaml::Lml::ModelCompiler.new
133
+ compiler.compile(StringIO.new(<<~LML))
134
+ models M {
135
+ class Holder {
136
+ attribute placeholder, String
137
+ }
138
+ class Inner {
139
+ attribute x, String
140
+ }
141
+ }
142
+ LML
143
+ holder = compiler.compiled_classes.fetch("Holder")
144
+ inner = compiler.compiled_classes.fetch("Inner")
145
+ holder.attribute :mixed, Lutaml::Model::Type::Union,
146
+ union_member_types: [inner, :string]
147
+
148
+ typed = compiler.hydrate(StringIO.new(<<~LML))
149
+ instance Holder {
150
+ mixed = instance { x = "deep" }
151
+ }
152
+ LML
153
+ expect(typed.mixed).to be_an_instance_of(inner)
154
+ expect(typed.mixed.x).to eq("deep")
155
+
156
+ scalar = compiler.hydrate(StringIO.new("instance Holder {\n mixed = shallow\n}\n"))
157
+ expect(scalar.mixed).to eq("shallow")
158
+ end
159
+
160
+ # Quoted attribute keys arrive from the grammar as {string: ...} capture
161
+ # nodes (issue #78); they must be unwrapped, not stringified.
162
+ it "preserves quoted attribute keys verbatim, padding and emptiness included" do
163
+ doc = Lutaml::Lml.parse_document(StringIO.new(<<~LML))
164
+ instance R {
165
+ data = instance {
166
+ " company name/address" = "Germany / DEU"
167
+ "" = "Mr Stephan"
168
+ }
169
+ }
170
+ LML
171
+ data = doc.instance.each_attribute.find { |n, _| n == "data" }
172
+ entry = data[2].first
173
+ names = []
174
+ entry.each_attribute { |name, _| names << name }
175
+ expect(names).to eq([" company name/address", ""])
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,285 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+ require "stringio"
6
+ require "json"
7
+ require "open3"
8
+ require "rbconfig"
9
+ require "lutaml/lml/lsp"
10
+
11
+ RSpec.describe "LSP server" do
12
+ def frame(message)
13
+ body = JSON.generate(message)
14
+ "Content-Length: #{body.bytesize}\r\n\r\n#{body}"
15
+ end
16
+
17
+ def parse_frames(raw)
18
+ scanner = StringIO.new(raw)
19
+ messages = []
20
+ loop do
21
+ headers = {}
22
+ while (line = scanner.gets)
23
+ line = line.chomp
24
+ break if line.empty?
25
+
26
+ key, value = line.split(": ", 2)
27
+ headers[key.to_s.downcase] = value
28
+ end
29
+ break unless headers["content-length"]
30
+
31
+ messages << JSON.parse(scanner.read(headers["content-length"].to_i))
32
+ end
33
+ messages
34
+ end
35
+
36
+ def run_session(messages)
37
+ input = StringIO.new
38
+ messages.each { |message| input.write(frame(message)) }
39
+ input.rewind
40
+ output = StringIO.new
41
+ server = Lutaml::Lml::Lsp::Server.new(
42
+ transport: Lutaml::Lml::Lsp::Transport.new(input: input, output: output),
43
+ )
44
+ code = server.run
45
+ [parse_frames(output.string), code]
46
+ end
47
+
48
+ def initialize_message(id = 1)
49
+ { "jsonrpc" => "2.0", "id" => id, "method" => "initialize", "params" => {} }
50
+ end
51
+
52
+ def open_message(uri, text)
53
+ {
54
+ "jsonrpc" => "2.0", "method" => "textDocument/didOpen",
55
+ "params" => {
56
+ "textDocument" => {
57
+ "uri" => uri, "languageId" => "lml", "version" => 1, "text" => text
58
+ },
59
+ }
60
+ }
61
+ end
62
+
63
+ def request(id, method, params)
64
+ { "jsonrpc" => "2.0", "id" => id, "method" => method, "params" => params }
65
+ end
66
+
67
+ let(:uri) { "file:///tmp/lsp-model.lml" }
68
+
69
+ let(:source) do
70
+ <<~LML
71
+ class Studio {
72
+ attribute glaze, Glaze
73
+ }
74
+
75
+ enum Glaze {
76
+ value "matte"
77
+ }
78
+ LML
79
+ end
80
+
81
+ def response(messages, id)
82
+ messages.find { |message| message["id"] == id }
83
+ end
84
+
85
+ def published(messages)
86
+ messages.find { |message| message["method"] == "textDocument/publishDiagnostics" }
87
+ end
88
+
89
+ it "advertises the server capabilities" do
90
+ messages, = run_session([initialize_message])
91
+ capabilities = response(messages, 1)["result"]["capabilities"]
92
+
93
+ expect(capabilities["textDocumentSync"]).to eq(1)
94
+ expect(capabilities["documentSymbolProvider"]).to be(true)
95
+ expect(capabilities["hoverProvider"]).to be(true)
96
+ expect(capabilities["documentFormattingProvider"]).to be(true)
97
+ expect(capabilities["diagnosticProvider"]).to include("interFileDependencies" => false)
98
+ end
99
+
100
+ it "publishes diagnostics from the parsed document" do
101
+ text = "class Tile { }\nclass Tile { }\n"
102
+ messages, = run_session([initialize_message, open_message(uri, text)])
103
+ diagnostics = published(messages)["params"]["diagnostics"]
104
+
105
+ expect(diagnostics.map { |item| item["code"] }).to eq(["validation/LML-V01"])
106
+ expect(diagnostics.first["range"]["start"]).to eq("line" => 0, "character" => 6)
107
+ expect(diagnostics.first["message"]).to include("remedy:")
108
+ end
109
+
110
+ it "answers a pull diagnostic request" do
111
+ messages, = run_session([
112
+ initialize_message, open_message(uri, source),
113
+ request(2, "textDocument/diagnostic", { "textDocument" => { "uri" => uri } })
114
+ ])
115
+ report = response(messages, 2)["result"]
116
+
117
+ expect(report["kind"]).to eq("full")
118
+ expect(report["items"]).to eq([])
119
+ end
120
+
121
+ it "lists document symbols" do
122
+ messages, = run_session([
123
+ initialize_message, open_message(uri, source),
124
+ request(2, "textDocument/documentSymbol", { "textDocument" => { "uri" => uri } })
125
+ ])
126
+ symbols = response(messages, 2)["result"]
127
+ names = symbols.map { |symbol| symbol["name"] }
128
+
129
+ expect(names).to include("Studio", "glaze", "Glaze")
130
+ expect(symbols.find { |symbol| symbol["name"] == "Studio" }["kind"]).to eq(5)
131
+ expect(symbols.find { |symbol| symbol["name"] == "matte" }["kind"]).to eq(22)
132
+ end
133
+
134
+ it "hovers an attribute with its type and value semantics" do
135
+ messages, = run_session([
136
+ initialize_message, open_message(uri, source),
137
+ request(2, "textDocument/hover",
138
+ { "textDocument" => { "uri" => uri },
139
+ "position" => { "line" => 1, "character" => 12 } })
140
+ ])
141
+ hover = response(messages, 2)["result"]
142
+
143
+ expect(hover["contents"]["value"]).to include("glaze")
144
+ expect(hover["contents"]["value"]).to include("Glaze")
145
+ end
146
+
147
+ it "goes to the definition of a type" do
148
+ messages, = run_session([
149
+ initialize_message, open_message(uri, source),
150
+ request(2, "textDocument/definition",
151
+ { "textDocument" => { "uri" => uri },
152
+ "position" => { "line" => 1, "character" => 24 } })
153
+ ])
154
+ locations = response(messages, 2)["result"]
155
+
156
+ expect(locations.first["range"]["start"]["line"]).to eq(4)
157
+ end
158
+
159
+ it "finds references including the declaration" do
160
+ messages, = run_session([
161
+ initialize_message, open_message(uri, source),
162
+ request(2, "textDocument/references",
163
+ { "textDocument" => { "uri" => uri },
164
+ "position" => { "line" => 4, "character" => 7 },
165
+ "context" => { "includeDeclaration" => true } })
166
+ ])
167
+ locations = response(messages, 2)["result"]
168
+ lines = locations.map { |location| location["range"]["start"]["line"] }
169
+
170
+ expect(lines).to include(1, 4)
171
+ end
172
+
173
+ it "completes grammar keywords and model names" do
174
+ messages, = run_session([
175
+ initialize_message, open_message(uri, source),
176
+ request(2, "textDocument/completion",
177
+ { "textDocument" => { "uri" => uri },
178
+ "position" => { "line" => 1, "character" => 2 } })
179
+ ])
180
+ labels = response(messages, 2)["result"]["items"].map { |item| item["label"] }
181
+
182
+ expect(labels).to include("class", "enum", "attribute", "value")
183
+ expect(labels).to include("Studio", "glaze")
184
+ end
185
+
186
+ it "returns a canonical formatting edit" do
187
+ messages, = run_session([
188
+ initialize_message, open_message(uri, "class B { }\nclass A { }\n"),
189
+ request(2, "textDocument/formatting",
190
+ { "textDocument" => { "uri" => uri }, "options" => {} })
191
+ ])
192
+ edits = response(messages, 2)["result"]
193
+
194
+ expect(edits.one?).to be(true)
195
+ expect(edits.first["newText"]).to eq("class B {\n}\n\nclass A {\n}\n")
196
+ end
197
+
198
+ it "survives an unparseable document" do
199
+ messages, = run_session([
200
+ initialize_message,
201
+ open_message(uri, "class Broken {\n"),
202
+ request(2, "textDocument/documentSymbol", { "textDocument" => { "uri" => uri } }),
203
+ request(3, "textDocument/formatting",
204
+ { "textDocument" => { "uri" => uri }, "options" => {} }),
205
+ { "jsonrpc" => "2.0", "id" => 4, "method" => "shutdown", "params" => {} },
206
+ { "jsonrpc" => "2.0", "method" => "exit", "params" => {} },
207
+ ])
208
+
209
+ expect(published(messages)["params"]["diagnostics"].first["code"]).to eq("parse/LML-001")
210
+ expect(response(messages, 2)["result"]).to eq([])
211
+ expect(response(messages, 3)["result"]).to be_nil
212
+ expect(messages.size).to be >= 4
213
+ end
214
+
215
+ it "opens every RS 3001 corpus fixture without crashing" do
216
+ Dir[fixtures_path("rs3001/*.lml")].each_with_index do |path, index|
217
+ text = File.read(path)
218
+ fixture_uri = Lutaml::Lml::Lsp::Conversions.path_to_uri(path)
219
+ messages, = run_session([
220
+ initialize_message(1),
221
+ open_message(fixture_uri, text),
222
+ request(2, "textDocument/documentSymbol",
223
+ { "textDocument" => { "uri" => fixture_uri } }),
224
+ request(3, "textDocument/diagnostic",
225
+ { "textDocument" => { "uri" => fixture_uri } }),
226
+ ])
227
+
228
+ expect(response(messages, 2)["result"]).to be_an(Array), "fixture #{index}: #{path}"
229
+ expect(response(messages, 3)["result"]["kind"]).to eq("full")
230
+ end
231
+ end
232
+
233
+ it "exits zero after a clean shutdown" do
234
+ messages, code = run_session([
235
+ initialize_message,
236
+ { "jsonrpc" => "2.0", "id" => 2, "method" => "shutdown", "params" => {} },
237
+ { "jsonrpc" => "2.0", "method" => "exit", "params" => {} },
238
+ ])
239
+
240
+ expect(code).to eq(0)
241
+ expect(response(messages, 2)["result"]).to be_nil
242
+ end
243
+
244
+ it "runs as a stdio executable" do
245
+ root = File.expand_path("../../../../..", __dir__)
246
+ frames = [
247
+ initialize_message,
248
+ { "jsonrpc" => "2.0", "id" => 2, "method" => "shutdown", "params" => {} },
249
+ { "jsonrpc" => "2.0", "method" => "exit", "params" => {} },
250
+ ].map { |message| frame(message) }.join
251
+
252
+ stdout, _stderr, status = Open3.capture3(
253
+ { "RUBYLIB" => File.join(root, "lib") },
254
+ RbConfig.ruby, File.join(root, "exe", "lutaml-lml-lsp"),
255
+ stdin_data: frames
256
+ )
257
+
258
+ expect(status.exitstatus).to eq(0)
259
+ expect(parse_frames(stdout).first["id"]).to eq(1)
260
+ end
261
+
262
+ describe "transport" do
263
+ it "round-trips a framed message" do
264
+ input = StringIO.new(frame({ "jsonrpc" => "2.0", "id" => 1, "result" => {} }))
265
+ output = StringIO.new
266
+ transport = Lutaml::Lml::Lsp::Transport.new(input: input, output: output)
267
+
268
+ expect(transport.read_message).to include("id" => 1)
269
+ expect(transport.read_message).to be_nil
270
+
271
+ transport.write_message(jsonrpc: "2.0", id: 1, result: nil)
272
+ expect(output.string).to start_with("Content-Length: ")
273
+ expect(output.string).to include('"result":null')
274
+ end
275
+ end
276
+
277
+ describe "keywords" do
278
+ it "reads the language keywords from the compiled grammar artifact" do
279
+ keywords = Lutaml::Lml::Lsp::Keywords.all
280
+
281
+ expect(keywords).to include("class", "enum", "attribute", "value", "instance")
282
+ expect(keywords).to eq(keywords.sort)
283
+ end
284
+ end
285
+ end