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
@@ -42,10 +42,7 @@ module Lutaml
42
42
  # - A hit returns before the wrapped body runs, so option-hash
43
43
  # mutations the body performs on a miss (e.g. consuming :adapter)
44
44
  # do not happen on a hit.
45
- # - Caching is disabled under Opal: keys need native Marshal/Digest.
46
45
  module ConversionCaching
47
- NATIVE_RUNTIME = !Lutaml::Model::RuntimeCompatibility.opal?
48
-
49
46
  UNMARSHALABLE_IVAR = :@__lutaml_conversion_cache_unmarshalable
50
47
 
51
48
  def cache_conversions
@@ -75,8 +72,7 @@ module Lutaml
75
72
  end
76
73
 
77
74
  def conversion_cache_store(options)
78
- unless NATIVE_RUNTIME && conversion_caching_enabled? &&
79
- options.is_a?(::Hash)
75
+ unless conversion_caching_enabled? && options.is_a?(::Hash)
80
76
  return
81
77
  end
82
78
 
@@ -305,11 +305,6 @@ module Lutaml
305
305
  # Uses TracePoint to detect when a class definition is complete,
306
306
  # allowing deferred import resolution.
307
307
  def setup_trace_point
308
- # Opal has no TracePoint. Symbol imports still resolve lazily
309
- # on first use (ensure_imports!), so there the class is marked
310
- # finalized at once instead of at the end of its body.
311
- return @finalized = true if Lutaml::Model.opal?
312
-
313
308
  @trace ||= TracePoint.new(:end) do |_tp|
314
309
  if include?(Lutaml::Model::Serialize)
315
310
  @finalized = true
@@ -108,9 +108,6 @@ module Lutaml
108
108
  def ensure_utf8(value)
109
109
  case value
110
110
  when String
111
- # Opal strings are JS strings with no per-string encoding;
112
- # String#encode there doesn't accept MRI's keyword options.
113
- return value if Lutaml::Model.opal?
114
111
  # The encode-with-options forces a fresh copy per value even
115
112
  # when the string is already valid UTF-8 — the overwhelming
116
113
  # case on parsed documents. Scan instead: no allocation on
@@ -5,13 +5,10 @@ module Lutaml
5
5
  # the name array rebuilt per node is pure churn (~145k
6
6
  # allocations per heroku.json parse). Rules are stable per
7
7
  # (class, register); the bounded cache tracks their arrays.
8
- RULE_NAMES_CACHE = if Lutaml::Model.opal?
9
- {}
10
- else
11
- Lutaml::Model::RuntimeCompatibility
12
- .require_native("concurrent")
13
- Concurrent::Map.new
14
- end
8
+ RULE_NAMES_CACHE = begin
9
+ Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
10
+ Concurrent::Map.new
11
+ end
15
12
 
16
13
  # The extractor is pure stateless logic over its arguments; the
17
14
  # per-call `new(*args).call` instance (Services::Base's default)
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Opal has no `weakref` stdlib; runtime_compatibility.rb provides a stub.
4
- require "weakref" unless Lutaml::Model.opal?
3
+ # The index holds WeakRef entries, so the instances they point at go
4
+ # out of scope with the GC rather than with the store.
5
+ require "weakref"
5
6
 
6
7
  module Lutaml
7
8
  module Model
@@ -15,18 +16,12 @@ module Lutaml
15
16
  # cumulatively for the class).
16
17
  COMPACTION_INTERVAL = 1000
17
18
 
18
- WeakBucket = if Lutaml::Model.opal?
19
- # Opal has neither WeakRef nor ObjectSpace::WeakMap; documents in
20
- # the browser are small, so strong references are the fallback.
21
- ::Hash
22
- else
23
- # CRuby: WeakMap holds keys weakly with zero Ruby-level
24
- # allocation per insert and no per-object finalizer — the WeakRef
25
- # approach allocated one finalizer-registering object per
26
- # instance (lutaml-model#695) and dominated GC cycles on
27
- # instance-heavy parses.
28
- ::ObjectSpace::WeakMap
29
- end
19
+ # WeakMap holds keys weakly with zero Ruby-level allocation per
20
+ # insert and no per-object finalizer — the WeakRef approach
21
+ # allocated one finalizer-registering object per instance
22
+ # (lutaml-model#695) and dominated GC cycles on instance-heavy
23
+ # parses.
24
+ WeakBucket = ::ObjectSpace::WeakMap
30
25
 
