teptris 0.2.54-powerpc64le-linux → 0.2.56-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f06803f154a5072fe10def850b80baec9295a4f4276a6126385cd08d69977b2
4
- data.tar.gz: 4444c30d22d28fb3a8be5509146223706cfb0a3c5ff60b3b15a2997b8c15107a
3
+ metadata.gz: 32b39ffbd30932eca5a224111eba8d0bafb2caee197d34d89bbfbfe564ee9842
4
+ data.tar.gz: 37b2de3ec0726b22136ead32e4977cfee8f05d168e5d3238c887f25b3af1da81
5
5
  SHA512:
6
- metadata.gz: c3423559c0cf6e7b8e80b24584f922c7afb37cc9aa898e5f1777caeede8266192f0a1a29d97affa7df928fc647569ad71009ab4616159f1a98a86baaed0c1dc4
7
- data.tar.gz: e073c1c5671c6a3c142284ceed2c0d2c051f2284fc189e0e84d2a2a8af04e51b74036b7b47b3d1d7c4910ba76c337369a70ca8a7a94a883257b6ce7fe8d8957b
6
+ metadata.gz: 0f66e8df86cb3d7b8a72228ccc7523c43ddc00a541fb7a32d3601fb4bca87129d485880d6b921b6d2208e801acf22fa28cfa4547c16609fef2bd232df130cb05
7
+ data.tar.gz: c65385e861e11cac016952efa0fa56b232277e0e2ec89d53413025db083532883ed7651aaa9880a7db2148b9f5516f7ad467fabe1e0be766f87706e7ddb2c96c
@@ -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
- $LIBS = $LIBS.sub("-lruby", "")
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!(/(^|\s)\S*libruby[\w.\/-]*/, "")
57
+ makefile.gsub!(%r{(^|\s)\S*libruby[\w./-]*}, "")
60
58
  File.write("Makefile", makefile)
61
59
  end
@@ -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[Integer, Integer]
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.object_id)
41
- index_of[t.object_id] = plans.length
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].object_id] : 0
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Teptris
2
4
  class Error < StandardError; end
3
5
 
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
- 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)
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
- # 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
- # @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
- # Lazy load: returns a wrapper that parses eagerly (one pass)
41
- # but materializes host objects only along the paths actually
42
- # accessed. Same datetime contract as load; to_h/to_a flatten to
43
- # the eager shape.
44
- def load_lazy(toml)
45
- raise ArgumentError, "input must be a String" unless toml.is_a?(String)
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
- TeptrisExt.load_lazy(toml)
48
- end
49
+ TeptrisExt.load_lazy(toml)
50
+ end
49
51
 
