lutaml-model 0.8.200 → 0.8.202

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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/.github/scripts/test_installed_gem.rb +1 -13
  3. data/.github/workflows/downstream-performance.yml +1 -22
  4. data/.github/workflows/performance.yml +1 -33
  5. data/.github/workflows/rake.yml +2 -6
  6. data/.rubocop.yml +0 -10
  7. data/.rubocop_todo.yml +0 -4
  8. data/Gemfile +0 -23
  9. data/README.adoc +25 -86
  10. data/Rakefile +2 -167
  11. data/docs/_guides/advanced-mapping.adoc +6 -6
  12. data/docs/_guides/character-encoding.adoc +0 -3
  13. data/docs/_guides/gem-integration.adoc +1 -1
  14. data/docs/_guides/index.adoc +0 -4
  15. data/docs/_guides/xml/type-namespaces.adoc +1 -1
  16. data/docs/_guides/xml-guide-0.8.0.adoc +2 -2
  17. data/docs/_guides/xml-namespaces.adoc +2 -3
  18. data/docs/_guides/xml_mappings/03_architecture.adoc +2 -2
  19. data/docs/_guides/xml_mappings/07_best_practices.adoc +2 -3
  20. data/docs/_guides/xml_mappings/08_troubleshooting.adoc +1 -9
  21. data/docs/_pages/comparison-with-shale.adoc +1 -1
  22. data/docs/_pages/configuration.adoc +6 -40
  23. data/docs/_pages/index.adoc +0 -1
  24. data/docs/_pages/serialization_adapters.adoc +4 -16
  25. data/docs/_references/architecture.adoc +1 -1
  26. data/docs/_references/lutaml-namespace-planning.md +1 -1
  27. data/docs/_references/three-phase-namespace-architecture.adoc +1 -2
  28. data/docs/_references/xsd-generation-with-namespace-support.adoc +3 -8
  29. data/docs/_tutorials/lutaml-xml-architecture.adoc +2 -8
  30. data/docs/architecture.md +7 -11
  31. data/docs/conversion_caching.adoc +1 -1
  32. data/docs/index.adoc +0 -1
  33. data/docs/key_value_data_model.adoc +1 -1
  34. data/docs/namespace-management.adoc +4 -10
  35. data/lib/lutaml/json/format.rb +0 -1
  36. data/lib/lutaml/json/generator_options.rb +0 -1
  37. data/lib/lutaml/key_value/transform.rb +9 -16
  38. data/lib/lutaml/lml/document_builder.rb +2 -2
  39. data/lib/lutaml/lml/entity_types.rb +2 -2
  40. data/lib/lutaml/model/adapter_resolver.rb +5 -15
  41. data/lib/lutaml/model/attribute.rb +14 -2
  42. data/lib/lutaml/model/cached_type_resolver.rb +1 -7
  43. data/lib/lutaml/model/error/unknown_adapter_type_error.rb +1 -1
  44. data/lib/lutaml/model/global_context.rb +3 -5
  45. data/lib/lutaml/model/instrumentation.rb +0 -3
  46. data/lib/lutaml/model/mapping/mapping_rule.rb +6 -10
  47. data/lib/lutaml/model/register.rb +20 -31
  48. data/lib/lutaml/model/runtime_compatibility.rb +0 -92
  49. data/lib/lutaml/model/schema/class_loader.rb +2 -4
  50. data/lib/lutaml/model/schema/xml_compiler/spec_builder/simple_types.rb +2 -3
  51. data/lib/lutaml/model/serialize/attribute_definition.rb +10 -184
  52. data/lib/lutaml/model/serialize/conversion_caching.rb +1 -5
  53. data/lib/lutaml/model/serialize/model_import.rb +0 -5
  54. data/lib/lutaml/model/serialize/value_mapping.rb +0 -3
  55. data/lib/lutaml/model/services/rule_value_extractor.rb +4 -7
  56. data/lib/lutaml/model/store.rb +10 -17
  57. data/lib/lutaml/model/toml.rb +0 -2
  58. data/lib/lutaml/model/transformation_registry.rb +3 -7
  59. data/lib/lutaml/model/version.rb +1 -1
  60. data/lib/lutaml/model.rb +3 -19
  61. data/lib/lutaml/toml/format.rb +4 -8
  62. data/lib/lutaml/xml/adapter/moxml_adapter.rb +1 -7
  63. data/lib/lutaml/xml/adapter.rb +0 -4
  64. data/lib/lutaml/xml/adapter_loader.rb +1 -6
  65. data/lib/lutaml/xml/builder/base.rb +0 -3
  66. data/lib/lutaml/xml/builder.rb +0 -8
  67. data/lib/lutaml/xml/data_model.rb +1 -1
  68. data/lib/lutaml/xml/doctype_extractor.rb +3 -3
  69. data/lib/lutaml/xml/format.rb +22 -74
  70. data/lib/lutaml/xml/leptris/plan_compiler.rb +1 -2
  71. data/lib/lutaml/xml/model_transform.rb +14 -24
  72. data/lib/lutaml/xml/polymorphic_value_handler.rb +1 -1
  73. data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
  74. data/lib/lutaml/xml/schema/builder.rb +6 -9
  75. data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
  76. data/lib/lutaml/xml/xml_element.rb +3 -2
  77. data/lib/lutaml/xml/xsd_validator.rb +4 -11
  78. data/lib/lutaml/yaml/adapter/yeptris_adapter.rb +2 -2
  79. data/lib/lutaml/yamls/adapter_loader.rb +1 -5
  80. data/lib/tasks/performance_comparator.rb +1 -1
  81. data/lutaml-model.gemspec +3 -8
  82. data/spec/benchmarks/xml_parsing_benchmark_spec.rb +1 -1
  83. data/spec/lutaml/json/adapter/standard_adapter_spec.rb +6 -9
  84. data/spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb +0 -2
  85. data/spec/lutaml/model/cached_type_resolver_spec.rb +2 -54
  86. data/spec/lutaml/model/cdata_spec.rb +2 -15
  87. data/spec/lutaml/model/encoding_spec.rb +0 -9
  88. data/spec/lutaml/model/except_spec.rb +0 -7
  89. data/spec/lutaml/model/json_spec.rb +0 -14
  90. data/spec/lutaml/model/mixed_content_spec.rb +6 -46
  91. data/spec/lutaml/model/ordered_content_spec.rb +0 -7
  92. data/spec/lutaml/model/polymorphic_scalar_member_spec.rb +57 -0
  93. data/spec/lutaml/model/processing_instruction_spec.rb +0 -6
  94. data/spec/lutaml/model/runtime_compatibility_spec.rb +0 -37
  95. data/spec/lutaml/model/serializable_spec.rb +0 -2
  96. data/spec/lutaml/model/toml_spec.rb +0 -23
  97. data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +0 -4
  98. data/spec/lutaml/xml/adapter/order_spec.rb +1 -1
  99. data/spec/lutaml/xml/adapter/xml_namespace_spec.rb +0 -7
  100. data/spec/lutaml/xml/attribute_namespace_disjointness_spec.rb +6 -6
  101. data/spec/lutaml/xml/builder/builder_spec.rb +0 -24
  102. data/spec/lutaml/xml/default_namespace_spec.rb +1 -8
  103. data/spec/lutaml/xml/doctype_preservation_spec.rb +0 -4
  104. data/spec/lutaml/xml/entity_fragmentation_spec.rb +0 -6
  105. data/spec/lutaml/xml/fpi_namespace_spec.rb +0 -21
  106. data/spec/lutaml/xml/mapping_spec.rb +8 -15
  107. data/spec/lutaml/xml/namespace_scope_vcard_spec.rb +0 -7
  108. data/spec/lutaml/xml/namespace_spec.rb +0 -13
  109. data/spec/lutaml/xml/prefix_control_spec.rb +0 -6
  110. data/spec/lutaml/xml/schema/builder_moxml_spec.rb +1 -1
  111. data/spec/lutaml/xml/xml_adapter_spec.rb +0 -7
  112. data/spec/lutaml/xml/xml_spec.rb +2 -88
  113. data/spec/spec_helper.rb +5 -24
  114. data/spec/support/test_adapter_config.rb +6 -6
  115. metadata +1 -32
  116. data/.github/workflows/js-pr-check.yml +0 -106
  117. data/.github/workflows/js-sync.yml +0 -55
  118. data/.github/workflows/opal.yml +0 -65
  119. data/.gitmodules +0 -6
  120. data/.rspec-opal +0 -5
  121. data/docs/_guides/opal.adoc +0 -232
  122. data/lib/compat/opal/generate_boot.rb +0 -137
  123. data/lib/compat/opal/js_bundle_entry.rb +0 -42
  124. data/lib/compat/opal/lutaml_model_boot.rb +0 -638
  125. data/lib/compat/opal/monitor.rb +0 -31
  126. data/lib/compat/opal/moxml/adapter/customized_rexml/entity_reference.rb +0 -9
  127. data/lib/compat/opal/moxml/adapter/customized_rexml/formatter.rb +0 -225
  128. data/lib/compat/opal/moxml/adapter/customized_rexml.rb +0 -11
  129. data/lib/compat/opal/moxml_boot.rb +0 -68
  130. data/lib/compat/opal/objectspace_shim.rb +0 -23
  131. data/lib/compat/opal/rexml/namespace.rb +0 -59
  132. data/lib/compat/opal/rexml/parsers/baseparser.rb +0 -1016
  133. data/lib/compat/opal/rexml/source.rb +0 -214
  134. data/lib/compat/opal/rexml/text.rb +0 -426
  135. data/lib/compat/opal/rexml/xmltokens.rb +0 -45
  136. data/lib/compat/opal/rexml_compat.rb +0 -85
  137. data/lib/compat/opal/yaml_compat.rb +0 -32
  138. data/lib/lutaml/model/cached_type_resolver/mutex_hash_cache.rb +0 -53
  139. data/lib/lutaml/model/schema/schema_builder/oga.rb +0 -92
  140. data/lib/lutaml/xml/schema/builder/oga.rb +0 -92
  141. data/spec/lutaml/model/boot_manifest_spec.rb +0 -30
  142. data/spec/lutaml/model/opal_smoke_spec.rb +0 -199
  143. data/spec/lutaml/model/serialize/attribute_definition_block_form_spec.rb +0 -244
  144. data/spec/lutaml/xml/adapter/oga_adapter_spec.rb +0 -135
  145. data/spec/lutaml/xml/opal_xml_spec.rb +0 -204
  146. data/spec/support/opal.rb +0 -9