31
26
  class << self
32
27
  def instance
@@ -210,9 +205,7 @@ module Lutaml
210
205
 
211
206
  def live_objects_for(bucket)
212
207
  # WeakMap#each_key requires a block on CRuby; WeakMap#each
213
- # yields key/value pairs, and Hash buckets enumerate the same
214
- # way (value is `true` for WeakMap, the object for the Opal
215
- # fallback keyed by object identity).
208
+ # yields key/value pairs (value is `true` for WeakMap).
216
209
  bucket.map { |key, _value| key }
217
210
  end
218
211
 
@@ -17,8 +17,6 @@ module Lutaml
17
17
  Transform = ::Lutaml::Toml::Adapter::Transform
18
18
 
19
19
  def self.detect_toml_adapter
20
- return nil if Lutaml::Model.opal?
21
-
22
20
  # teptris 0.2.12+ parses ~3x and dumps ~8x faster than tomlib
23
21
  # and ships prebuilts for every platform (mingw-ucrt restored
24
22
  # in 0.2.4+) — native TOML on Windows retires the tomlib
@@ -94,11 +94,7 @@ module Lutaml
94
94
  # add minutes to process boot
95
95
  Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
96
96
  @transformations = {} # Cache for transformation instances (mutex-protected for cycle detection)
97
- @mappings = if Lutaml::Model.opal?
98
- {}
99
- else
100
- Concurrent::Map.new
101
- end
97
+ @mappings = Concurrent::Map.new
102
98
  @mutex = Mutex.new
103
99
  @building_threads = {} # Track which thread is building each transformation
104
100
  @condition = ConditionVariable.new
@@ -199,10 +195,10 @@ module Lutaml
199
195
  end
200
196
 
201
197
  # Inner cache level container matching the outer map's engine
202
- # (Concurrent::Map under GVL-threaded MRI, plain Hash under Opal).
198
+ # (Concurrent::Map under GVL-threaded MRI).
203
199
  def new_inner_map
204
200
  Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
205
- Lutaml::Model.opal? ? {} : ::Concurrent::Map.new
201
+ ::Concurrent::Map.new
206
202
  end
207
203
 
208
204
  # Clear all cached data (transformations and mappings).
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.200"
5
+ VERSION = "0.8.202"
6
6
  end
7
7
  end
data/lib/lutaml/model.rb CHANGED
@@ -263,18 +263,9 @@ module Lutaml
263
263
  @configuration = nil
264
264
  end
265
265
 
266
- # Convenience accessors for runtime/platform detection.
267
- # Delegates to RuntimeCompatibility so call sites can write
268
- # `Lutaml::Model.opal?` (or `Model.opal?` inside the namespace)
269
- # instead of the long `Lutaml::Model::RuntimeCompatibility.opal?`.
270
- def self.opal?
271
- RuntimeCompatibility.opal?
272
- end
273
-
274
- def self.native?
275
- RuntimeCompatibility.native?
276
- end
277
-
266
+ # Platform detection, delegated to RuntimeCompatibility so call sites
267
+ # can write `Lutaml::Model.windows?` (or `Model.windows?` inside the
268
+ # namespace).
278
269
  def self.windows?
279
270
  RuntimeCompatibility.windows?
280
271
  end
@@ -300,10 +291,3 @@ require "#{__dir__}/xml/format"
300
291
  # Builder must be prepended AFTER XML so its initialize runs first
301
292
  # (Builder -> XML InstanceMethods -> Serialize)
302
293
  Lutaml::Model::Serialize.prepend(Lutaml::Model::Serialize::Builder)
303
-
304
- # Opal does not propagate a module prepended into an already-included
305
- # module to classes that included it earlier (see lib/lutaml/xml/format.rb).
306
- # Serializable included Serialize at boot, so Builder goes onto it directly.
307
- if Lutaml::Model.opal?
308
- Lutaml::Model::Serializable.prepend(Lutaml::Model::Serialize::Builder)
309
- end
@@ -31,14 +31,10 @@ Lutaml::Model::FormatRegistry.register(
31
31
  adapter_class: nil,
32
32
  transformer: Lutaml::Toml::Adapter::Transform,
33
33
  key_value: true,
34
- adapter_options: if Lutaml::Model.opal?
35
- nil
36
- else
37
- {
38
- available: %i[teptris tomlib toml_rb],
39
- default: Lutaml::Model::RuntimeCompatibility.windows? ? :toml_rb : :tomlib,
40
- }
41
- end,
34
+ adapter_options: {
35
+ available: %i[teptris tomlib toml_rb],
36
+ default: Lutaml::Model::RuntimeCompatibility.windows? ? :toml_rb : :tomlib,
37
+ },
42
38
  )
