lutaml-model 0.8.162 → 0.8.164
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/Gemfile +1 -1
- data/bench/bench_kv_materialization.rb +125 -0
- data/lib/compat/opal/lutaml_model_boot.rb +2 -0
- data/lib/lutaml/key_value/mapping.rb +23 -2
- data/lib/lutaml/key_value/transform.rb +13 -8
- data/lib/lutaml/key_value/transformation/value_serializer.rb +8 -0
- data/lib/lutaml/key_value/transformation.rb +21 -2
- data/lib/lutaml/model/adapter_resolver.rb +27 -2
- data/lib/lutaml/model/attribute.rb +31 -1
- data/lib/lutaml/model/mapping/mapping.rb +8 -1
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/leptris/native_emission.rb +499 -35
- data/lib/lutaml/xml/leptris/plan_serializer.rb +9 -3
- data/lib/lutaml/yamls/adapter/yeptris_adapter.rb +54 -0
- data/lib/lutaml/yamls/adapter.rb +1 -0
- data/lib/lutaml/yamls/adapter_loader.rb +49 -0
- data/lib/lutaml/yamls/format.rb +6 -0
- data/spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb +40 -0
- data/spec/lutaml/model/json_hash_collection_spec.rb +37 -0
- data/spec/lutaml/model/kv_flatten_memo_spec.rb +49 -0
- data/spec/lutaml/model/yamls/yeptris_adapter_spec.rb +70 -0
- data/spec/lutaml/xml/leptris/native_emission_ns_parity_spec.rb +56 -0
- data/spec/lutaml/xml/leptris/native_emission_ordered_spec.rb +144 -0
- data/spec/lutaml/xml/leptris/native_emission_raw_gate_spec.rb +26 -0
- data/spec/lutaml/xml/plan_uri_exact_dispatch_spec.rb +8 -1
- metadata +12 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "standard_adapter"
|
|
4
|
+
|
|
5
|
+
module Lutaml
|
|
6
|
+
module Yamls
|
|
7
|
+
module Adapter
|
|
8
|
+
# YAMLS streams over the yeptris engine (libyeptris C11), using the
|
|
9
|
+
# multi-document stream API at Psych parity (yeptris-ruby#354).
|
|
10
|
+
# Inherits the standard adapter's document contract — split fallback
|
|
11
|
+
# on parse failure, nil-document skipping — and swaps only the
|
|
12
|
+
# engine calls.
|
|
13
|
+
class YeptrisAdapter < StandardAdapter
|
|
14
|
+
def self.parse(yamls, _options = {})
|
|
15
|
+
parse_with_stream(yamls)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# The engine require sits outside parse's rescue so a broken
|
|
19
|
+
# install still surfaces its LoadError instead of degrading to
|
|
20
|
+
# the split lane.
|
|
21
|
+
def self.parse_with_stream(yamls)
|
|
22
|
+
require_engine
|
|
23
|
+
require "yeptris/yaml"
|
|
24
|
+
|
|
25
|
+
# rubocop:disable-next Naming/VariableNumber -- upstream schema literal
|
|
26
|
+
results = Yeptris::YAML.load_stream(yamls, schema: :compat_11)
|
|
27
|
+
results.compact
|
|
28
|
+
rescue Yeptris::ParseError => e
|
|
29
|
+
warn "Skipping invalid yaml: #{e.message}"
|
|
30
|
+
parse_with_split(yamls)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.require_engine
|
|
34
|
+
require "yeptris"
|
|
35
|
+
end
|
|
36
|
+
private_class_method :require_engine
|
|
37
|
+
|
|
38
|
+
# Same probe contract as the key-value lane's adapter: true only
|
|
39
|
+
# when the native engine loads AND answers a stream parse, so
|
|
40
|
+
# half-initialized installs gate to the standard lane instead of
|
|
41
|
+
# committing and failing mid-load.
|
|
42
|
+
def self.available?
|
|
43
|
+
require_engine
|
|
44
|
+
require "yeptris/yaml"
|
|
45
|
+
# rubocop:disable-next Naming/VariableNumber -- upstream schema literal
|
|
46
|
+
::Yeptris::YAML.load_stream("---\nprobe: 1\n", schema: :compat_11)
|
|
47
|
+
true
|
|
48
|
+
rescue LoadError, StandardError
|
|
49
|
+
false
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/lutaml/yamls/adapter.rb
CHANGED
|
@@ -10,6 +10,7 @@ module Lutaml
|
|
|
10
10
|
autoload :YamlsSequence, "#{__dir__}/adapter/yamls_sequence"
|
|
11
11
|
autoload :YamlsSequenceRule, "#{__dir__}/adapter/yamls_sequence_rule"
|
|
12
12
|
autoload :StandardAdapter, "#{__dir__}/adapter/standard_adapter"
|
|
13
|
+
autoload :YeptrisAdapter, "#{__dir__}/adapter/yeptris_adapter"
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Yamls
|
|
5
|
+
# Adapter loader for the YAMLS stream format.
|
|
6
|
+
#
|
|
7
|
+
# YAMLS adapters live in lutaml/yamls/adapter/, not the default
|
|
8
|
+
# lutaml/key_value/adapter/<format>/ layout, so registration carries
|
|
9
|
+
# this loader for AdapterResolver's file loading and class resolution.
|
|
10
|
+
module AdapterLoader
|
|
11
|
+
# Load the YAMLS adapter file
|
|
12
|
+
#
|
|
13
|
+
# @param _adapter [String] the adapter format name ("yamls")
|
|
14
|
+
# @param type [String] the normalized type name (e.g., "yeptris_adapter")
|
|
15
|
+
def self.load_adapter_file(_adapter, type)
|
|
16
|
+
adapter_path = if Lutaml::Model.opal?
|
|
17
|
+
"lutaml/yamls/adapter/#{type}"
|
|
18
|
+
else
|
|
19
|
+
File.join(File.dirname(__FILE__), "adapter", type)
|
|
20
|
+
end
|
|
21
|
+
require adapter_path
|
|
22
|
+
rescue LoadError => e
|
|
23
|
+
raise Lutaml::Model::UnknownAdapterTypeError.new("yamls", type),
|
|
24
|
+
cause: e
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# YAMLS is not an XML format; the resolver calls this on every
|
|
28
|
+
# registered loader, so it is a no-op here.
|
|
29
|
+
def self.load_moxml_adapter(_type_name, _adapter_name); end
|
|
30
|
+
|
|
31
|
+
# Resolve the adapter class for YAMLS
|
|
32
|
+
#
|
|
33
|
+
# @param _adapter [String] the adapter format name ("yamls")
|
|
34
|
+
# @param type [String] the normalized type name (e.g., "yeptris_adapter")
|
|
35
|
+
# @return [Class] the adapter class
|
|
36
|
+
def self.class_for(_adapter, type)
|
|
37
|
+
Lutaml::Yamls::Adapter.const_get(to_class_name(type))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Convert string to class name
|
|
41
|
+
#
|
|
42
|
+
# @param str [String] the string to convert
|
|
43
|
+
# @return [String] the class name
|
|
44
|
+
def self.to_class_name(str)
|
|
45
|
+
str.to_s.split("_").map(&:capitalize).join
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/lutaml/yamls/format.rb
CHANGED
|
@@ -10,6 +10,7 @@ module Lutaml
|
|
|
10
10
|
class Error < StandardError; end
|
|
11
11
|
|
|
12
12
|
autoload :Adapter, "#{__dir__}/adapter"
|
|
13
|
+
autoload :AdapterLoader, "#{__dir__}/adapter_loader"
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
|
|
@@ -19,4 +20,9 @@ Lutaml::Model::FormatRegistry.register(
|
|
|
19
20
|
adapter_class: Lutaml::Yamls::Adapter::StandardAdapter,
|
|
20
21
|
transformer: Lutaml::Yamls::Adapter::Transform,
|
|
21
22
|
key_value: true,
|
|
23
|
+
adapter_loader: Lutaml::Yamls::AdapterLoader,
|
|
24
|
+
adapter_options: {
|
|
25
|
+
available: %i[standard yeptris],
|
|
26
|
+
default: :standard,
|
|
27
|
+
},
|
|
22
28
|
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#1115: the yeptris opt-in is consumer-neutral
|
|
6
|
+
# (LUTAML_YAML; FONTIST_YAML stays honored as the legacy spelling), and
|
|
7
|
+
# a bundle containing yeptris without the opt-in sees a one-time
|
|
8
|
+
# warning naming the switch — the gated engine is visible, not silent.
|
|
9
|
+
RSpec.describe "yeptris engine opt-in switch" do
|
|
10
|
+
around do |example|
|
|
11
|
+
old = ENV.to_h.slice("LUTAML_YAML", "FONTIST_YAML")
|
|
12
|
+
ENV.delete("LUTAML_YAML")
|
|
13
|
+
ENV.delete("FONTIST_YAML")
|
|
14
|
+
example.run
|
|
15
|
+
old.each { |k, v| ENV[k] = v }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "selects yeptris with LUTAML_YAML=yeptris" do
|
|
19
|
+
skip "yeptris engine not available on this platform" unless
|
|
20
|
+
Lutaml::Model::AdapterResolver.send(:yeptris_opted_in?)
|
|
21
|
+
|
|
22
|
+
expect(Lutaml::Model::Config.adapter_for(:yaml))
|
|
23
|
+
.to be(Lutaml::Yaml::Adapter::YeptrisAdapter)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "honors the legacy FONTIST_YAML spelling" do
|
|
27
|
+
expect(Lutaml::Model::AdapterResolver.send(:yeptris_opted_in?)).to be(false)
|
|
28
|
+
|
|
29
|
+
ENV["FONTIST_YAML"] = "yeptris"
|
|
30
|
+
expect(Lutaml::Model::AdapterResolver.send(:yeptris_opted_in?)).to be(true)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "selects yeptris with FONTIST_YAML=yeptris" do
|
|
34
|
+
skip "yeptris engine not available on this platform" if
|
|
35
|
+
RUBY_ENGINE == "opal"
|
|
36
|
+
|
|
37
|
+
ENV["FONTIST_YAML"] = "yeptris"
|
|
38
|
+
expect(Lutaml::Model::Config.adapter_for(:yaml)).not_to be_nil
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#1114: a hash-valued entry in a string-collection
|
|
6
|
+
# attribute materialized as a Type::String wrapper holding the JSON
|
|
7
|
+
# text (data loss). Builtin scalars now keep structured data verbatim
|
|
8
|
+
# on parse and emit it verbatim on serialize; custom Value subclasses
|
|
9
|
+
# keep the wrapper/shaping contract.
|
|
10
|
+
module JsonHashCollectionSpec
|
|
11
|
+
class Probe < Lutaml::Model::Serializable
|
|
12
|
+
attribute :name, :string
|
|
13
|
+
attribute :files, :string, collection: true
|
|
14
|
+
|
|
15
|
+
key_value do
|
|
16
|
+
map "name", to: :name
|
|
17
|
+
map "files", to: :files
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
RSpec.describe "hash-valued entries on string collections (#1114)" do
|
|
23
|
+
let(:data) do
|
|
24
|
+
{ "name" => "Roboto", "files" => { "regular" => "Roboto-Regular.ttf" } }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "keeps the hash structure on parse" do
|
|
28
|
+
model = JsonHashCollectionSpec::Probe.from_json(JSON.dump(data))
|
|
29
|
+
expect(model.files).to eq([{ "regular" => "Roboto-Regular.ttf" }])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "round-trips the hash through to_json" do
|
|
33
|
+
model = JsonHashCollectionSpec::Probe.from_json(JSON.dump(data))
|
|
34
|
+
expect(JSON.parse(model.to_json)["files"])
|
|
35
|
+
.to eq([{ "regular" => "Roboto-Regular.ttf" }])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#1122: the per-register flattened-mapping memo (round 7)
|
|
6
|
+
# froze the rule list before a second DSL block (a mixin-installed
|
|
7
|
+
# key_value combined with an in-class one) added its rules — the
|
|
8
|
+
# InternetDraft "version" rule vanished from to_hash. Every DSL and
|
|
9
|
+
# import mutation point now invalidates the memo.
|
|
10
|
+
module KvFlattenMemoSpec
|
|
11
|
+
module Serialization
|
|
12
|
+
def self.included(base)
|
|
13
|
+
base.key_value do
|
|
14
|
+
map "_type", to: :type
|
|
15
|
+
map "number", to: :number
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Draft < Lutaml::Model::Serializable
|
|
21
|
+
include Serialization
|
|
22
|
+
|
|
23
|
+
attribute :type, :string
|
|
24
|
+
attribute :number, :string
|
|
25
|
+
attribute :version, :string
|
|
26
|
+
|
|
27
|
+
key_value do
|
|
28
|
+
map "version", to: :version
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
RSpec.describe "KV flatten memo vs late DSL blocks (#1122)" do
|
|
34
|
+
it "keeps rules added by a later key_value block" do
|
|
35
|
+
model = KvFlattenMemoSpec::Draft.new(
|
|
36
|
+
type: "internet_draft", number: "draft-ietf-quic-transport",
|
|
37
|
+
version: "34"
|
|
38
|
+
)
|
|
39
|
+
h = model.to_hash
|
|
40
|
+
expect(h["version"]).to eq("34")
|
|
41
|
+
expect(h["number"]).to eq("draft-ietf-quic-transport")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "keeps the memo effective for stable rule sets" do
|
|
45
|
+
model = KvFlattenMemoSpec::Draft.new(number: "x", version: "1")
|
|
46
|
+
first = model.to_hash
|
|
47
|
+
expect(model.to_hash).to eq(first)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "lutaml/yamls/adapter/yeptris_adapter"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Lutaml::Yamls::Adapter::YeptrisAdapter, if: Lutaml::Yamls::Adapter::YeptrisAdapter.available? do
|
|
7
|
+
let(:valid_yamls_content) do
|
|
8
|
+
<<~YAMLS
|
|
9
|
+
name: John
|
|
10
|
+
age: 30
|
|
11
|
+
---
|
|
12
|
+
name: Jane
|
|
13
|
+
age: 25
|
|
14
|
+
---
|
|
15
|
+
name: Bob
|
|
16
|
+
age: 35
|
|
17
|
+
YAMLS
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
let(:invalid_yamls_content) do
|
|
21
|
+
<<~YAMLS
|
|
22
|
+
name: John
|
|
23
|
+
age: 30
|
|
24
|
+
---
|
|
25
|
+
invalid yaml: [
|
|
26
|
+
---
|
|
27
|
+
name: Bob
|
|
28
|
+
age: 35
|
|
29
|
+
YAMLS
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
let(:yamls_with_empty_docs) do
|
|
33
|
+
<<~YAMLS
|
|
34
|
+
name: John
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
name: Jane
|
|
39
|
+
YAMLS
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe ".parse" do
|
|
43
|
+
it "parses each YAML document as a separate object" do
|
|
44
|
+
results = described_class.parse(valid_yamls_content)
|
|
45
|
+
expect(results).to be_an(Array)
|
|
46
|
+
expect(results.length).to eq(3)
|
|
47
|
+
expect(results.first).to eq({ "name" => "John", "age" => 30 })
|
|
48
|
+
expect(results.last).to eq({ "name" => "Bob", "age" => 35 })
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "degrades to the split lane on invalid documents" do
|
|
52
|
+
results = described_class.parse(invalid_yamls_content)
|
|
53
|
+
expect(results).to be_an(Array)
|
|
54
|
+
expect(results.length).to eq(2)
|
|
55
|
+
expect(results.first).to eq({ "name" => "John", "age" => 30 })
|
|
56
|
+
expect(results.last).to eq({ "name" => "Bob", "age" => 35 })
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "skips empty documents" do
|
|
60
|
+
results = described_class.parse(yamls_with_empty_docs)
|
|
61
|
+
expect(results).to be_an(Array)
|
|
62
|
+
expect(results.length).to eq(2)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "parses a single document" do
|
|
66
|
+
results = described_class.parse("name: John\nage: 30\n")
|
|
67
|
+
expect(results).to eq([{ "name" => "John", "age" => 30 }])
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# leptris#1941: namespaced trees must emit through the native ops
|
|
4
|
+
# lane byte-identically to the DOM lane. The engine's ops builder
|
|
5
|
+
# copies each row's ns binding onto the built values and the plan
|
|
6
|
+
# serializer collects (prefix, uri) declarations from the result
|
|
7
|
+
# tree itself — so the lane's namespace-less restriction was a
|
|
8
|
+
# Ruby-side gate, not an engine limit.
|
|
9
|
+
|
|
10
|
+
require "lutaml/model"
|
|
11
|
+
require "lutaml/xml/leptris"
|
|
12
|
+
require "leptris/xml/ffi"
|
|
13
|
+
|
|
14
|
+
RSpec.describe Lutaml::Xml::Leptris::NativeEmission do
|
|
15
|
+
let(:ex_namespace) do
|
|
16
|
+
Class.new(Lutaml::Xml::W3c::XmlNamespace) do
|
|
17
|
+
uri "http://example.com/ns"
|
|
18
|
+
prefix_default "ex"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
let(:model_class) do
|
|
23
|
+
ns = ex_namespace
|
|
24
|
+
Class.new do
|
|
25
|
+
include Lutaml::Model::Serialize
|
|
26
|
+
|
|
27
|
+
attribute :id, :string
|
|
28
|
+
attribute :value, :string
|
|
29
|
+
|
|
30
|
+
xml do
|
|
31
|
+
namespace ns
|
|
32
|
+
element "element"
|
|
33
|
+
map_element "id", to: :id
|
|
34
|
+
map_element "value", to: :value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.name
|
|
38
|
+
"NsEmissionModel"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
let(:instance) { model_class.new(id: "7", value: "hello") }
|
|
44
|
+
let(:register) { Lutaml::Model::Config.default_register }
|
|
45
|
+
let(:plan) { Lutaml::Xml::Leptris::PlanCompiler.compile(model_class, register) }
|
|
46
|
+
|
|
47
|
+
it "emits a namespaced tree byte-identically to the DOM lane" do
|
|
48
|
+
native = described_class.emit(instance, plan, register)
|
|
49
|
+
dom = Lutaml::Xml::Leptris::PlanSerializer.call(instance, plan, register)
|
|
50
|
+
expect(native).to eq(dom)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "accepts namespaced trees in the compatibility gate" do
|
|
54
|
+
expect(described_class.compatible?(plan)).to be(true)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# leptris#1941 ordered slice: parsed ordered models — the uniword
|
|
4
|
+
# shape (element-only roots, nested ordered paragraphs, mixed-content
|
|
5
|
+
# runs) — emit through the native ops lane byte-identically to the
|
|
6
|
+
# interpretive writer. The DOM lane mints one wrapper per element
|
|
7
|
+
# (create_element + Class#new ≈ 14% of serialize CPU plus its GC
|
|
8
|
+
# share); the ops lane pushes rows and lets the engine build.
|
|
9
|
+
|
|
10
|
+
require "lutaml/model"
|
|
11
|
+
require "lutaml/xml/leptris"
|
|
12
|
+
|
|
13
|
+
RSpec.describe Lutaml::Xml::Leptris::NativeEmission do
|
|
14
|
+
let(:w_ns) do
|
|
15
|
+
Class.new(Lutaml::Xml::Namespace) do
|
|
16
|
+
uri "http://example.com/ordered/wml"
|
|
17
|
+
prefix_default "w"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
let(:t_class) do
|
|
22
|
+
ns = w_ns
|
|
23
|
+
stub_const("OrderedNs::WmlNs", ns)
|
|
24
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
25
|
+
attribute :value, :string
|
|
26
|
+
|
|
27
|
+
xml do
|
|
28
|
+
namespace ns
|
|
29
|
+
element "t"
|
|
30
|
+
map_content to: :value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
stub_const("OrderedNs::T", klass)
|
|
34
|
+
klass
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
let(:run_class) do
|
|
38
|
+
t_class
|
|
39
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
40
|
+
attribute :bold, :boolean
|
|
41
|
+
attribute :ts, OrderedNs::T, collection: true
|
|
42
|
+
|
|
43
|
+
xml do
|
|
44
|
+
namespace OrderedNs::WmlNs
|
|
45
|
+
ordered
|
|
46
|
+
element "r"
|
|
47
|
+
map_attribute "bold", to: :bold
|
|
48
|
+
map_element "t", to: :ts
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
stub_const("OrderedNs::Run", klass)
|
|
52
|
+
klass
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
let(:para_class) do
|
|
56
|
+
run_class
|
|
57
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
58
|
+
attribute :style, :string
|
|
59
|
+
attribute :runs, OrderedNs::Run, collection: true
|
|
60
|
+
|
|
61
|
+
xml do
|
|
62
|
+
namespace OrderedNs::WmlNs
|
|
63
|
+
ordered
|
|
64
|
+
element "p"
|
|
65
|
+
map_attribute "style", to: :style
|
|
66
|
+
map_element "r", to: :runs
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
stub_const("OrderedNs::Para", klass)
|
|
70
|
+
klass
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
let(:doc_class) do
|
|
74
|
+
para_class
|
|
75
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
76
|
+
attribute :paras, OrderedNs::Para, collection: true
|
|
77
|
+
|
|
78
|
+
xml do
|
|
79
|
+
namespace OrderedNs::WmlNs
|
|
80
|
+
ordered
|
|
81
|
+
element "document"
|
|
82
|
+
map_element "p", to: :paras
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
stub_const("OrderedNs::Document", klass)
|
|
86
|
+
klass
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
let(:source) do
|
|
90
|
+
<<~XML
|
|
91
|
+
<w:document xmlns:w="http://example.com/ordered/wml">
|
|
92
|
+
<w:p style="Heading1">
|
|
93
|
+
<w:r><w:t>first run</w:t></w:r>
|
|
94
|
+
<w:r w:bold="true"><w:t>second</w:t></w:r>
|
|
95
|
+
</w:p>
|
|
96
|
+
<w:p>
|
|
97
|
+
<w:r><w:t>plain</w:t></w:r>
|
|
98
|
+
</w:p>
|
|
99
|
+
</w:document>
|
|
100
|
+
XML
|
|
101
|
+
end
|
|
102
|
+
let(:register) { Lutaml::Model::Config.default_register }
|
|
103
|
+
let(:instance) { doc_class.from_xml(source) }
|
|
104
|
+
let(:plan) do
|
|
105
|
+
Lutaml::Xml::Leptris::PlanCompiler.compile(doc_class, register)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
around do |example|
|
|
109
|
+
Lutaml::Model::Config.with_adapter(xml: :leptris) { example.run }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "admits parsed ordered instances in the compatibility gate" do
|
|
113
|
+
expect(described_class.compatible?(plan, instance, register)).to be(true)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "emits ordered parsed instances byte-identically to the interpretive writer" do
|
|
117
|
+
_p = plan
|
|
118
|
+
_i = instance
|
|
119
|
+
Lutaml::Xml::Leptris::PlanCompiler.compile(OrderedNs::Para, register)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
native = described_class.emit(instance, plan, register)
|
|
127
|
+
|
|
128
|
+
interpretive = Lutaml::Model::Config.with_adapter(xml: :nokogiri) do
|
|
129
|
+
instance.to_xml
|
|
130
|
+
end
|
|
131
|
+
expect(native).to eq(interpretive)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "round-trips the emitted document" do
|
|
135
|
+
native = described_class.emit(instance, plan, register)
|
|
136
|
+
reparsed = doc_class.from_xml(native)
|
|
137
|
+
expect(reparsed.paras.size).to eq(2)
|
|
138
|
+
expect(reparsed.paras[0].runs.map { |r| r.ts.map(&:value) }).to eq(
|
|
139
|
+
[["first run"], ["second"]],
|
|
140
|
+
)
|
|
141
|
+
expect(reparsed.paras[0].runs[1].bold).to be(true)
|
|
142
|
+
expect(reparsed.paras[1].runs.first.ts.first.value).to eq("plain")
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# leptris#1941 consumer-gap law: the RAW-splice capability rides
|
|
4
|
+
# engine 1.9.406.0 (PLAN_OP_RAW + row identity). A bundle resolving
|
|
5
|
+
# an OLDER leptris gem — e.g. the metanorma consumer matrix pinned to
|
|
6
|
+
# 1.9.405.0 — must take the DOM lane, not the ops lane: splicing
|
|
7
|
+
# :raw without the engine constant emitted EMPTY fragments and the
|
|
8
|
+
# round-trip parse died on "empty input". The gate probes the FFI
|
|
9
|
+
# constant, so capability tracks the loaded gem, not a version
|
|
10
|
+
# table that drifts.
|
|
11
|
+
RSpec.describe Lutaml::Xml::Leptris::NativeEmission, ".raw_op_supported?" do
|
|
12
|
+
it "is false for an FFI surface without the RAW op" do
|
|
13
|
+
plain = Class.new
|
|
14
|
+
expect(described_class.raw_op_supported?(plain)).to be(false)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "is true when PLAN_OP_RAW is defined" do
|
|
18
|
+
with_raw = Class.new
|
|
19
|
+
with_raw.const_set(:PLAN_OP_RAW, 4)
|
|
20
|
+
expect(described_class.raw_op_supported?(with_raw)).to be(true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "probes the loaded gem by default (harness runs 1.9.406.0)" do
|
|
24
|
+
expect(described_class.raw_op_supported?).to be(true)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -230,7 +230,14 @@ RSpec.describe "XML plan fast path: (URI, local) dispatch and W3C xml:* attribut
|
|
|
230
230
|
mutated = settings_class.from_xml(source)
|
|
231
231
|
mutated.w14_doc_id = w14_doc_id_class.new(val: "{A}")
|
|
232
232
|
output = mutated.to_xml
|
|
233
|
-
|
|
233
|
+
# leptris#1941: writer-added namespaced children now ride the
|
|
234
|
+
# native emission lane, which spells them with the model's
|
|
235
|
+
# declared prefix — the DOM lane DROPPED the w14 namespace
|
|
236
|
+
# entirely here (bare docId/val, no declaration). Both the
|
|
237
|
+
# prefix form and the interpretive's default-ns form are
|
|
238
|
+
# valid spellings of the same namespace; the native lane can
|
|
239
|
+
# only express the prefixed form.
|
|
240
|
+
expect(output).to include("<w14:docId")
|
|
234
241
|
expect(output).to include('val="{A}"')
|
|
235
242
|
expect(output.index("zoom")).to be < output.index("docId")
|
|
236
243
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.164
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -185,6 +185,7 @@ files:
|
|
|
185
185
|
- bench/bench_alloc_audit.rb
|
|
186
186
|
- bench/bench_common.rb
|
|
187
187
|
- bench/bench_compare.rb
|
|
188
|
+
- bench/bench_kv_materialization.rb
|
|
188
189
|
- bench/bench_merge_attempts.rb
|
|
189
190
|
- bench/bench_mml.rb
|
|
190
191
|
- bench/bench_niso.rb
|
|
@@ -996,6 +997,8 @@ files:
|
|
|
996
997
|
- lib/lutaml/yamls/adapter/transform.rb
|
|
997
998
|
- lib/lutaml/yamls/adapter/yamls_sequence.rb
|
|
998
999
|
- lib/lutaml/yamls/adapter/yamls_sequence_rule.rb
|
|
1000
|
+
- lib/lutaml/yamls/adapter/yeptris_adapter.rb
|
|
1001
|
+
- lib/lutaml/yamls/adapter_loader.rb
|
|
999
1002
|
- lib/lutaml/yamls/format.rb
|
|
1000
1003
|
- lib/tasks/benchmark_runner.rb
|
|
1001
1004
|
- lib/tasks/memory_profile.rb
|
|
@@ -1737,6 +1740,7 @@ files:
|
|
|
1737
1740
|
- spec/lutaml/key_value/when_attribute_spec.rb
|
|
1738
1741
|
- spec/lutaml/model/absent_value_contracts_spec.rb
|
|
1739
1742
|
- spec/lutaml/model/adapter_resolver_configured_spec.rb
|
|
1743
|
+
- spec/lutaml/model/adapter_resolver_yeptris_switch_spec.rb
|
|
1740
1744
|
- spec/lutaml/model/any_element_mapping_spec.rb
|
|
1741
1745
|
- spec/lutaml/model/attribute_apply_value_map_spec.rb
|
|
1742
1746
|
- spec/lutaml/model/attribute_collection_spec.rb
|
|
@@ -1802,6 +1806,7 @@ files:
|
|
|
1802
1806
|
- spec/lutaml/model/inheritance_spec.rb
|
|
1803
1807
|
- spec/lutaml/model/inherited_state_isolation_spec.rb
|
|
1804
1808
|
- spec/lutaml/model/json_adapter_spec.rb
|
|
1809
|
+
- spec/lutaml/model/json_hash_collection_spec.rb
|
|
1805
1810
|
- spec/lutaml/model/json_spec.rb
|
|
1806
1811
|
- spec/lutaml/model/json_state_nesting_spec.rb
|
|
1807
1812
|
- spec/lutaml/model/jsonl/standard_adapter_spec.rb
|
|
@@ -1809,6 +1814,7 @@ files:
|
|
|
1809
1814
|
- spec/lutaml/model/key_value_accepted_values_spec.rb
|
|
1810
1815
|
- spec/lutaml/model/key_value_data_model/key_value_element_spec.rb
|
|
1811
1816
|
- spec/lutaml/model/key_value_mapping_spec.rb
|
|
1817
|
+
- spec/lutaml/model/kv_flatten_memo_spec.rb
|
|
1812
1818
|
- spec/lutaml/model/late_attribute_declaration_spec.rb
|
|
1813
1819
|
- spec/lutaml/model/lazy_collection_spec.rb
|
|
1814
1820
|
- spec/lutaml/model/liquefiable_lazy_spec.rb
|
|
@@ -1946,6 +1952,7 @@ files:
|
|
|
1946
1952
|
- spec/lutaml/model/yaml_adapter_spec.rb
|
|
1947
1953
|
- spec/lutaml/model/yaml_stream_spec.rb
|
|
1948
1954
|
- spec/lutaml/model/yamls/standard_adapter_spec.rb
|
|
1955
|
+
- spec/lutaml/model/yamls/yeptris_adapter_spec.rb
|
|
1949
1956
|
- spec/lutaml/model/yamls_range_spec.rb
|
|
1950
1957
|
- spec/lutaml/model/yamls_sequence_spec.rb
|
|
1951
1958
|
- spec/lutaml/model/yamls_spec.rb
|
|
@@ -2010,6 +2017,9 @@ files:
|
|
|
2010
2017
|
- spec/lutaml/xml/general_namespace_spec.rb
|
|
2011
2018
|
- spec/lutaml/xml/html_entities_spec.rb
|
|
2012
2019
|
- spec/lutaml/xml/indent_spec.rb
|
|
2020
|
+
- spec/lutaml/xml/leptris/native_emission_ns_parity_spec.rb
|
|
2021
|
+
- spec/lutaml/xml/leptris/native_emission_ordered_spec.rb
|
|
2022
|
+
- spec/lutaml/xml/leptris/native_emission_raw_gate_spec.rb
|
|
2013
2023
|
- spec/lutaml/xml/leptris/plan_hydrator_ns_snapshot_spec.rb
|
|
2014
2024
|
- spec/lutaml/xml/leptris_string_encoding_spec.rb
|
|
2015
2025
|
- spec/lutaml/xml/line_ending_spec.rb
|