lutaml-model 0.8.161 → 0.8.163
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 +13 -2
- data/lib/lutaml/key_value/transform.rb +13 -8
- data/lib/lutaml/key_value/transformation.rb +10 -2
- data/lib/lutaml/model/adapter_resolver.rb +21 -9
- 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 +10 -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/yamls/yeptris_adapter_spec.rb +70 -0
- data/spec/lutaml/model/yeptris_error_parity_spec.rb +1 -1
- data/spec/lutaml/model/yeptris_native_detection_spec.rb +6 -2
- data/spec/lutaml/xml/leptris/native_emission_ns_parity_spec.rb +56 -0
- data/spec/lutaml/xml/leptris/native_emission_ordered_spec.rb +145 -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 +9 -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,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
|
|
@@ -24,7 +24,7 @@ RSpec.describe "yeptris adapter error parity" do
|
|
|
24
24
|
nil
|
|
25
25
|
end
|
|
26
26
|
args = libs.flat_map { |l| ["-I", l] } + ["-e", probe]
|
|
27
|
-
Open3.capture2e(Gem.ruby, *args).first
|
|
27
|
+
Open3.capture2e({ "FONTIST_YAML" => "yeptris" }, Gem.ruby, *args).first
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def yeptris_installed?
|
|
@@ -47,7 +47,9 @@ RSpec.describe Lutaml::Model::AdapterResolver, ".adapter_for yeptris native dete
|
|
|
47
47
|
it "resolves the yeptris lane when the native engine answers a probe" do
|
|
48
48
|
skip "optional yeptris engine not resolvable outside the bundle" unless subprocess_yeptris_capable?
|
|
49
49
|
|
|
50
|
-
stdout, stderr, status = Open3.capture3(
|
|
50
|
+
stdout, stderr, status = Open3.capture3({ "FONTIST_YAML" => "yeptris" },
|
|
51
|
+
RbConfig.ruby, "-I", "lib", "-e",
|
|
52
|
+
parse_probe)
|
|
51
53
|
expect(status).to be_success, stderr
|
|
52
54
|
expect(stdout).to include("ADAPTER=YeptrisAdapter")
|
|
53
55
|
expect(stdout).to include("PARSED=scalar")
|
|
@@ -69,7 +71,9 @@ RSpec.describe Lutaml::Model::AdapterResolver, ".adapter_for yeptris native dete
|
|
|
69
71
|
#{parse_probe}
|
|
70
72
|
RUBY
|
|
71
73
|
|
|
72
|
-
stdout, stderr, status = Open3.capture3(
|
|
74
|
+
stdout, stderr, status = Open3.capture3({ "FONTIST_YAML" => "yeptris" },
|
|
75
|
+
RbConfig.ruby, "-I", "lib", "-e",
|
|
76
|
+
poison)
|
|
73
77
|
expect(status).to be_success, stderr
|
|
74
78
|
expect(stdout).to include("ADAPTER=StandardAdapter")
|
|
75
79
|
expect(stdout).to include("PARSED=scalar")
|
|
@@ -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,145 @@
|
|
|
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
|
+
|
|
103
|
+
around do |example|
|
|
104
|
+
Lutaml::Model::Config.with_adapter(xml: :leptris) { example.run }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
let(:register) { Lutaml::Model::Config.default_register }
|
|
108
|
+
let(:instance) { doc_class.from_xml(source) }
|
|
109
|
+
let(:plan) do
|
|
110
|
+
Lutaml::Xml::Leptris::PlanCompiler.compile(doc_class, register)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "admits parsed ordered instances in the compatibility gate" do
|
|
114
|
+
expect(described_class.compatible?(plan, instance, register)).to be(true)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "emits ordered parsed instances byte-identically to the interpretive writer" do
|
|
118
|
+
_p = plan
|
|
119
|
+
_i = instance
|
|
120
|
+
para_plan = Lutaml::Xml::Leptris::PlanCompiler.compile(OrderedNs::Para, register)
|
|
121
|
+
puts "DEBUG para_tree_attrs=#{para_plan[:tree][:attributes].inspect}"
|
|
122
|
+
puts "DEBUG para_attr_rows=#{para_plan[:attr_rows].inspect}"
|
|
123
|
+
puts "DEBUG doc_plan_rows=#{plan[:rows].map { |r| [r[0].name, r[2]] }.inspect} doc_attr_rows=#{plan[:attr_rows].inspect}"
|
|
124
|
+
puts "DEBUG para_rows=#{para_plan[:rows].map { |r| [r[0].name, r[2]] }.inspect}"
|
|
125
|
+
puts "DEBUG doc_order=#{instance.element_order.map { |o| [o.type, o.name, o.node_type] }.inspect}"
|
|
126
|
+
puts "DEBUG paras=#{instance.paras.map { |x| [x.object_id, x.style] }.inspect} runs=#{instance.paras[0].runs.map { |r| [r.object_id, r.bold, r.ts.map(&:value)] }.inspect}"
|
|
127
|
+
native = described_class.emit(instance, plan, register)
|
|
128
|
+
puts "DEBUG after-emit paras=#{instance.paras.map { |x| [x.object_id, x.style] }.inspect}"
|
|
129
|
+
interpretive = Lutaml::Model::Config.with_adapter(xml: :nokogiri) do
|
|
130
|
+
instance.to_xml
|
|
131
|
+
end
|
|
132
|
+
expect(native).to eq(interpretive)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "round-trips the emitted document" do
|
|
136
|
+
native = described_class.emit(instance, plan, register)
|
|
137
|
+
reparsed = doc_class.from_xml(native)
|
|
138
|
+
expect(reparsed.paras.size).to eq(2)
|
|
139
|
+
expect(reparsed.paras[0].runs.map { |r| r.ts.map(&:value) }).to eq(
|
|
140
|
+
[["first run"], ["second"]],
|
|
141
|
+
)
|
|
142
|
+
expect(reparsed.paras[0].runs[1].bold).to be(true)
|
|
143
|
+
expect(reparsed.paras[1].runs.first.ts.first.value).to eq("plain")
|
|
144
|
+
end
|
|
145
|
+
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.163
|
|
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
|
|
@@ -1946,6 +1949,7 @@ files:
|
|
|
1946
1949
|
- spec/lutaml/model/yaml_adapter_spec.rb
|
|
1947
1950
|
- spec/lutaml/model/yaml_stream_spec.rb
|
|
1948
1951
|
- spec/lutaml/model/yamls/standard_adapter_spec.rb
|
|
1952
|
+
- spec/lutaml/model/yamls/yeptris_adapter_spec.rb
|
|
1949
1953
|
- spec/lutaml/model/yamls_range_spec.rb
|
|
1950
1954
|
- spec/lutaml/model/yamls_sequence_spec.rb
|
|
1951
1955
|
- spec/lutaml/model/yamls_spec.rb
|
|
@@ -2010,6 +2014,9 @@ files:
|
|
|
2010
2014
|
- spec/lutaml/xml/general_namespace_spec.rb
|
|
2011
2015
|
- spec/lutaml/xml/html_entities_spec.rb
|
|
2012
2016
|
- spec/lutaml/xml/indent_spec.rb
|
|
2017
|
+
- spec/lutaml/xml/leptris/native_emission_ns_parity_spec.rb
|
|
2018
|
+
- spec/lutaml/xml/leptris/native_emission_ordered_spec.rb
|
|
2019
|
+
- spec/lutaml/xml/leptris/native_emission_raw_gate_spec.rb
|
|
2013
2020
|
- spec/lutaml/xml/leptris/plan_hydrator_ns_snapshot_spec.rb
|
|
2014
2021
|
- spec/lutaml/xml/leptris_string_encoding_spec.rb
|
|
2015
2022
|
- spec/lutaml/xml/line_ending_spec.rb
|