43
39
 
44
40
  require_relative "type/serializers"
@@ -26,8 +26,7 @@ module Lutaml
26
26
  class MoxmlAdapter < BaseAdapter
27
27
  class << self
28
28
  # Engine registry: the lazy requires keep this file free of
29
- # native-only dependencies at load time (the Opal boot
30
- # requires this file unconditionally). `parse_error` is the
29
+ # engine-only dependencies at load time. `parse_error` is the
31
30
  # engine error class the parse boundary rescues into a
32
31
  # format error (nil = ride moxml's own error surface); the
33
32
  # rexml entry carries the historical empty-document error
@@ -43,11 +42,6 @@ module Lutaml
43
42
  moxml_adapter: "Moxml::Adapter::Leptris",
44
43
  parse_error: "Moxml::ParseError",
45
44
  },
46
- oga: {
47
- requires: ["oga", "moxml/adapter/oga"],
48
- moxml_adapter: "Moxml::Adapter::Oga",
49
- parse_error: nil,
50
- },
51
45
  ox: {
52
46
  requires: ["moxml/adapter/ox"],
53
47
  moxml_adapter: "Moxml::Adapter::Ox",
@@ -12,10 +12,6 @@ module Lutaml
12
12
  autoload :PlanBasedBuilder, "#{__dir__}/adapter/plan_based_builder"
13
13
  autoload :NamespaceUriCollector,
14
14
  "#{__dir__}/adapter/namespace_uri_collector"
15
- # Plain autoload (in addition to the native table): the Opal boot
16
- # generator harvests `autoload :Name, "path"` declarations only,
17
- # so the facade must appear here to ride the sequential boot.
18
- autoload :MoxmlAdapter, "#{__dir__}/adapter/moxml_adapter"
19
15
  Lutaml::Model::RuntimeCompatibility.autoload_native(
20
16
  self,
21
17
  MoxmlAdapter: "#{__dir__}/adapter/moxml_adapter",
@@ -20,12 +20,7 @@ module Lutaml
20
20
  # "nokogiri_adapter") — informational; all types share the
21
21
  # one adapter file
22
22
  def self.load_adapter_file(_adapter, _type)
23
- adapter_path = if Lutaml::Model.opal?
24
- "lutaml/xml/adapter/#{ADAPTER_FILE}"
25
- else
26
- File.join(File.dirname(__FILE__), "adapter",
27
- ADAPTER_FILE)
28
- end
23
+ adapter_path = File.join(File.dirname(__FILE__), "adapter", ADAPTER_FILE)
29
24
  require adapter_path
30
25
  rescue LoadError => e
31
26
  raise Lutaml::Model::UnknownAdapterTypeError.new("xml", ADAPTER_FILE),
@@ -18,9 +18,6 @@ module Lutaml
18
18
  def self.build(options = {})
19
19
  engine = options.delete(:engine) || Lutaml::Xml.moxml_engine
20
20
  context = Moxml.new(engine)
21
- if Lutaml::Model.opal?
22
- context.config.namespace_validation_mode = :lenient
23
- end
24
21
 
25
22
  encoding_value = options.delete(:encoding)
26
23
  context.config.default_indent = options.delete(:indent) if options.key?(:indent)
@@ -5,14 +5,6 @@ module Lutaml
5
5
  # Builder module for XML generation
6
6
  module Builder
7
7
  autoload :Base, "#{__dir__}/builder/base"
8
- autoload :Oga, "#{__dir__}/builder/oga"
9
- autoload :Rexml, "#{__dir__}/builder/rexml"
10
- Lutaml::Model::RuntimeCompatibility.autoload_native(
11
- self,
12
- Nokogiri: "#{__dir__}/builder/nokogiri",
13
- Ox: "#{__dir__}/builder/ox",
14
- Leptris: "#{__dir__}/builder/leptris",
15
- )
16
8
  end
17
9
  end
18
10
  end
@@ -6,7 +6,7 @@ module Lutaml
6
6
  #
7
7
  # These classes represent XML structure without serialization logic,
8
8
  # allowing transformation to produce XML data that can be serialized
9
- # by different adapters (Nokogiri, Ox, Oga).
9
+ # by different adapters (Nokogiri, Ox).
10
10
  module DataModel
11
11
  # Represents an XML element with namespace, attributes, and children.
12
12
  class XmlElement
@@ -6,13 +6,13 @@ module Lutaml
6
6
  #
7
7
  # This module provides a shared method to extract DOCTYPE declarations
8
8
  # from raw XML strings when the XML library doesn't directly expose this
9
- # information (as is the case with Moxml/Oga and Ox).
9
+ # information (as is the case with Moxml and Ox).
10
10
  #
11
11
  # Nokogiri provides native access to DOCTYPE via `parsed.internal_subset`,
12
12
  # so it doesn't need this extraction method.
13
13
  #
14
- # This logic is identical in both Oga and Ox adapters and has been
15
- # extracted here to maintain DRY principles.
14
+ # This logic is shared by the Ox path and has been extracted here
15
+ # to maintain DRY principles.
16
16
  module DocTypeExtractor
17
17
  # Extract DOCTYPE information from raw XML string
18
18
  #
@@ -10,15 +10,6 @@
10
10
  # XML requires moxml for parsing
11
11
  require "moxml"
12
12
 
13
- # Under Opal, moxml's autoloads don't fire (Opal ignores autoload).
14
- # Pull in the eager-load boot that ships at lib/compat/opal/moxml_boot.rb
15
- # so Moxml::Adapter::{Oga,Rexml} etc. are actually defined. Without
16
- # this, `Config.adapter = :oga` later fails with
17
- # `NameError: uninitialized constant Moxml::Adapter::Oga`.
18
- if Lutaml::Model.opal?
19
- require "moxml_boot"
20
- end
21
-
22
13
  module Lutaml
23
14
  module Xml
24
15
  autoload :HtmlEntities, "#{__dir__}/html_entities"
@@ -195,32 +186,20 @@ Lutaml::Model::FormatRegistry.register(
195
186
  Ox::ParseError
196
187
  REXML::ParseException
197
188
  ],
198
- adapter_options: if Lutaml::Model.opal?
199
- # Both Oga (vendored opal-oga fork, pure-Ruby lexer)
200
- # and REXML (bundled stdlib gem, pure Ruby) work
201
- # under Opal. Oga is the default because moxml's CI
202
- # verifies it most thoroughly; REXML is selectable
203
- # for callers that prefer a stdlib-only stack.
204
- {
205
- available: %i[oga rexml],
206
- default: :oga,
207
- }
208
- else
209
- {
210
- available: %i[nokogiri ox oga rexml leptris moxml],
211
- # #908: the metadata default is the LAST resort —
212
- # explicit configuration and moxml runtime detection
213
- # answer first. When resolution falls this far, prefer
214
- # leptris, consistent with moxml's runtime preference
215
- # (leptris whenever present); bundles without it
216
- # resolve through auto-detection long before here.
217
- # #1224: the metadata default is the DEFERRED lane -
218
- # resolution defers the engine to moxml at parse
219
- # time (the facade lane), so a consumer selecting the
220
- # default never hard-codes an engine name.
221
- default: :moxml,
222
- }
223
- end,
189
+ adapter_options: {
190
+ available: %i[nokogiri ox rexml leptris moxml],
191
+ # #908: the metadata default is the LAST resort —
192
+ # explicit configuration and moxml runtime detection
193
+ # answer first. When resolution falls this far, prefer
194
+ # leptris, consistent with moxml's runtime preference
195
+ # (leptris whenever present); bundles without it
196
+ # resolve through auto-detection long before here.
197
+ # #1224: the metadata default is the DEFERRED lane -
198
+ # resolution defers the engine to moxml at parse
199
+ # time (the facade lane), so a consumer selecting the
200
+ # default never hard-codes an engine name.
201
+ default: :moxml,
202
+ },
224
203
  )
225
204
 
226
205
  # Register XML transformation builder
@@ -248,18 +227,18 @@ Lutaml::Model::Serialize.prepend(
248
227
  Lutaml::Xml::Serialization::InstanceMethods,
249
228
  )
250
229
 
251
- # Opal does not propagate methods prepended into an already-included module
252
- # to classes that included it before the prepend. Serializable includes
253
- # Serialize during model boot, so make the XML instance API available on the
254
- # concrete base class as well.
230
+ # TruffleRuby does not propagate methods prepended into an already-included
231
+ # module to classes that included it before the prepend. Serializable
232
+ # includes Serialize during model boot, so the XML instance API is made
233
+ # available on the concrete base class as well.
255
234
  #
256
235
  # Anonymous model classes (Class.new { include Serialize }) extend
257
236
  # Serialize::ClassMethods rather than inheriting from Serializable, so the
258
237
  # ModelImportExt override (root?) must land on ClassMethods too.
259
238
  #
260
- # On Opal (and TruffleRuby, below) the ClassMethods.prepend(FormatConversion)
261
- # above does not reach Serializable's singleton chain, which extended
262
- # ClassMethods before it ran, so it is prepended onto that singleton directly.
239
+ # The ClassMethods.prepend(FormatConversion) above does not reach
240
+ # Serializable's singleton chain, which extended ClassMethods before it
241
+ # ran, so it is prepended onto that singleton directly.
263
242
  #
264
243
  # TruffleRuby (34.0.1) has the same propagation gap, on both the include
265
244
  # side and the extend/singleton side — a module prepended into an
@@ -274,7 +253,7 @@ Lutaml::Model::Serialize.prepend(
274
253
  # mixed, doctype, xml_declaration, raw_schema_location), so
275
254
  # ModelTransform#apply_xml_mapping dies at `instance.encoding = ...` —
276
255
  # e.g. every relaton ItemData parse via Relaton::Cli.parse_xml.
277
- if Lutaml::Model.opal? || RUBY_ENGINE == "truffleruby"
256
+ if RUBY_ENGINE == "truffleruby"
278
257
  Lutaml::Model::Serializable.singleton_class.prepend(
279
258
  Lutaml::Xml::Serialization::ModelImportExt,
280
259
  )
@@ -308,30 +287,14 @@ Lutaml::Xml::Type::Serializers.register_all!
308
287
 
309
288
  # Register XML schema methods
310
289
  Lutaml::Model::Schema.register_method(:to_xsd) do |klass, options = {}|
311
- if Lutaml::Model.opal?
312
- raise NotImplementedError,
313
- "XSD schema generation is not available under Opal."
314
- end
315
-
316
290
  Lutaml::Xml::Schema::XsdSchema.generate(klass, options)
317
291
  end
318
292
 
319
293
  Lutaml::Model::Schema.register_method(:to_relaxng) do |klass, options = {}|
320
- if Lutaml::Model.opal?
321
- raise NotImplementedError,
322
- "RELAX NG schema generation requires Nokogiri, " \
323
- "which is not available under Opal."
324
- end
325
-
326
294
  Lutaml::Xml::Schema::RelaxngSchema.generate(klass, options)
327
295
  end
328
296
 
329
297
  Lutaml::Model::Schema.register_method(:from_xml) do |xml, options = {}|
330
- if Lutaml::Model.opal?
331
- raise NotImplementedError,
332
- "XML schema compilation is not available under Opal."
333
- end
334
-
335
298
  Lutaml::Model::Schema::XmlCompiler.to_models(xml, options)
336
299
  end
337
300
 
@@ -341,31 +304,16 @@ end
341
304
  # it; see #1204). Rides Xsd.parse so the metaschema registration
342
305
  # preamble runs before the parse resolves attribute types.
343
306
  Lutaml::Model::Schema.register_method(:target_namespace) do |xml|
344
- if Lutaml::Model.opal?
345
- raise NotImplementedError,
346
- "XML schema compilation is not available under Opal."
347
- end
348
-
349
307
  parsed = Lutaml::Xml::Schema::Xsd.parse(xml, validate_schema: false)
350
308
  schema = parsed.is_a?(Array) ? parsed.first : parsed
351
309
  schema&.target_namespace
352
310
  end
353
311
 
354
312
  Lutaml::Model::Schema.register_method(:from_relaxng) do |rng, options = {}|
355
- if Lutaml::Model::RuntimeCompatibility.opal?
356
- raise NotImplementedError,
357
- "RELAX NG schema compilation is not available under Opal."
358
- end
359
-
360
313
  Lutaml::Model::Schema::RngCompiler.to_models(rng, options)
361
314
  end
362
315
 
363
316
  Lutaml::Model::Schema.register_method(:from_rnc) do |rnc, options = {}|
364
- if Lutaml::Model::RuntimeCompatibility.opal?
365
- raise NotImplementedError,
366
- "RNC schema compilation is not available under Opal."
367
- end
368
-
369
317
  Lutaml::Model::Schema::RncCompiler.to_models(rnc, options)
370
318
  end
371
319
 
@@ -388,8 +388,7 @@ module Lutaml
388
388
  # on the theme docx). The tree is complete here; freeze
389
389
  # now.
390
390
  begin
391
- # Lazy: the Opal boot loads this file, and leptris is a
392
- # native gem there — the require only belongs on the
391
+ # Lazy: the leptris require only belongs on the
393
392
  # engines-enabled path.
394
393
  require "leptris/xml/descriptor"
395
394
  descriptor = ::Leptris::XML::Descriptor.build(**tree)
@@ -16,40 +16,31 @@ module Lutaml
16
16
  # rules — attribute, derived/valid flags, and #765 group-skip —
17
17
  # keyed on the mapping's finalize version so late changes rebuild.
18
18
  # The loop body used to re-derive these per parsed instance.
19
- # Concurrent::Map under threaded MRI, plain Hash under Opal
20
- # (Concurrent is unavailable there); class identity keys either.
19
+ # Concurrent::Map; class identity keys.
21
20
  # Concurrent is required here (not at boot) so its first load never
22
21
  # happens inside RubyGems' unresolved-tree resolution (see
23
22
  # TransformationRegistry#initialize).
24
- RULE_RECORDS = if Lutaml::Model.opal?
25
- {}
26
- else
27
- Lutaml::Model::RuntimeCompatibility
28
- .require_native("concurrent")
29
- Concurrent::Map.new # rubocop:disable Lint/HashCompareByIdentity
30
- end
23
+ RULE_RECORDS = begin
24
+ Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
25
+ Concurrent::Map.new # rubocop:disable Lint/HashCompareByIdentity
26
+ end
31
27
 
32
28
  # Namespaced rule name -> [local_name, rule_uri]. Pure string
33
29
  # splitting, deterministic per spelling, shared across parses.
34
- # Concurrent::Map under threaded MRI, plain Hash under Opal.
35
- NAMESPACED_NAME_PARTS = if Lutaml::Model.opal?
36
- {}
37
- else
38
- Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
39
- Concurrent::Map.new
40
- end
30
+ NAMESPACED_NAME_PARTS = begin
31
+ Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
32
+ Concurrent::Map.new
33
+ end
41
34
 
42
35
  # Rule name -> its local suffix after the last colon. The
43
36
  # cross-namespace fallback probes this suffix per rule name per
44
37
  # child per element (11M substring mints on a 2M-node parse);
45
38
  # the suffix is static per spelling, so it is shared here with
46
39
  # the same backing as NAMESPACED_NAME_PARTS.
47
- RULE_LOCAL_NAMES = if Lutaml::Model.opal?
48
- {}
49
- else
50
- Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
51
- Concurrent::Map.new
52
- end
40
+ RULE_LOCAL_NAMES = begin
41
+ Lutaml::Model::RuntimeCompatibility.require_native("concurrent")
42
+ Concurrent::Map.new
43
+ end
53
44
  include NestedCollectionAttribute
54
45
 
55
46
  # Performance: Frozen empty hash to reduce allocations
@@ -955,7 +946,6 @@ _effective_register)
955
946
  def decode_html_entities_value(value, enabled)
956
947
  return value if value.nil? || !value.is_a?(String)
957
948
  return value unless enabled
958
- return value if Lutaml::Model.opal?
959
949
 
960
950
  Lutaml::Xml::HtmlEntities.decode(value)
961
951
  end
@@ -971,7 +961,7 @@ _effective_register)
971
961
  version = mapping&.rule_records_version.to_i
