teptris 0.2.26-aarch64-linux → 0.2.30-aarch64-linux
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/lib/teptris/descriptor.rb +70 -0
- data/lib/teptris/toml.rb +9 -6
- data/lib/teptris/version.rb +1 -1
- data/lib/teptris.rb +1 -0
- data/lib/teptris_ext.so +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '059989b3fe2865a88701cd0f3fa6017e6a7d1858d9f1f4acb92b775a6678002b'
|
|
4
|
+
data.tar.gz: 83c5727792a555111b7e9d8fe48d3250022b5b8fed521930973f57b4c60f5add
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bc284eabb37a3f900fae5acb85f4ab84e7400d28bc2bfc1088cd3744026c310dfc2feba6bcb547ad285976897ea3109f2323bf14b5f94683f217a0c3c4300ba
|
|
7
|
+
data.tar.gz: 8e3395e4e6543dea2d6dd0409bd8caa4768bad3a8c21298874b5c2e5f3f17ae6a616e7737cf32ea28aee4a8c34e4996b35d5f399dd5d9c927c14bb0af64a1e95
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Tree-shaped schema-descriptor materialization (teptris#46, mirroring
|
|
4
|
+
# leptris v1): compile a plan tree once, then materialize a whole TOML
|
|
5
|
+
# subtree against it in ONE native pass — unplanned keys are never
|
|
6
|
+
# materialized.
|
|
7
|
+
#
|
|
8
|
+
# descriptor = Teptris::Descriptor.build(
|
|
9
|
+
# children: [
|
|
10
|
+
# { name: "name", kind: :scalar },
|
|
11
|
+
# { name: "port", kind: :scalar },
|
|
12
|
+
# { name: "hosts", kind: :collection },
|
|
13
|
+
# { name: "items", kind: :nested, plan: {
|
|
14
|
+
# children: [{ name: "id", kind: :scalar }] } },
|
|
15
|
+
# { name: "everything_else", kind: :raw },
|
|
16
|
+
# ])
|
|
17
|
+
# descriptor.walk(toml_string) # => { "name" => "svc", ... }
|
|
18
|
+
#
|
|
19
|
+
# Row kinds: :scalar (any TOML value), :collection (array of scalars),
|
|
20
|
+
# :nested (recurse via +plan:+; also spans arrays of tables), :raw
|
|
21
|
+
# (the untouched native subtree). Rows absent from the document read
|
|
22
|
+
# as nil.
|
|
23
|
+
class Teptris::Descriptor
|
|
24
|
+
KINDS = { scalar: 1, collection: 2, nested: 3, raw: 4 }.freeze
|
|
25
|
+
private_constant :KINDS
|
|
26
|
+
|
|
27
|
+
attr_reader :rows, :first_row
|
|
28
|
+
|
|
29
|
+
def self.build(tree)
|
|
30
|
+
# Pre-order plan numbering (root = plan 0) with each plan's rows
|
|
31
|
+
# assigned a DISJOINT reserved range. Interleaved appending leaks
|
|
32
|
+
# siblings that follow a :nested child into the sub-plan's range —
|
|
33
|
+
# the 0.2.29 bug (every array-of-tables element grew stray nil
|
|
34
|
+
# rows).
|
|
35
|
+
plans = []
|
|
36
|
+
index_of = {}
|
|
37
|
+
collect = lambda do |t|
|
|
38
|
+
unless index_of.key?(t.object_id)
|
|
39
|
+
index_of[t.object_id] = plans.length
|
|
40
|
+
plans << t
|
|
41
|
+
end
|
|
42
|
+
(t[:children] || []).each do |ch|
|
|
43
|
+
collect.call(ch[:plan]) if KINDS.fetch(ch[:kind]) == 3
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
collect.call(tree)
|
|
47
|
+
|
|
48
|
+
first_row = [0]
|
|
49
|
+
plans.each { |t| first_row << first_row[-1] + (t[:children] || []).length }
|
|
50
|
+
rows = Array.new(first_row[-1])
|
|
51
|
+
plans.each_with_index do |t, i|
|
|
52
|
+
(t[:children] || []).each_with_index do |ch, j|
|
|
53
|
+
kind = KINDS.fetch(ch[:kind])
|
|
54
|
+
sub = kind == 3 ? index_of[ch[:plan].object_id] : 0
|
|
55
|
+
rows[first_row[i] + j] = [ch[:name].to_s, kind, sub]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
d = allocate
|
|
60
|
+
d.instance_variable_set(:@rows, rows.freeze)
|
|
61
|
+
d.instance_variable_set(:@first_row, first_row.freeze)
|
|
62
|
+
d.instance_variable_set(:@handle,
|
|
63
|
+
TeptrisExt.plan_build(rows, first_row))
|
|
64
|
+
d.freeze
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def walk(toml)
|
|
68
|
+
TeptrisExt.plan_emit(@handle, toml)
|
|
69
|
+
end
|
|
70
|
+
end
|
data/lib/teptris/toml.rb
CHANGED
|
@@ -36,13 +36,16 @@ module Teptris
|
|
|
36
36
|
TeptrisExt.load(toml, opts)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
#
|
|
40
|
-
#
|
|
39
|
+
# One-pass schema materialization over a compiled
|
|
40
|
+
# Teptris::Descriptor: unplanned keys are never materialized
|
|
41
|
+
# (teptris#46).
|
|
41
42
|
def load_schema(toml, descriptor)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
unless descriptor.is_a?(Teptris::Descriptor)
|
|
44
|
+
raise ArgumentError,
|
|
45
|
+
"descriptor must be a Teptris::Descriptor (use " \
|
|
46
|
+
"Teptris::Descriptor.build), got #{descriptor.class}"
|
|
47
|
+
end
|
|
48
|
+
descriptor.walk(toml)
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
def engine_version
|
data/lib/teptris/version.rb
CHANGED
data/lib/teptris.rb
CHANGED
data/lib/teptris_ext.so
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: teptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.30
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- teptris contributors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: An FFI binding over libteptris, a C11 TOML 1.0 parser/emitter. API shape
|
|
14
14
|
mirrors the tomlib gem.
|
|
@@ -18,6 +18,7 @@ extensions: []
|
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
20
|
- lib/teptris.rb
|
|
21
|
+
- lib/teptris/descriptor.rb
|
|
21
22
|
- lib/teptris/error.rb
|
|
22
23
|
- lib/teptris/toml.rb
|
|
23
24
|
- lib/teptris/version.rb
|