@@ -1,137 +0,0 @@
1
- # frozen_string: true
2
-
3
- # One-shot generator for lib/compat/opal/lutaml_model_boot.rb.
4
- #
5
- # Walks lib/lutaml/**/*.rb and extracts every `autoload :Name, "path"`
6
- # declaration (single-line or multi-line), resolving the standard
7
- # `"#{__dir__}/..."` and `"#{File.dirname(__FILE__)}/..."` interpolation
8
- # patterns relative to the declaring file's directory.
9
- #
10
- # Opal treats autoload as a no-op, so every autoload target must appear
11
- # here as an explicit `require` for nested constants to resolve at runtime.
12
- #
13
- # Run after adding/removing any autoload in lib/lutaml/:
14
- # ruby lib/compat/opal/generate_boot.rb
15
-
16
- require "pathname"
17
-
18
- REPO_ROOT = Pathname.new(File.expand_path("../../..", __dir__))
19
- LIB = REPO_ROOT.join("lib")
20
-
21
- # Patterns excluded under Opal because they pull in native-only deps
22
- # (Nokogiri/Ox C extensions, Thor CLI, etc.). The one XML adapter
23
- # (moxml_adapter) resolves engine classes through LAZY requires, so it
24
- # is boot-safe. REXML is pure Ruby and ships in the bundled gem +
25
- # moxml's lib/compat/opal/rexml/* shadows, so it is NOT excluded — it
26
- # is a fully working second Opal adapter.
27
- NATIVE_ONLY_PATTERNS = [
28
- %r{/schema/(relaxng|xsd)\b},
29
- %r{/schema_builder/(nokogiri|oga)\b},
30
- %r{/schema/builder/(nokogiri|oga)\b},
31
- %r{\Alutaml/model/cli\z},
32
- # leptris is an FFI wrapper over a native library — Opal::Builder dies
33
- # on its requires (and FFI itself does not exist under Opal); the
34
- # adapter probe degrades to moxml at runtime (#1008).
35
- %r{\Alutaml/xml/leptris},
36
- # The CSV adapter pulls the csv bundled stdlib gem, which has no Opal
37
- # build; CSV instance import/export is not part of the Opal surface
38
- # (Executor's CsvAdapter autoload never fires under Opal either).
39
- %r{\Alutaml/lml/executor/csv_adapter\z},
40
- ].freeze
41
-
42
- # Match `autoload :Name, "...anything..."` where the string argument may
43
- # span multiple physical lines (whitespace after the comma).
44
- DECL_RE = /autoload\s+:[A-Za-z0-9_]+\s*,\s*"([^"]+)"/
45
-
46
- # Stitches multi-line autoload declarations into a single logical line so
47
- # DECL_RE can match. We only merge when the line ends right after the
48
- # comma that follows `autoload :Name`.
49
- def join_multiline_autoloads(src)
50
- src.gsub(/(autoload\s+:[A-Za-z0-9_]+\s*,)\s*\n\s*/) do
51
- "#{Regexp.last_match(1)} "
52
- end
53
- end
54
-
55
- # Resolve an autoload's raw string argument to a require path relative to
56
- # LIB. Both common interpolation shapes resolve relative to the declaring
57
- # file's directory, which is what MRI does for them.
58
- def resolve_path(raw, declaring_file)
59
- declaring_dir = Pathname.new(declaring_file).dirname
60
-
61
- if raw.start_with?("\#{__dir__}/")
62
- subdir = raw.sub("\#{__dir__}/", "").delete_suffix(".rb")
63
- (declaring_dir + subdir).relative_path_from(LIB).to_s.delete_suffix(".rb")
64
- elsif raw.start_with?("\#{File.dirname(__FILE__)}/")
65
- subdir = raw.sub("\#{File.dirname(__FILE__)}/", "").delete_suffix(".rb")
66
- (declaring_dir + subdir).relative_path_from(LIB).to_s.delete_suffix(".rb")
67
- elsif raw.start_with?("lutaml/")
68
- raw.delete_suffix(".rb")
69
- else
70
- raw.delete_suffix(".rb")
71
- end
72
- end
73
-
74
- paths = []
75
- Dir.glob("#{LIB}/lutaml/**/*.rb").each do |file|
76
- src = File.read(file)
77
- # Strip full-line and trailing comments so commented-out autoload
78
- # examples (e.g. in type_registry.rb) don't end up in the boot file.
79
- src = src.lines.reject { |line| line.lstrip.start_with?("#") }.join
80
- join_multiline_autoloads(src).scan(DECL_RE).each do |(raw)|
81
- paths << resolve_path(raw, file)
82
- end
83
- end
84
-
85
- paths = paths.uniq.sort
86
- native_only = paths.select { |p| NATIVE_ONLY_PATTERNS.any? { |re| p =~ re } }
87
- opal_paths = paths - native_only
88
-
89
- # Order matters: namespace-defining entry files must load before any of
90
- # their nested files. lutaml/model.rb declares the Lutaml::Model module
91
- # (referenced by every other file); lutaml/xml.rb declares Lutaml::Xml.
92
- # After the entry files, load by depth-then-name so a parent file (e.g.
93
- # lutaml/hash_format.rb) is required before its children (e.g.
94
- # lutaml/hash_format/adapter/document.rb).
95
- #
96
- # ENTRY_FILES are added unconditionally: they are top-level entry points
97
- # that nothing else autoloads (because they ARE the entry points users
98
- # require directly), so they would otherwise be missing from the list.
99
- # lutaml/lml defines Lutaml::Lml and its error hierarchy — the lutaml/lml/*
100
- # files open the namespace, but the entry file itself is only ever
101
- # user-required, so it must be pinned here.
102
- ENTRY_FILES = %w[lutaml/model lutaml/xml lutaml/lml].freeze
103
- remaining = (opal_paths - ENTRY_FILES).sort_by { |p| [p.count("/"), p] }
104
- ordered = ENTRY_FILES + remaining
105
-
106
- out = []
107
- out << "# frozen_string_literal: true"
108
- out << ""
109
- out << "# DO NOT EDIT — regenerate with:"
110
- out << "# ruby lib/compat/opal/generate_boot.rb"
111
- out << "#"
112
- out << "# Opal does not support Ruby autoload (it is a no-op at parse time)."
113
- out << "# This file explicitly requires every autoload target in lib/lutaml/**"
114
- out << "# so that nested constants resolve at runtime under Opal."
115
- out << "#"
116
- out << "# Native-only paths excluded under Opal:"
117
- out << "# - nokogiri/ox/rexml adapters (C extensions unavailable)"
118
- out << "# - XSD / RELAX NG schema generators (require Nokogiri)"
119
- out << "# - lutaml/model/cli (thor-based, runtime-irrelevant under Opal)"
120
- out << "#"
121
- out << "# Ordering: lutaml/model, lutaml/xml and lutaml/lml define the"
122
- out << "# Lutaml::Model, Lutaml::Xml and Lutaml::Lml namespaces, so they load"
123
- out << "# first. Remaining paths are ordered by depth (shallower first) so"
124
- out << "# parent files declare their child namespaces before children load."
125
- out << "#"
126
- out << "# Loaded by the Opal Rakefile before spec_helper."
127
- out << ""
128
- ordered.each { |p| out << %(require "#{p}") }
129
- out << ""
130
-
131
- # OPAL_BOOT_OUTPUT lets the in-sync guard spec regenerate to a temp path
132
- # without clobbering the committed manifest; unset, it writes canonically.
133
- target = ENV.fetch("OPAL_BOOT_OUTPUT") do
134
- File.expand_path("lutaml_model_boot.rb", __dir__)
135
- end
136
- File.write(target, out.join("\n"))
137
- warn "Generated #{ordered.size} requires (excluded #{native_only.size} native-only paths) -> #{target}"
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # JS bundle entry point. Pulls in the Opal-only compat shims and boot
4
- # files BEFORE lutaml/model so that moxml's adapter constants, the
5
- # String/Encoding/YAML/Array#pack patches, and the eager-loaded
6
- # Moxml::* / Lutaml::* constants are all in place by the time
7
- # lib/lutaml/model.rb runs.
8
- #
9
- # Used by scripts/build.rb as the bundle ENTRY (instead of
10
- # "lutaml/model" directly) so the JS bundle mirrors the load order
11
- # that lutaml-model's Rakefile applies for `rake spec:opal`.
12
-
13
- if RUBY_ENGINE == "opal"
14
- # 0. runtime_compatibility first: it stubs Mutex/ConditionVariable/
15
- # Thread/WeakRef and patches Module#prepend for Opal. Oga's LRU
16
- # and other gems reference Mutex at file-load time, so this must
17
- # run before any gem that touches thread-safety primitives.
18
- require "lutaml/model/runtime_compatibility"
19
-
20
- # 0a. Opal's stdlib StringIO < IO loads here so moxml's
21
- # `class StringIO` (bare, no parent) in rexml_compat.rb re-opens
22
- # the existing class instead of conflicting with `< ::IO`.
23
- # Without this, the bare-class definition runs first and Opal's
24
- # `< IO` definition later raises "superclass mismatch".
25
- require "stringio"
26
-
27
- # 1. stdlib shims: String/Encoding/StringIO + Array#pack + nodejs/yaml
28
- require "rexml_compat"
29
- require "yaml_compat"
30
-
31
- # 2. forks' Opal-aware conditionals select the pure-Ruby lexer
32
- require "oga"
33
- require "ll/setup"
34
-
35
- # 3. eager-load boots (Opal ignores autoload)
36
- require "moxml_boot"
37
- require "lutaml_model_boot"
38
- end
39
-
40
- # 4. the actual entry point
41
- require "lutaml/model"
42
- require "lutaml/xml"