50
- # Many-small batch path (teptris-ruby#108 ask 3): parse N inputs
51
- # in one C call, share the safe_load/datetime_policy options
52
- # struct across the batch, return one eager Hash per document.
53
- # Same datetime contract as load. A failing document raises
54
- # Teptris::ParseError carrying the first failure's line/column.
55
- def load_batch(tomls, safe_load: nil, datetime_policy: :native,
56
- threads: 1)
57
- _validate_batch!(tomls, safe_load, datetime_policy)
58
- opts = _safe_load_opts(safe_load, datetime_policy)
59
- return TeptrisExt.load_batch(tomls, opts) if threads <= 1
60
-
61
- # threads > 1: slice across Ruby threads. The C parse releases
62
- # the GVL, so parses overlap; materialization serializes on the
63
- # GVL. Contiguous slices keep error order deterministic: the
64
- # lowest-index failure raises after all threads join.
65
- n = tomls.size
66
- threads = [threads, n].min
67
- return TeptrisExt.load_batch(tomls, opts) if threads <= 1
68
- # load_slice releases the GVL once per slice (no per-document
69
- # ping-pong) and shares one key cache across its documents.
70
- # Repeated objects are dup'd once each HERE: a repeat landing in
71
- # two slices would double-lock across threads (the slice-level
72
- # guard cannot see across slices); frozen dup'ing is C-side.
73
- # @type var seen: Hash[Integer, bool]
74
- seen = {}
75
- tomls = tomls.map do |s|
76
- next s.dup if seen[s.object_id]
77
- seen[s.object_id] = true
78
- s
79
- end
80
- per = (n.to_f / threads).ceil
81
- results = Array.new(n)
82
- # @type var first_error: [Integer, untyped]?
83
- first_error = nil
84
- mutex = Mutex.new
85
- threads.times.map do |ti|
86
- Thread.new(ti) do |i|
87
- base = i * per
88
- slice = tomls[base, per] || []
89
- begin
90
- loaded = TeptrisExt.load_slice(slice, opts)
91
- slice.each_with_index { |_, j| results[base + j] = loaded[j] }
92
- rescue StandardError => e
93
- mutex.synchronize do
94
- first_error ||= [base, e]
95
- end
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
- results
104
- end
105
-
106
- # Lazy twin of load_batch: parse N inputs eagerly, hand back an
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
- # Many-small path with file paths: read each file, then call
115
- # load_batch. Symmetric with load_file's single-doc shape.
116
- def load_files(paths, safe_load: nil, datetime_policy: :native)
117
- _validate_batch!(paths, safe_load, datetime_policy, kind: :paths)
118
- load_batch(paths.map { |p| File.read(p) },
119
- safe_load: safe_load, datetime_policy: datetime_policy)
120
- end
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
- # One-pass schema materialization over a compiled
123
- # Teptris::Descriptor: unplanned keys are never materialized
124
- # (teptris#46).
125
- def load_schema(toml, descriptor)
126
- unless descriptor.is_a?(Teptris::Descriptor)
127
- raise ArgumentError,
128
- "descriptor must be a Teptris::Descriptor (use " \
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
- def engine_version
135
- TeptrisExt.engine_version
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
- public
141
+ def engine_version
142
+ TeptrisExt.engine_version
143
+ end
139
144
 
140
- def load_file(path)
141
- load(File.read(path))
142
- end
145
+ def load_file(path)
146
+ load(File.read(path))
147
+ end
143
148
 
144
- def dump(obj)
145
- TeptrisExt.dump(obj)
146
- end
149
+ def dump(obj)
150
+ TeptrisExt.dump(obj)
151
+ end
147
152
 
148
- private
153
+ private
149
154
 
150
- def _validate_batch!(input, safe_load, datetime_policy, kind: :strings)
151
- unless input.is_a?(Array)
152
- raise ArgumentError, "expected Array of #{kind}, got #{input.class}"
153
- end
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
- def _safe_load_opts(safe_load, datetime_policy)
163
- # @type var opts: Hash[Symbol, untyped]
164
- opts = {}
165
- opts[:string_datetimes] = true if datetime_policy == :string
166
- if safe_load && datetime_policy == :native
167
- permitted = Array(safe_load) + [:__scalar]
168
- opts[:forbid_time] = true unless permitted.include?(Time)
169
- opts[:forbid_date] = true unless permitted.include?(Date)
170
- end
171
- opts.empty? ? nil : 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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Teptris
2
- VERSION = "0.2.54"
4
+ VERSION = "0.2.56"
3
5
  end
data/lib/teptris.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "date"
2
4
 
3
5
  require_relative "teptris/version"
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.54
4
+ version: 0.2.56
5
5
  platform: powerpc64le-linux
6
6
  authors:
7
7
  - teptris contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-04 00:00:00.000000000 Z
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.
@@ -63,7 +63,12 @@ files:
63
63
  homepage: https://github.com/leptris/teptris-ruby
64
64
  licenses:
65
65
  - MIT
66
- metadata: {}
66
+ metadata:
67
+ bug_tracker_uri: https://github.com/leptris/teptris-ruby/issues
68
+ changelog_uri: https://github.com/leptris/teptris-ruby/releases
69
+ documentation_uri: https://leptris.github.io/docs/teptris-ruby
70
+ rubygems_mfa_required: 'true'
71
+ source_code_uri: https://github.com/leptris/teptris-ruby
67
72
  post_install_message:
68
73
  rdoc_options: []
69
74
  require_paths: