teptris 0.2.55-s390x-linux → 0.3.0.0-s390x-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/ext/teptris_ext/extconf.rb +5 -7
- data/lib/teptris/descriptor.rb +5 -4
- data/lib/teptris/error.rb +2 -0
- data/lib/teptris/toml.rb +146 -144
- data/lib/teptris/version.rb +3 -1
- data/lib/teptris.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 472a1314831be47d2e80ccdddf7a87af51357dac3ac3aa41dd92d649f82975a2
|
|
4
|
+
data.tar.gz: 57bcb65db66177d1469c8c1712dc332b2acb828dd36198994ee7440ef2bf5599
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb8b0005dfd53387d4b7434c7508889a4bb43541c153f63dc4df9ef6f310bb1987c1cc07e26b74a6ae9881968adf36f2ce2c1c39525f78503270e9b3cc06bff1
|
|
7
|
+
data.tar.gz: dce82b767d7b40253aa39ddb5d8cb94a6749650bf59d46a1be9d446f1e7fc3334138ce77ca0e86880d09d7888ac12238f4596e1a72db5ad999b85579799a466e
|
data/ext/teptris_ext/extconf.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "mkmf"
|
|
2
4
|
|
|
3
5
|
# Two modes:
|
|
@@ -34,12 +36,8 @@ end
|
|
|
34
36
|
# On Windows the .so MUST link the ruby DLL import lib — symbols do
|
|
35
37
|
# not resolve at load otherwise.
|
|
36
38
|
win = RUBY_PLATFORM =~ /mingw/
|
|
37
|
-
unless win
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
if RUBY_PLATFORM =~ /darwin/
|
|
41
|
-
$DLDFLAGS << " -Wl,-undefined,dynamic_lookup"
|
|
42
|
-
end
|
|
39
|
+
$LIBS = $LIBS.sub("-lruby", "") unless win
|
|
40
|
+
$DLDFLAGS << " -Wl,-undefined,dynamic_lookup" if RUBY_PLATFORM =~ /darwin/
|
|
43
41
|
if archive_mode
|
|
44
42
|
# Link the whole archive: every teptris symbol lands inside the ext.
|
|
45
43
|
$LDFLAGS << " #{archive}"
|
|
@@ -56,6 +54,6 @@ unless win
|
|
|
56
54
|
makefile.gsub!(/^LIBRUBYARG_SHARED = .*$/, "LIBRUBYARG_SHARED =")
|
|
57
55
|
makefile.gsub!(/^LIBRUBYARG_STATIC = .*$/, "LIBRUBYARG_STATIC =")
|
|
58
56
|
makefile.gsub!(/^LIBRUBY = .*$/, "LIBRUBY =")
|
|
59
|
-
makefile.gsub!(
|
|
57
|
+
makefile.gsub!(%r{(^|\s)\S*libruby[\w./-]*}, "")
|
|
60
58
|
File.write("Makefile", makefile)
|
|
61
59
|
end
|
data/lib/teptris/descriptor.rb
CHANGED
|
@@ -34,11 +34,12 @@ class Teptris::Descriptor
|
|
|
34
34
|
# rows).
|
|
35
35
|
# @type var plans: Array[Hash[Symbol, untyped]]
|
|
36
36
|
plans = []
|
|
37
|
-
# @type var index_of: Hash[
|
|
37
|
+
# @type var index_of: Hash[Object, Integer]
|
|
38
38
|
index_of = {}
|
|
39
|
+
index_of.compare_by_identity
|
|
39
40
|
collect = lambda do |t|
|
|
40
|
-
unless index_of.key?(t
|
|
41
|
-
index_of[t
|
|
41
|
+
unless index_of.key?(t)
|
|
42
|
+
index_of[t] = plans.length
|
|
42
43
|
plans << t
|
|
43
44
|
end
|
|
44
45
|
(t[:children] || []).each do |ch|
|
|
@@ -53,7 +54,7 @@ class Teptris::Descriptor
|
|
|
53
54
|
plans.each_with_index do |t, i|
|
|
54
55
|
(t[:children] || []).each_with_index do |ch, j|
|
|
55
56
|
kind = KINDS.fetch(ch[:kind])
|
|
56
|
-
sub = kind == 3 ? index_of[ch[:plan]
|
|
57
|
+
sub = kind == 3 ? index_of[ch[:plan]] : 0
|
|
57
58
|
rows[first_row[i] + j] = [ch[:name].to_s, kind, sub]
|
|
58
59
|
end
|
|
59
60
|
end
|
data/lib/teptris/error.rb
CHANGED
data/lib/teptris/toml.rb
CHANGED
|
@@ -1,175 +1,177 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "date"
|
|
2
4
|
|
|
3
5
|
require_relative "error"
|
|
4
6
|
|
|
5
7
|
require_relative "version"
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
# API shape mirrors the tomlib gem: load/dump, String keys, and the
|
|
10
|
+
# tomlib datetime contract (Time with zone for offset datetimes, local
|
|
11
|
+
# Time for local datetimes, Date for dates, String "HH:MM:SS" for
|
|
12
|
+
# local times).
|
|
13
|
+
module Teptris::TOML
|
|
14
|
+
class << self
|
|
15
|
+
def load(toml)
|
|
16
|
+
raise ArgumentError, "input must be a String" unless toml.is_a?(String)
|
|
17
|
+
|
|
18
|
+
TeptrisExt.load(toml)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Safe-load shaped entry point for frameworks: permitted_classes
|
|
22
|
+
# restricts datetime materialization (raise when a value would
|
|
23
|
+
# materialize an unpermitted class); datetime_policy :string keeps
|
|
24
|
+
# every datetime kind as its canonical ISO string instead.
|
|
25
|
+
def safe_load(toml, permitted_classes: nil, datetime_policy: :native)
|
|
26
|
+
unless %i[native string].include?(datetime_policy)
|
|
27
|
+
raise ArgumentError, "datetime_policy must be :native or :string"
|
|
18
28
|
end
|
|
19
29
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
unless
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
# @type var opts: Hash[Symbol, untyped]
|
|
29
|
-
opts = {}
|
|
30
|
-
opts[:string_datetimes] = true if datetime_policy == :string
|
|
31
|
-
if permitted_classes && datetime_policy == :native
|
|
32
|
-
permitted = permitted_classes + [:__scalar]
|
|
33
|
-
opts[:forbid_time] = true unless permitted.include?(Time)
|
|
34
|
-
opts[:forbid_date] = true unless permitted.include?(Date)
|
|
35
|
-
end
|
|
36
|
-
load(toml) if opts.empty?
|
|
37
|
-
TeptrisExt.load(toml, opts)
|
|
30
|
+
# @type var opts: Hash[Symbol, untyped]
|
|
31
|
+
opts = {}
|
|
32
|
+
opts[:string_datetimes] = true if datetime_policy == :string
|
|
33
|
+
if permitted_classes && datetime_policy == :native
|
|
34
|
+
permitted = permitted_classes + [:__scalar]
|
|
35
|
+
opts[:forbid_time] = true unless permitted.include?(Time)
|
|
36
|
+
opts[:forbid_date] = true unless permitted.include?(Date)
|
|
38
37
|
end
|
|
38
|
+
load(toml) if opts.empty?
|
|
39
|
+
TeptrisExt.load(toml, opts)
|
|
40
|
+
end
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
# Lazy load: returns a wrapper that parses eagerly (one pass)
|
|
43
|
+
# but materializes host objects only along the paths actually
|
|
44
|
+
# accessed. Same datetime contract as load; to_h/to_a flatten to
|
|
45
|
+
# the eager shape.
|
|
46
|
+
def load_lazy(toml)
|
|
47
|
+
raise ArgumentError, "input must be a String" unless toml.is_a?(String)
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
TeptrisExt.load_lazy(toml)
|
|
50
|
+
end
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
52
|
+
# Many-small batch path (teptris-ruby#108 ask 3): parse N inputs
|
|
53
|
+
# in one C call, share the safe_load/datetime_policy options
|
|
54
|
+
# struct across the batch, return one eager Hash per document.
|
|
55
|
+
# Same datetime contract as load. A failing document raises
|
|
56
|
+
# Teptris::ParseError carrying the first failure's line/column.
|
|
57
|
+
def load_batch(tomls, safe_load: nil, datetime_policy: :native,
|
|
58
|
+
threads: 1)
|
|
59
|
+
_validate_batch!(tomls, safe_load, datetime_policy)
|
|
60
|
+
opts = _safe_load_opts(safe_load, datetime_policy)
|
|
61
|
+
return TeptrisExt.load_batch(tomls, opts) if threads <= 1
|
|
62
|
+
|
|
63
|
+
# threads > 1: slice across Ruby threads. The C parse releases
|
|
64
|
+
# the GVL, so parses overlap; materialization serializes on the
|
|
65
|
+
# GVL. Contiguous slices keep error order deterministic: the
|
|
66
|
+
# lowest-index failure raises after all threads join.
|
|
67
|
+
n = tomls.size
|
|
68
|
+
threads = [threads, n].min
|
|
69
|
+
return TeptrisExt.load_batch(tomls, opts) if threads <= 1
|
|
70
|
+
|
|
71
|
+
# load_slice releases the GVL once per slice (no per-document
|
|
72
|
+
# ping-pong) and shares one key cache across its documents.
|
|
73
|
+
# Repeated objects are dup'd once each HERE: a repeat landing in
|
|
74
|
+
# two slices would double-lock across threads (the slice-level
|
|
75
|
+
# guard cannot see across slices); frozen dup'ing is C-side.
|
|
76
|
+
# compare_by_identity: object-identity keys without the
|
|
77
|
+
# object_id indirection (same dup-once contract, less aliasing)
|
|
78
|
+
# @type var seen: Hash[Object, bool]
|
|
79
|
+
seen = {}
|
|
80
|
+
seen.compare_by_identity
|
|
81
|
+
tomls = tomls.map do |s|
|
|
82
|
+
next s.dup if seen[s]
|
|
83
|
+
|
|
84
|
+
seen[s] = true
|
|
85
|
+
s
|
|
86
|
+
end
|
|
87
|
+
per = (n.to_f / threads).ceil
|
|
88
|
+
results = Array.new(n)
|
|
89
|
+
# @type var first_error: [Integer, untyped]?
|
|
90
|
+
first_error = nil
|
|
91
|
+
mutex = Mutex.new
|
|
92
|
+
threads.times.map do |ti|
|
|
93
|
+
Thread.new(ti) do |i|
|
|
94
|
+
base = i * per
|
|
95
|
+
slice = tomls[base, per] || []
|
|
96
|
+
begin
|
|
97
|
+
loaded = TeptrisExt.load_slice(slice, opts)
|
|
98
|
+
slice.each_with_index { |_, j| results[base + j] = loaded[j] }
|
|
99
|
+
rescue StandardError => e
|
|
100
|
+
mutex.synchronize do
|
|
101
|
+
first_error ||= [base, e]
|
|
96
102
|
end
|
|
97
103
|
end
|
|
98
|
-
end.each(&:join)
|
|
99
|
-
if first_error
|
|
100
|
-
_, err = first_error
|
|
101
|
-
raise err
|
|
102
104
|
end
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
# Array of Lazy wrappers — materialization happens only on access.
|
|
108
|
-
# Same per-doc error semantics as load_lazy (first failure raises).
|
|
109
|
-
def load_lazy_batch(tomls)
|
|
110
|
-
_validate_batch!(tomls, nil, :native)
|
|
111
|
-
TeptrisExt.load_lazy_batch(tomls)
|
|
105
|
+
end.each(&:join)
|
|
106
|
+
if first_error
|
|
107
|
+
_, err = first_error
|
|
108
|
+
raise err
|
|
112
109
|
end
|
|
110
|
+
results
|
|
111
|
+
end
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
# Lazy twin of load_batch: parse N inputs eagerly, hand back an
|
|
114
|
+
# Array of Lazy wrappers — materialization happens only on access.
|
|
115
|
+
# Same per-doc error semantics as load_lazy (first failure raises).
|
|
116
|
+
def load_lazy_batch(tomls)
|
|
117
|
+
_validate_batch!(tomls, nil, :native)
|
|
118
|
+
TeptrisExt.load_lazy_batch(tomls)
|
|
119
|
+
end
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"Teptris::Descriptor.build), got #{descriptor.class}"
|
|
130
|
-
end
|
|
131
|
-
descriptor.walk(toml)
|
|
132
|
-
end
|
|
121
|
+
# Many-small path with file paths: read each file, then call
|
|
122
|
+
# load_batch. Symmetric with load_file's single-doc shape.
|
|
123
|
+
def load_files(paths, safe_load: nil, datetime_policy: :native)
|
|
124
|
+
_validate_batch!(paths, safe_load, datetime_policy, kind: :paths)
|
|
125
|
+
load_batch(paths.map { |p| File.read(p) },
|
|
126
|
+
safe_load: safe_load, datetime_policy: datetime_policy)
|
|
127
|
+
end
|
|
133
128
|
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
# One-pass schema materialization over a compiled
|
|
130
|
+
# Teptris::Descriptor: unplanned keys are never materialized
|
|
131
|
+
# (teptris#46).
|
|
132
|
+
def load_schema(toml, descriptor)
|
|
133
|
+
unless descriptor.is_a?(Teptris::Descriptor)
|
|
134
|
+
raise ArgumentError,
|
|
135
|
+
"descriptor must be a Teptris::Descriptor (use " \
|
|
136
|
+
"Teptris::Descriptor.build), got #{descriptor.class}"
|
|
136
137
|
end
|
|
138
|
+
descriptor.walk(toml)
|
|
139
|
+
end
|
|
137
140
|
|
|
138
|
-
|
|
141
|
+
def engine_version
|
|
142
|
+
TeptrisExt.engine_version
|
|
143
|
+
end
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
def load_file(path)
|
|
146
|
+
load(File.read(path))
|
|
147
|
+
end
|
|
143
148
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
def dump(obj)
|
|
150
|
+
TeptrisExt.dump(obj)
|
|
151
|
+
end
|
|
147
152
|
|
|
148
|
-
|
|
153
|
+
private
|
|
149
154
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if !safe_load.nil? && !safe_load.is_a?(Array) && !safe_load.is_a?(Symbol)
|
|
155
|
-
raise ArgumentError, "safe_load must be nil, an Array, or a Symbol"
|
|
156
|
-
end
|
|
157
|
-
unless %i[native string].include?(datetime_policy)
|
|
158
|
-
raise ArgumentError, "datetime_policy must be :native or :string"
|
|
159
|
-
end
|
|
155
|
+
def _validate_batch!(input, safe_load, datetime_policy, kind: :strings)
|
|
156
|
+
raise ArgumentError, "expected Array of #{kind}, got #{input.class}" unless input.is_a?(Array)
|
|
157
|
+
if !safe_load.nil? && !safe_load.is_a?(Array) && !safe_load.is_a?(Symbol)
|
|
158
|
+
raise ArgumentError, "safe_load must be nil, an Array, or a Symbol"
|
|
160
159
|
end
|
|
160
|
+
return if %i[native string].include?(datetime_policy)
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
opts
|
|
162
|
+
raise ArgumentError, "datetime_policy must be :native or :string"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def _safe_load_opts(safe_load, datetime_policy)
|
|
166
|
+
# @type var opts: Hash[Symbol, untyped]
|
|
167
|
+
opts = {}
|
|
168
|
+
opts[:string_datetimes] = true if datetime_policy == :string
|
|
169
|
+
if safe_load && datetime_policy == :native
|
|
170
|
+
permitted = Array(safe_load) + [:__scalar]
|
|
171
|
+
opts[:forbid_time] = true unless permitted.include?(Time)
|
|
172
|
+
opts[:forbid_date] = true unless permitted.include?(Date)
|
|
172
173
|
end
|
|
174
|
+
opts.empty? ? nil : opts
|
|
173
175
|
end
|
|
174
176
|
end
|
|
175
177
|
end
|
data/lib/teptris/version.rb
CHANGED
data/lib/teptris.rb
CHANGED
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.
|
|
4
|
+
version: 0.3.0.0
|
|
5
5
|
platform: s390x-linux
|
|
6
6
|
authors:
|
|
7
7
|
- teptris contributors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A native C extension over libteptris, a C99 TOML 1.1 parser/emitter.
|
|
14
14
|
API shape mirrors the tomlib gem.
|