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,406 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../lml_spec_setup"
5
+ require "tempfile"
6
+
7
+ RSpec.describe Lutaml::Lml::ModelCompiler do
8
+ let(:compiler) { described_class.new }
9
+
10
+ describe ".compile" do
11
+ it "compiles LML model definitions into Serializable subclasses" do
12
+ file = Tempfile.new(%w[test .lml])
13
+ file.write("models TestModels {\n class Widget {\n attribute name {\n type String\n cardinality 1\n }\n }\n}")
14
+ file.rewind
15
+
16
+ result = compiler.compile(file)
17
+ expect(result).to have_key("Widget")
18
+ expect(result["Widget"]).to be < Lutaml::Model::Serializable
19
+ expect(result["Widget"].attributes).to have_key(:name)
20
+ file.close!
21
+ end
22
+
23
+ it "compiles classes from diagram syntax" do
24
+ file = Tempfile.new(%w[test .lutaml])
25
+ file.write("diagram Test {\n class Foo {\n +bar: String[0..1]\n +baz: Integer[1..*]\n }\n}")
26
+ file.rewind
27
+
28
+ result = compiler.compile(file)
29
+ foo = result["Foo"]
30
+ expect(foo.attributes[:bar]).not_to be_collection
31
+ expect(foo.attributes[:baz]).to be_collection
32
+ file.close!
33
+ end
34
+
35
+ it "resolves standard types correctly" do
36
+ file = Tempfile.new(%w[test .lml])
37
+ file.write("models Types {\n class Typed {\n attribute s { type String cardinality 1 }\n attribute b { type Boolean cardinality 0..1 }\n attribute i { type Integer cardinality 1 }\n attribute d { type date_time cardinality 1 }\n }\n}")
38
+ file.rewind
39
+
40
+ result = compiler.compile(file)
41
+ typed = result["Typed"]
42
+ obj = typed.new("s" => "hello", "b" => true, "i" => 42)
43
+ expect(obj.s).to eq("hello")
44
+ expect(obj.b).to be(true)
45
+ expect(obj.i).to eq(42)
46
+ file.close!
47
+ end
48
+
49
+ it "offers no lutaml-model :hash mapping for any DSL type name" do
50
+ expect(described_class::TYPE_MAP.values).not_to include(:hash)
51
+ end
52
+
53
+ it "handles collection cardinality" do
54
+ file = Tempfile.new(%w[test .lml])
55
+ file.write("models Coll {\n class Container {\n attribute items { type String cardinality 0..n }\n attribute single { type String cardinality 1 }\n }\n}")
56
+ file.rewind
57
+
58
+ result = compiler.compile(file)
59
+ container = result["Container"]
60
+ expect(container.attributes[:items]).to be_collection
61
+ expect(container.attributes[:single]).not_to be_collection
62
+ file.close!
63
+ end
64
+
65
+ it "resolves custom types from compiled classes" do
66
+ file = Tempfile.new(%w[test .lml])
67
+ file.write("models Nested {\n class Inner {\n attribute val { type String cardinality 1 }\n }\n class Outer {\n attribute inner { type Inner cardinality 1 }\n }\n}")
68
+ file.rewind
69
+
70
+ result = compiler.compile(file)
71
+ expect(result["Inner"]).to be < Lutaml::Model::Serializable
72
+ expect(result["Outer"]).to be < Lutaml::Model::Serializable
73
+ file.close!
74
+ end
75
+
76
+ it "handles reference types as strings" do
77
+ file = Tempfile.new(%w[test .lml])
78
+ file.write("models Ref {\n class Item {\n attribute ref { type reference:(Other.id) cardinality 0..n }\n }\n}")
79
+ file.rewind
80
+
81
+ result = compiler.compile(file)
82
+ expect(result["Item"].attributes[:ref]).to be_collection
83
+ file.close!
84
+ end
85
+
86
+ it "compiles enums with value constants" do
87
+ file = Tempfile.new(%w[test .lml])
88
+ file.write("models Enums {\n enum Color {\n red\n green\n blue\n }\n}")
89
+ file.rewind
90
+
91
+ result = compiler.compile(file)
92
+ expect(result["Color"]).to be < Lutaml::Model::Serializable
93
+ expect(result["Color"].red.value).to eq("red")
94
+ expect(result["Color"].green.value).to eq("green")
95
+ file.close!
96
+ end
97
+
98
+ it "compiles data types" do
99
+ file = Tempfile.new(%w[test .lml])
100
+ file.write("diagram Test {\n data_type Uri {\n definition { URI }\n }\n}")
101
+ file.rewind
102
+
103
+ result = compiler.compile(file)
104
+ expect(result["Uri"]).to be < Lutaml::Model::Serializable
105
+ file.close!
106
+ end
107
+
108
+ it "registers classes in a namespace" do
109
+ mod = Module.new
110
+ file = Tempfile.new(%w[test .lml])
111
+ file.write("models NS {\n class Item {\n attribute name { type String cardinality 1 }\n }\n}")
112
+ file.rewind
113
+
114
+ described_class.new(namespace: mod).compile(file)
115
+ expect(mod.const_defined?(:Item)).to be true
116
+ obj = mod::Item.new("name" => "test")
117
+ expect(obj.name).to eq("test")
118
+ file.close!
119
+ end
120
+
121
+ it "creates the default namespace nested under Lutaml::Lml" do
122
+ file = Tempfile.new(%w[test .lml])
123
+ file.write("models NS {\n class Item {\n attribute name { type String cardinality 1 }\n }\n}")
124
+ file.rewind
125
+
126
+ ns = described_class::DEFAULT_NAMESPACE
127
+ result = described_class.new(namespace: ns).compile(file)
128
+ mod = Object.const_get(ns)
129
+ expect(result["Item"].name).to eq("Lutaml::Lml::Generated::Item")
130
+ expect(mod.const_defined?(:Item)).to be true
131
+ file.close!
132
+ end
133
+
134
+ it "creates intermediate modules for a scoped namespace string" do
135
+ ns = "LmlScopedSpec::Inner"
136
+ file = Tempfile.new(%w[test .lml])
137
+ file.write("models NS {\n class Item {\n attribute name { type String cardinality 1 }\n }\n}")
138
+ file.rewind
139
+
140
+ described_class.new(namespace: ns).compile(file)
141
+ expect(LmlScopedSpec::Inner::Item.name)
142
+ .to eq("LmlScopedSpec::Inner::Item")
143
+ file.close!
144
+ end
145
+
146
+ it "resolves a string namespace into a real module" do
147
+ ns = "LmlSpecNamespace"
148
+ file = Tempfile.new(%w[test .lml])
149
+ file.write("models NS {\n class Item {\n attribute name { type String cardinality 1 }\n }\n}")
150
+ file.rewind
151
+
152
+ described_class.new(namespace: ns).compile(file)
153
+ expect(Object.const_get(ns)::Item.name).to eq("#{ns}::Item")
154
+ file.close!
155
+ end
156
+
157
+ it "produces classes that generate JSON and YAML Schema" do
158
+ require "lutaml/model/schema"
159
+ file = Tempfile.new(%w[test .lml])
160
+ file.write(<<~LML)
161
+ models Schemas {
162
+ class Widget {
163
+ attribute name { type String cardinality 1 }
164
+ attribute color { type Color cardinality 0..1 }
165
+ attribute parts { type Integer cardinality 0..n }
166
+ }
167
+ enum Color {
168
+ RED
169
+ GREEN
170
+ }
171
+ }
172
+ LML
173
+ file.rewind
174
+
175
+ result = described_class.new(namespace: "LmlSchemaSpec").compile(file)
176
+ parsed = JSON.parse(Lutaml::Model::Schema.to_json(result["Widget"]))
177
+ expect(parsed["$ref"]).to eq("#/$defs/LmlSchemaSpec_Widget")
178
+ defs = parsed["$defs"]
179
+ expect(defs["LmlSchemaSpec_Widget"]["properties"]["parts"]["type"]).to eq("array")
180
+ expect(defs["LmlSchemaSpec_Color"]["properties"]["value"]["enum"]).to eq(%w[RED GREEN])
181
+
182
+ expect(Lutaml::Model::Schema.to_yaml(result["Widget"])).to start_with("%YAML 1.1")
183
+ file.close!
184
+ end
185
+
186
+ context "when attributes reference other models (issue #49)" do
187
+ let(:lml) do
188
+ <<~LML
189
+ class Concept {
190
+ related: RelatedConcept [0..*]
191
+ origin: RelatedConcept
192
+ name: String [1..1]
193
+ }
194
+ class RelatedConcept {
195
+ id: String
196
+ }
197
+ LML
198
+ end
199
+
200
+ [nil, "LmlRefSpec"].each do |namespace|
201
+ it "emits $ref to the referenced definition (namespace: #{namespace.inspect})" do
202
+ require "lutaml/model/schema"
203
+ result = described_class.new(namespace: namespace).compile(lml)
204
+ parsed = YAML.safe_load(Lutaml::Model::Schema.to_yaml(result["Concept"]))
205
+ prefix = namespace ? "#{namespace}_" : ""
206
+ props = parsed["$defs"]["#{prefix}Concept"]["properties"]
207
+
208
+ expect(props["related"]).to eq(
209
+ "type" => "array", "items" => { "$ref" => "#/$defs/#{prefix}RelatedConcept" },
210
+ )
211
+ expect(props["origin"]).to eq("$ref" => "#/$defs/#{prefix}RelatedConcept")
212
+ expect(parsed["$defs"]).to have_key("#{prefix}RelatedConcept")
213
+ end
214
+ end
215
+ end
216
+
217
+ context "with the issue #49 namespace and `as :element` syntax" do
218
+ let(:lml) do
219
+ <<~LML
220
+ class Car {
221
+ namespace "xyz"
222
+ wheels Wheel[4] as :element
223
+ vin: String as :attribute
224
+ }
225
+ class Wheel {
226
+ tire
227
+ }
228
+ LML
229
+ end
230
+
231
+ it "carries the namespace and element/attribute kinds into the XML mapping" do
232
+ car = described_class.new.compile(lml)["Car"]
233
+ mapping = car.mappings_for(:xml)
234
+
235
+ expect(mapping.namespace_uri).to eq("xyz")
236
+ expect(mapping.elements.map(&:name)).to eq(["wheels"])
237
+ expect(mapping.attributes.map(&:name)).to eq(["vin"])
238
+ end
239
+
240
+ it "does not turn namespace or `as` into string properties" do
241
+ car = described_class.new.compile(lml)["Car"]
242
+ expect(car.attributes.keys).to contain_exactly(:wheels, :vin)
243
+ end
244
+
245
+ it "generates a YAML Schema with only the declared properties" do
246
+ require "lutaml/model/schema"
247
+ car = described_class.new.compile(lml)["Car"]
248
+ props = YAML.safe_load(Lutaml::Model::Schema.to_yaml(car))["$defs"]["Car"]["properties"]
249
+
250
+ expect(props.keys).to contain_exactly("wheels", "vin")
251
+ expect(props["wheels"]["items"]).to eq("$ref" => "#/$defs/Wheel")
252
+ end
253
+
254
+ it "keeps the namespace on an empty class" do
255
+ klass = described_class.new.compile("class Empty {\n namespace \"xyz\"\n}\n")["Empty"]
256
+ expect(klass.mappings_for(:xml).namespace_uri).to eq("xyz")
257
+ end
258
+
259
+ it "keeps an attribute literally named namespace" do
260
+ klass = described_class.new.compile("class A {\n namespace: String\n}\n")["A"]
261
+ expect(klass.attributes.keys).to eq([:namespace])
262
+ end
263
+ end
264
+ end
265
+
266
+ describe "Lutaml::Lml.compile" do
267
+ it "provides module-level compile method" do
268
+ file = Tempfile.new(%w[test .lml])
269
+ file.write("models Top {\n class Thing {\n attribute x { type String cardinality 1 }\n }\n}")
270
+ file.rewind
271
+
272
+ result = Lutaml::Lml.compile(file)
273
+ expect(result).to have_key("Thing")
274
+ file.close!
275
+ end
276
+ end
277
+
278
+ describe ".hydrate" do
279
+ it "hydrates a compiled class from instance data" do
280
+ file = Tempfile.new(%w[test .lml])
281
+ file.write("models H {\n class Sensor {\n attribute name { type String cardinality 1 }\n attribute reading { type Float cardinality 0..1 }\n }\n}")
282
+ file.rewind
283
+
284
+ compiler.compile(file)
285
+ file.rewind
286
+
287
+ instance_lml = Tempfile.new(%w[inst .lml])
288
+ instance_lml.write("instance MySensor {\n instance Sensor {\n name = \"TH-042\"\n reading = 23.5\n }\n}")
289
+ instance_lml.rewind
290
+
291
+ result = compiler.hydrate(instance_lml)
292
+ expect(result).to be_a(compiler.compiled_classes["Sensor"])
293
+ expect(result.name).to eq("TH-042")
294
+ expect(result.reading).to eq(23.5)
295
+
296
+ file.close!
297
+ instance_lml.close!
298
+ end
299
+
300
+ it "hydrates nested instances" do
301
+ models_lml = Tempfile.new(%w[mod .lml])
302
+ models_lml.write("models Nested {\n class Address {\n attribute city { type String cardinality 1 }\n }\n class Person {\n attribute name { type String cardinality 1 }\n attribute addresses { type Address cardinality 0..n }\n }\n}")
303
+ models_lml.rewind
304
+
305
+ compiler.compile(models_lml)
306
+
307
+ instance_lml = Tempfile.new(%w[inst .lml])
308
+ instance_lml.write("instance Wrapper {\n instance Person {\n name = \"Alice\"\n addresses = [\n instance Address {\n city = \"Tokyo\"\n },\n instance Address {\n city = \"Osaka\"\n }\n ]\n }\n}")
309
+ instance_lml.rewind
310
+
311
+ result = compiler.hydrate(instance_lml)
312
+ expect(result.name).to eq("Alice")
313
+ expect(result.addresses.length).to eq(2)
314
+ expect(result.addresses[0]).to be_a(compiler.compiled_classes["Address"])
315
+ expect(result.addresses[0].city).to eq("Tokyo")
316
+ expect(result.addresses[1].city).to eq("Osaka")
317
+
318
+ models_lml.close!
319
+ instance_lml.close!
320
+ end
321
+
322
+ it "hydrates array instances" do
323
+ file = Tempfile.new(%w[test .lml])
324
+ file.write("models Arr {\n class Item {\n attribute label { type String cardinality 1 }\n }\n class Box {\n attribute items { type Item cardinality 0..n }\n }\n}")
325
+ file.rewind
326
+
327
+ compiler.compile(file)
328
+ file.rewind
329
+
330
+ instance_lml = Tempfile.new(%w[inst .lml])
331
+ instance_lml.write("instance MyBox {\n instance Box {\n items = [\n instance Item {\n label = \"first\"\n },\n instance Item {\n label = \"second\"\n }\n ]\n }\n}")
332
+ instance_lml.rewind
333
+
334
+ result = compiler.hydrate(instance_lml)
335
+ expect(result).to be_a(compiler.compiled_classes["Box"])
336
+ expect(result.items.length).to eq(2)
337
+ expect(result.items[0].label).to eq("first")
338
+ expect(result.items[1].label).to eq("second")
339
+
340
+ file.close!
341
+ instance_lml.close!
342
+ end
343
+
344
+ it "hydrates real-world IHO metadata" do
345
+ compiler.compile(File.new("spec/lml/fixtures/lml/iho_data_models.lml"))
346
+
347
+ result = compiler.hydrate(File.new("spec/lml/fixtures/lml/data_s158_metadata.lml"))
348
+ expect(result).to be_a(compiler.compiled_classes["IhoMetadata"])
349
+ expect(result.document_number).to eq("S-158:102")
350
+ expect(result.title).to eq("Bathymetric Surface Validation Checks")
351
+ expect(result.compliant_standards.length).to eq(2)
352
+ expect(result.compliant_standards[0]).to be_a(compiler.compiled_classes["CompliantStandard"])
353
+ expect(result.compliant_standards[0].title).to eq("S-102 PS")
354
+ end
355
+
356
+ it "returns a hash for unknown types" do
357
+ instance_lml = Tempfile.new(%w[inst .lml])
358
+ instance_lml.write("instance Mystery {\n type UnknownType\n name = \"test\"\n}")
359
+ instance_lml.rewind
360
+
361
+ result = compiler.hydrate(instance_lml)
362
+ expect(result).to be_a(Hash)
363
+ expect(result[:name]).to eq("test")
364
+
365
+ instance_lml.close!
366
+ end
367
+ end
368
+
369
+ describe "with real-world fixtures" do
370
+ it "compiles iho_data_models.lml" do
371
+ result = Lutaml::Lml.compile(File.new("spec/lml/fixtures/lml/iho_data_models.lml"))
372
+ expect(result.keys).to contain_exactly("IhoMetadata", "CompliantStandard")
373
+
374
+ meta = result["IhoMetadata"]
375
+ obj = meta.new("document_number" => "S-101", "title" => "Test")
376
+ expect(obj.document_number).to eq("S-101")
377
+ expect(obj.title).to eq("Test")
378
+ expect(meta.attributes[:compliant_standards].collection?).to be true
379
+ end
380
+
381
+ it "compiles iho_s102_check.lml" do
382
+ result = Lutaml::Lml.compile(File.new("spec/lml/fixtures/lml/iho_s102_check.lml"))
383
+ expect(result.keys).to contain_exactly("ValidationChecks", "ValidationCheck")
384
+
385
+ vc = result["ValidationCheck"]
386
+ expect(vc.attributes[:data_quality_measure].collection?).to be true
387
+ expect(vc.attributes[:prerequisites].collection?).to be true
388
+ expect(vc.attributes[:dev_id].collection?).to be false
389
+ end
390
+ end
391
+
392
+ describe "declared mapping blocks" do
393
+ it "emits lutaml-model wire-name mappings" do
394
+ file = Tempfile.new(%w[test .lml])
395
+ file.write("models M {\n class Widget {\n attribute name { type String cardinality 1 }\n mapping yaml { map \"full-name\", to: \"name\" }\n }\n}")
396
+ file.rewind
397
+
398
+ result = compiler.compile(file)
399
+ widget = result["Widget"]
400
+ expect(widget.attributes).to have_key(:name)
401
+ wired = widget.from_yaml("---\nfull-name: Gizmo\n")
402
+ expect(wired.name).to eq("Gizmo")
403
+ file.close!
404
+ end
405
+ end
406
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::Association do
7
+ describe "attribute definitions" do
8
+ it "has name and definition" do
9
+ assoc = described_class.new(name: "contains", definition: "Owner to member")
10
+ expect(assoc.name).to eq("contains")
11
+ expect(assoc.definition).to eq("Owner to member")
12
+ end
13
+
14
+ it "has default visibility" do
15
+ assoc = described_class.new
16
+ expect(assoc.visibility).to eq("public")
17
+ end
18
+
19
+ it "has owner and member ends" do
20
+ assoc = described_class.new(
21
+ owner_end: "Order",
22
+ owner_end_type: "Order",
23
+ member_end: "LineItem",
24
+ member_end_type: "LineItem",
25
+ )
26
+ expect(assoc.owner_end).to eq("Order")
27
+ expect(assoc.member_end).to eq("LineItem")
28
+ end
29
+
30
+ it "has cardinality ends" do
31
+ card = Lutaml::Lml::Cardinality.new(min: "1", max: "*")
32
+ assoc = described_class.new(
33
+ owner_end: "Order",
34
+ owner_end_cardinality: card,
35
+ )
36
+ expect(assoc.owner_end_cardinality.min).to eq("1")
37
+ expect(assoc.owner_end_cardinality.max).to eq("*")
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::Collection do
7
+ it "has name attribute" do
8
+ coll = described_class.new(name: "test_suite")
9
+ expect(coll.name).to eq("test_suite")
10
+ end
11
+
12
+ it "has includes collection" do
13
+ coll = described_class.new(includes: ["item1", "item2"])
14
+ expect(coll.includes).to eq(["item1", "item2"])
15
+ end
16
+
17
+ it "has validations collection" do
18
+ coll = described_class.new(validations: ["count >= 3"])
19
+ expect(coll.validations).to eq(["count >= 3"])
20
+ end
21
+
22
+ it "defaults to empty collections" do
23
+ coll = described_class.new
24
+ expect(coll.includes).to be_nil
25
+ expect(coll.validations).to be_nil
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::DataType do
7
+ describe "attribute definitions" do
8
+ it "has name attribute" do
9
+ dt = described_class.new(name: "Uri")
10
+ expect(dt.name).to eq("Uri")
11
+ end
12
+
13
+ it "has default keyword" do
14
+ dt = described_class.new
15
+ expect(dt.keyword).to eq("dataType")
16
+ end
17
+
18
+ it "has default visibility" do
19
+ dt = described_class.new
20
+ expect(dt.visibility).to eq("public")
21
+ end
22
+
23
+ it "has default is_abstract" do
24
+ dt = described_class.new
25
+ expect(dt.is_abstract).to be(false)
26
+ end
27
+ end
28
+
29
+ describe ".entity_type" do
30
+ it "returns :data_types" do
31
+ expect(described_class.entity_type).to eq(:data_types)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::Diagram do
7
+ describe "attribute definitions" do
8
+ it "has name attribute" do
9
+ diagram = described_class.new(name: "SystemOverview")
10
+ expect(diagram.name).to eq("SystemOverview")
11
+ end
12
+
13
+ it "has default visibility" do
14
+ diagram = described_class.new
15
+ expect(diagram.visibility).to eq("public")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::Document do
7
+ describe "inheritance" do
8
+ it "inherits from Lutaml::Model::Serializable" do
9
+ expect(described_class).to be < Lutaml::Model::Serializable
10
+ end
11
+ end
12
+
13
+ describe "attributes" do
14
+ it "has instance attribute" do
15
+ doc = described_class.new
16
+ expect(doc.instance).to be_nil
17
+ end
18
+
19
+ it "has requires collection defaulting to empty" do
20
+ doc = described_class.new
21
+ expect(doc.requires).to eq([])
22
+ end
23
+
24
+ it "has instances attribute" do
25
+ doc = described_class.new
26
+ expect(doc.instances).to be_nil
27
+ end
28
+
29
+ it "defaults view_imports to a fresh empty array per instance" do
30
+ first = described_class.new
31
+ second = described_class.new
32
+ expect(first.view_imports).to eq([])
33
+ expect(first.view_imports).not_to equal(second.view_imports)
34
+ end
35
+
36
+ it "defaults comments and groups to empty arrays" do
37
+ doc = described_class.new
38
+ expect(doc.comments).to eq([])
39
+ expect(doc.groups).to eq([])
40
+ end
41
+ end
42
+
43
+ describe "setting attributes" do
44
+ it "accepts requires list" do
45
+ doc = described_class.new
46
+ doc.requires = ["file1.lml", "file2.lml"]
47
+ expect(doc.requires).to eq(["file1.lml", "file2.lml"])
48
+ end
49
+
50
+ it "accepts an instance" do
51
+ inst = Lutaml::Lml::Instance.new(type: "MyType")
52
+ doc = described_class.new
53
+ doc.instance = inst
54
+ expect(doc.instance.type).to eq("MyType")
55
+ end
56
+
57
+ it "accepts an InstanceCollection" do
58
+ collection = Lutaml::Lml::InstanceCollection.new
59
+ doc = described_class.new
60
+ doc.instances = collection
61
+ expect(doc.instances).to eq(collection)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require_relative "../../../lml_spec_setup"
5
+
6
+ RSpec.describe Lutaml::Lml::Enum do
7
+ describe "attribute definitions" do
8
+ it "has name attribute" do
9
+ enum = described_class.new(name: "Color")
10
+ expect(enum.name).to eq("Color")
11
+ end
12
+
13
+ it "has default keyword" do
14
+ enum = described_class.new
15
+ expect(enum.keyword).to eq("enumeration")
16
+ end
17
+
18
+ it "has default visibility" do
19
+ enum = described_class.new
20
+ expect(enum.visibility).to eq("public")
21
+ end
22
+
23
+ it "has default is_abstract" do
24
+ enum = described_class.new
25
+ expect(enum.is_abstract).to be(false)
26
+ end
27
+
28
+ it "has collection attributes with defaults" do
29
+ enum = described_class.new
30
+ expect(enum.attributes).to eq([])
31
+ expect(enum.operations).to eq([])
32
+ expect(enum.values).to eq([])
33
+ expect(enum.stereotype).to eq([])
34
+ end
35
+ end
36
+
37
+ describe ".entity_type" do
38
+ it "returns :enums" do
39
+ expect(described_class.entity_type).to eq(:enums)
40
+ end
41
+ end
42
+ end