972
962
  per_class = RULE_RECORDS[model_class.object_id] # rubocop:disable Lint/HashCompareByIdentity
973
963
  unless per_class
974
- per_class = Lutaml::Model.opal? ? {} : Concurrent::Map.new
964
+ per_class = Concurrent::Map.new
975
965
  RULE_RECORDS[model_class.object_id] = per_class # rubocop:disable Lint/HashCompareByIdentity
976
966
  end
977
967
  cached = per_class[register]
@@ -13,7 +13,7 @@ module Lutaml
13
13
  # `polymorphic_class: true`, indicating it's part of a polymorphic
14
14
  # inheritance tree
15
15
  #
16
- # This logic is identical across all XML adapters (Nokogiri, Oga, Ox)
16
+ # This logic is identical across all XML adapters (Nokogiri, Ox)
17
17
  # and has been extracted here to maintain DRY principles.
18
18
  module PolymorphicValueHandler
19
19
  # Determine if a value should be treated as polymorphic
@@ -13,7 +13,7 @@ module Lutaml
13
13
  # Moxml (the closed #1183 leak).
14
14
  #
15
15
  # The block receives the Moxml::Builder and drives it with
16
- # the same method_missing tag DSL the Nokogiri/Oga wrappers
16
+ # the same method_missing tag DSL the Nokogiri wrapper
17
17
  # expose: tag(attrs) { ... } closures, symbol or string
