teptris 0.2.37-powerpc64le-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 +7 -0
- data/lib/teptris/descriptor.rb +70 -0
- data/lib/teptris/error.rb +13 -0
- data/lib/teptris/toml.rb +66 -0
- data/lib/teptris/version.rb +3 -0
- data/lib/teptris.rb +26 -0
- data/lib/teptris_ext.so +0 -0
- metadata +49 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5617277aeb4c82d25171814c36e159ee170356e3b2e3462669c962c55fe4c622
|
|
4
|
+
data.tar.gz: 6a3ee08acecafa2c8e3f43b3bac07d88aabb5a6cb13e187c637bce954573f0cd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8d3b5e55081b0b88f664ee3073557f8a9314d5fc52136c4812ebc81872d93c5a324d6078dbd29ae6aed6a9759f6a2d36e579f48613d89577900a6bc8381a63d3
|
|
7
|
+
data.tar.gz: 9e0176ca279e306c6c01c94b5547e9a66332bc38837352fbd3bdb832d31119589fb9b374faecfde0a05434520fb35e016490281bb2ba318ff699f57244f8363d
|
|
@@ -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
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require "date"
|
|
2
|
+
|
|
3
|
+
require_relative "error"
|
|
4
|
+
|
|
5
|
+
require_relative "version"
|
|
6
|
+
|
|
7
|
+
module Teptris
|
|
8
|
+
# API shape mirrors the tomlib gem: load/dump, String keys, and the
|
|
9
|
+
# tomlib datetime contract (Time with zone for offset datetimes, local
|
|
10
|
+
# Time for local datetimes, Date for dates, String "HH:MM:SS" for
|
|
11
|
+
# local times).
|
|
12
|
+
module TOML
|
|
13
|
+
class << self
|
|
14
|
+
def load(toml)
|
|
15
|
+
raise ArgumentError, "input must be a String" unless toml.is_a?(String)
|
|
16
|
+
|
|
17
|
+
TeptrisExt.load(toml)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Safe-load shaped entry point for frameworks: permitted_classes
|
|
21
|
+
# restricts datetime materialization (raise when a value would
|
|
22
|
+
# materialize an unpermitted class); datetime_policy :string keeps
|
|
23
|
+
# every datetime kind as its canonical ISO string instead.
|
|
24
|
+
def safe_load(toml, permitted_classes: nil, datetime_policy: :native)
|
|
25
|
+
unless %i[native string].include?(datetime_policy)
|
|
26
|
+
raise ArgumentError, "datetime_policy must be :native or :string"
|
|
27
|
+
end
|
|
28
|
+
opts = {}
|
|
29
|
+
opts[:string_datetimes] = true if datetime_policy == :string
|
|
30
|
+
if permitted_classes && datetime_policy == :native
|
|
31
|
+
permitted = permitted_classes + [:__scalar]
|
|
32
|
+
opts[:forbid_time] = true unless permitted.include?(Time)
|
|
33
|
+
opts[:forbid_date] = true unless permitted.include?(Date)
|
|
34
|
+
end
|
|
35
|
+
load(toml) if opts.empty?
|
|
36
|
+
TeptrisExt.load(toml, opts)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# One-pass schema materialization over a compiled
|
|
40
|
+
# Teptris::Descriptor: unplanned keys are never materialized
|
|
41
|
+
# (teptris#46).
|
|
42
|
+
def load_schema(toml, descriptor)
|
|
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)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def engine_version
|
|
52
|
+
TeptrisExt.engine_version
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
public
|
|
56
|
+
|
|
57
|
+
def load_file(path)
|
|
58
|
+
load(File.read(path))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def dump(obj)
|
|
62
|
+
TeptrisExt.dump(obj)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
data/lib/teptris.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "date"
|
|
2
|
+
|
|
3
|
+
require_relative "teptris/version"
|
|
4
|
+
require_relative "teptris/error"
|
|
5
|
+
require_relative "teptris/descriptor"
|
|
6
|
+
require_relative "teptris/toml"
|
|
7
|
+
|
|
8
|
+
# Windows ucrt rubies name their DLL per minor (x64-ucrt-ruby330.dll), so
|
|
9
|
+
# the mingw gems ship one extension per ruby minor beside a shared
|
|
10
|
+
# libteptris.dll (nokogiri's fat-gem layout). The native extension IS the
|
|
11
|
+
# binding — no fallback, ever.
|
|
12
|
+
begin
|
|
13
|
+
if RUBY_PLATFORM =~ /mingw/
|
|
14
|
+
require "teptris/#{RUBY_VERSION[/\A\d+\.\d+/]}/teptris_ext"
|
|
15
|
+
else
|
|
16
|
+
require "teptris_ext"
|
|
17
|
+
end
|
|
18
|
+
rescue LoadError
|
|
19
|
+
raise LoadError,
|
|
20
|
+
"teptris native extension not available for #{RUBY_PLATFORM} " \
|
|
21
|
+
"ruby #{RUBY_VERSION} (no fallback by design)"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module Teptris
|
|
25
|
+
TEPTRIS_OK = 0
|
|
26
|
+
end
|
data/lib/teptris_ext.so
ADDED
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: teptris
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.37
|
|
5
|
+
platform: powerpc64le-linux
|
|
6
|
+
authors:
|
|
7
|
+
- teptris contributors
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-09-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A native C extension over libteptris, a C99 TOML 1.1 parser/emitter.
|
|
14
|
+
API shape mirrors the tomlib gem.
|
|
15
|
+
email:
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/teptris.rb
|
|
21
|
+
- lib/teptris/descriptor.rb
|
|
22
|
+
- lib/teptris/error.rb
|
|
23
|
+
- lib/teptris/toml.rb
|
|
24
|
+
- lib/teptris/version.rb
|
|
25
|
+
- lib/teptris_ext.so
|
|
26
|
+
homepage: https://github.com/leptris/teptris-ruby
|
|
27
|
+
licenses:
|
|
28
|
+
- MIT
|
|
29
|
+
metadata: {}
|
|
30
|
+
post_install_message:
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '3.0'
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 3.4.20
|
|
46
|
+
signing_key:
|
|
47
|
+
specification_version: 4
|
|
48
|
+
summary: TOML for Ruby at libteptris speed (native C extension)
|
|
49
|
+
test_files: []
|