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.
- checksums.yaml +4 -4
- data/.github/scripts/test_installed_gem.rb +1 -13
- data/.github/workflows/downstream-performance.yml +1 -22
- data/.github/workflows/performance.yml +1 -33
- data/.github/workflows/rake.yml +2 -6
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -4
- data/Gemfile +0 -23
- data/README.adoc +25 -86
- data/Rakefile +2 -167
- data/docs/_guides/advanced-mapping.adoc +6 -6
- data/docs/_guides/character-encoding.adoc +0 -3
- data/docs/_guides/gem-integration.adoc +1 -1
- data/docs/_guides/index.adoc +0 -4
- data/docs/_guides/xml/type-namespaces.adoc +1 -1
- data/docs/_guides/xml-guide-0.8.0.adoc +2 -2
- data/docs/_guides/xml-namespaces.adoc +2 -3
- data/docs/_guides/xml_mappings/03_architecture.adoc +2 -2
- data/docs/_guides/xml_mappings/07_best_practices.adoc +2 -3
- data/docs/_guides/xml_mappings/08_troubleshooting.adoc +1 -9
- data/docs/_pages/comparison-with-shale.adoc +1 -1
- data/docs/_pages/configuration.adoc +6 -40
- data/docs/_pages/index.adoc +0 -1
- data/docs/_pages/serialization_adapters.adoc +4 -16
- data/docs/_references/architecture.adoc +1 -1
- data/docs/_references/lutaml-namespace-planning.md +1 -1
- data/docs/_references/three-phase-namespace-architecture.adoc +1 -2
- data/docs/_references/xsd-generation-with-namespace-support.adoc +3 -8
- data/docs/_tutorials/lutaml-xml-architecture.adoc +2 -8
- data/docs/architecture.md +7 -11
- data/docs/conversion_caching.adoc +1 -1
- data/docs/index.adoc +0 -1
- data/docs/key_value_data_model.adoc +1 -1
- data/docs/namespace-management.adoc +4 -10
- data/lib/lutaml/json/format.rb +0 -1
- data/lib/lutaml/json/generator_options.rb +0 -1
- data/lib/lutaml/key_value/transform.rb +9 -16
- data/lib/lutaml/lml/document_builder.rb +2 -2
- data/lib/lutaml/lml/entity_types.rb +2 -2
- data/lib/lutaml/model/adapter_resolver.rb +5 -15
- data/lib/lutaml/model/attribute.rb +14 -2
- data/lib/lutaml/model/cached_type_resolver.rb +1 -7
- data/lib/lutaml/model/error/unknown_adapter_type_error.rb +1 -1
- data/lib/lutaml/model/global_context.rb +3 -5
- data/lib/lutaml/model/instrumentation.rb +0 -3
- data/lib/lutaml/model/mapping/mapping_rule.rb +6 -10
- data/lib/lutaml/model/register.rb +20 -31
- data/lib/lutaml/model/runtime_compatibility.rb +0 -92
- data/lib/lutaml/model/schema/class_loader.rb +2 -4
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/simple_types.rb +2 -3
- data/lib/lutaml/model/serialize/attribute_definition.rb +10 -184
- data/lib/lutaml/model/serialize/conversion_caching.rb +1 -5
- data/lib/lutaml/model/serialize/model_import.rb +0 -5
- data/lib/lutaml/model/serialize/value_mapping.rb +0 -3
- data/lib/lutaml/model/services/rule_value_extractor.rb +4 -7
- data/lib/lutaml/model/store.rb +10 -17
- data/lib/lutaml/model/toml.rb +0 -2
- data/lib/lutaml/model/transformation_registry.rb +3 -7
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model.rb +3 -19
- data/lib/lutaml/toml/format.rb +4 -8
- data/lib/lutaml/xml/adapter/moxml_adapter.rb +1 -7
- data/lib/lutaml/xml/adapter.rb +0 -4
- data/lib/lutaml/xml/adapter_loader.rb +1 -6
- data/lib/lutaml/xml/builder/base.rb +0 -3
- data/lib/lutaml/xml/builder.rb +0 -8
- data/lib/lutaml/xml/data_model.rb +1 -1
- data/lib/lutaml/xml/doctype_extractor.rb +3 -3
- data/lib/lutaml/xml/format.rb +22 -74
- data/lib/lutaml/xml/leptris/plan_compiler.rb +1 -2
- data/lib/lutaml/xml/model_transform.rb +14 -24
- data/lib/lutaml/xml/polymorphic_value_handler.rb +1 -1
- data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
- data/lib/lutaml/xml/schema/builder.rb +6 -9
- data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
- data/lib/lutaml/xml/xml_element.rb +3 -2
- data/lib/lutaml/xml/xsd_validator.rb +4 -11
- data/lib/lutaml/yaml/adapter/yeptris_adapter.rb +2 -2
- data/lib/lutaml/yamls/adapter_loader.rb +1 -5
- data/lib/tasks/performance_comparator.rb +1 -1
- data/lutaml-model.gemspec +3 -8
- data/spec/benchmarks/xml_parsing_benchmark_spec.rb +1 -1
- data/spec/lutaml/json/adapter/standard_adapter_spec.rb +6 -9
- data/spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb +0 -2
- data/spec/lutaml/model/cached_type_resolver_spec.rb +2 -54
- data/spec/lutaml/model/cdata_spec.rb +2 -15
- data/spec/lutaml/model/encoding_spec.rb +0 -9
- data/spec/lutaml/model/except_spec.rb +0 -7
- data/spec/lutaml/model/json_spec.rb +0 -14
- data/spec/lutaml/model/mixed_content_spec.rb +6 -46
- data/spec/lutaml/model/ordered_content_spec.rb +0 -7
- data/spec/lutaml/model/polymorphic_scalar_member_spec.rb +57 -0
- data/spec/lutaml/model/processing_instruction_spec.rb +0 -6
- data/spec/lutaml/model/runtime_compatibility_spec.rb +0 -37
- data/spec/lutaml/model/serializable_spec.rb +0 -2
- data/spec/lutaml/model/toml_spec.rb +0 -23
- data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +0 -4
- data/spec/lutaml/xml/adapter/order_spec.rb +1 -1
- data/spec/lutaml/xml/adapter/xml_namespace_spec.rb +0 -7
- data/spec/lutaml/xml/attribute_namespace_disjointness_spec.rb +6 -6
- data/spec/lutaml/xml/builder/builder_spec.rb +0 -24
- data/spec/lutaml/xml/default_namespace_spec.rb +1 -8
- data/spec/lutaml/xml/doctype_preservation_spec.rb +0 -4
- data/spec/lutaml/xml/entity_fragmentation_spec.rb +0 -6
- data/spec/lutaml/xml/fpi_namespace_spec.rb +0 -21
- data/spec/lutaml/xml/mapping_spec.rb +8 -15
- data/spec/lutaml/xml/namespace_scope_vcard_spec.rb +0 -7
- data/spec/lutaml/xml/namespace_spec.rb +0 -13
- data/spec/lutaml/xml/prefix_control_spec.rb +0 -6
- data/spec/lutaml/xml/schema/builder_moxml_spec.rb +1 -1
- data/spec/lutaml/xml/xml_adapter_spec.rb +0 -7
- data/spec/lutaml/xml/xml_spec.rb +2 -88
- data/spec/spec_helper.rb +5 -24
- data/spec/support/test_adapter_config.rb +6 -6
- metadata +1 -32
- data/.github/workflows/js-pr-check.yml +0 -106
- data/.github/workflows/js-sync.yml +0 -55
- data/.github/workflows/opal.yml +0 -65
- data/.gitmodules +0 -6
- data/.rspec-opal +0 -5
- data/docs/_guides/opal.adoc +0 -232
- data/lib/compat/opal/generate_boot.rb +0 -137
- data/lib/compat/opal/js_bundle_entry.rb +0 -42
- data/lib/compat/opal/lutaml_model_boot.rb +0 -638
- data/lib/compat/opal/monitor.rb +0 -31
- data/lib/compat/opal/moxml/adapter/customized_rexml/entity_reference.rb +0 -9
- data/lib/compat/opal/moxml/adapter/customized_rexml/formatter.rb +0 -225
- data/lib/compat/opal/moxml/adapter/customized_rexml.rb +0 -11
- data/lib/compat/opal/moxml_boot.rb +0 -68
- data/lib/compat/opal/objectspace_shim.rb +0 -23
- data/lib/compat/opal/rexml/namespace.rb +0 -59
- data/lib/compat/opal/rexml/parsers/baseparser.rb +0 -1016
- data/lib/compat/opal/rexml/source.rb +0 -214
- data/lib/compat/opal/rexml/text.rb +0 -426
- data/lib/compat/opal/rexml/xmltokens.rb +0 -45
- data/lib/compat/opal/rexml_compat.rb +0 -85
- data/lib/compat/opal/yaml_compat.rb +0 -32
- data/lib/lutaml/model/cached_type_resolver/mutex_hash_cache.rb +0 -53
- data/lib/lutaml/model/schema/schema_builder/oga.rb +0 -92
- data/lib/lutaml/xml/schema/builder/oga.rb +0 -92
- data/spec/lutaml/model/boot_manifest_spec.rb +0 -30
- data/spec/lutaml/model/opal_smoke_spec.rb +0 -199
- data/spec/lutaml/model/serialize/attribute_definition_block_form_spec.rb +0 -244
- data/spec/lutaml/xml/adapter/oga_adapter_spec.rb +0 -135
- data/spec/lutaml/xml/opal_xml_spec.rb +0 -204
- 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"
|