18
18
  # attribute keys, xmlns handled as a namespace declaration.
19
19
  class Moxml
@@ -4,22 +4,21 @@ module Lutaml
4
4
  module Xml
5
5
  module Schema
6
6
  # SchemaBuilder provides an adapter-agnostic interface for XSD schema generation
7
- # It wraps XML builders (Nokogiri, Oga) to generate XSD documents
7
+ # It wraps XML builders (Nokogiri, or the moxml layer) to generate XSD documents
8
8
  #
9
9
  # NOTE: Schema generation is separate from XML parsing. While the XML parsing
10
- # adapters (Nokogiri, Oga, Ox, REXML) handle reading/writing XML documents,
11
- # schema generation requires an XML builder API which is only implemented for
12
- # Nokogiri and Oga. When the configured XML adapter is Ox or REXML, we use
13
- # Nokogiri for schema generation since it has the most complete builder API.
10
+ # adapters (Nokogiri, Ox, REXML) handle reading/writing XML documents, schema
11
+ # generation requires an XML builder API: the Nokogiri wrapper keeps
12
+ # byte-identical emission, and every other configured engine generates
13
+ # through the moxml layer.
14
14
  class Builder
15
15
  autoload :Nokogiri, "#{__dir__}/builder/nokogiri"
16
- autoload :Oga, "#{__dir__}/builder/oga"
17
16
  autoload :Moxml, "#{__dir__}/builder/moxml"
18
17
 
19
18
  attr_reader :builder, :adapter_type
20
19
 
21
20
  # Supported schema builders (separate from XML parsing adapters)
22
- SUPPORTED_BUILDERS = %i[nokogiri oga].freeze
21
+ SUPPORTED_BUILDERS = %i[nokogiri].freeze
23
22
 
24
23
  def initialize(adapter_type: nil, options: {}, &block)
25
24
  # Use specified adapter, or configured XML adapter, or default to Nokogiri
@@ -48,8 +47,6 @@ module Lutaml
48
47
  case @adapter_type
49
48
  when :nokogiri
50
49
  Nokogiri.new(@options, &block)
51
- when :oga
52
- Oga.new(@options, &block)
53
50
  else
54
51
  Moxml.new(@options, &block)
55
52
  end
@@ -8,7 +8,7 @@ module Lutaml
8
8
  # Generates RELAX NG schemas from LutaML model classes. The
9
9
  # emission rides the configured engine through the moxml layer
10
10
  # (#1184); an explicit adapter option keeps the dedicated
11
- # Nokogiri/Oga wrappers available.
11
+ # Nokogiri wrapper available.
12
12
  class RelaxngSchema
13
13
  extend Lutaml::Model::Schema::SharedMethods
14
14
 
@@ -203,8 +203,9 @@ module Lutaml
203
203
  # This supports the new namespace_definitions approach where each element only
204
204
  # stores its own declarations, and child elements inherit from parent
205
205
  #
206
- # NOTE: Not cached here because Oga::Element#initialize calls this before
207
- # super() sets @parent_document, which would cache an incorrect empty result.
206
+ # NOTE: Not cached here because an engine element's initialize calls
207
+ # this before super() sets @parent_document, which would cache an
208
+ # incorrect empty result.
208
209
  # The hot path (namespaced_name) is cached separately.
209
210
  if @namespaces&.any?
210
211
  @namespaces