teptris 0.3.33.0 → 0.3.33.1

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: 8955c880db82b01c41be3698c3befbb8e4c91358643dcd92ec729c2087c94b70
4
- data.tar.gz: a9bf3438e8bc81c59feb214dde7534d07484d2aec396c2d54b39f78ad2f9ef97
3
+ metadata.gz: 9d251f0150a0ebb5b1bf72e4eaaa53e6d58aff2c2547d7e569d61db8d38aeeba
4
+ data.tar.gz: dbb61e0ff0f20910d709bcaf380e9cb6a3a9c4c600e5b425b7d6e048797b66d6
5
5
  SHA512:
6
- metadata.gz: c4871e38031d23c81ffb93678f23b14912b93fe9dd6f98cbfffe8aa02bd59c541dae942328464f1d9f12d94ef192b2fe9fbfa608e54848feba8d84d228499a1a
7
- data.tar.gz: fd7150572a12b4ae6e34b5c578e57136fdd036315fa70044d8dda1c91a0875e229b2b8c0a7040da779a6cd6e59258ac985f987edfed5c3a685b7d56ff655ca55
6
+ metadata.gz: eae3325d80fea84fcf6d048c35d2e7cb4c4559c5577f8b9998097564ba614d237d566aaa951b9f00956bd00bf0736bd80abea389f11741f223beb57b8c64a230
7
+ data.tar.gz: 9b9aa0b4578f64a42ae8bb08647e8e99f418fc83e745fb6db4b3c4bdb8d6de6e3649f26a4ec76dc33efaff1193f8ff8f8d78fbb4438778a67783800fc5c49b90
@@ -860,6 +860,28 @@ static VALUE ext_plan_emit(VALUE self, VALUE rb_plan, VALUE toml)
860
860
  return out;
861
861
  }
862
862
 
863
+ /* The retained-document walk (teptris_plan_walk's own face): walk a
864
+ * load_doc() handle against the plan — one parse, many walks (and
865
+ * one document may serve several plans). Same shape as plan_emit. */
866
+ static VALUE ext_plan_emit_doc(VALUE self, VALUE rb_plan, VALUE rbdoc)
867
+ {
868
+ teptris_plan *plan;
869
+ TypedData_Get_Struct(rb_plan, teptris_plan, &plan_type, plan);
870
+ doc_owner *d;
871
+ TypedData_Get_Struct(rbdoc, doc_owner, &doc_owner_type, d);
872
+ teptris_status st;
873
+ teptris_plan_result *res =
874
+ teptris_plan_walk(plan, teptris_document_root(d->doc), &st);
875
+ if (res == NULL) {
876
+ char msg[96];
877
+ snprintf(msg, sizeof msg, "plan walk failed (status %d)", (int)st);
878
+ raise_teptris(msg);
879
+ }
880
+ VALUE out = asm_rows(plan, res, 0);
881
+ teptris_plan_result_free(res);
882
+ return out;
883
+ }
884
+
863
885
 
864
886
  /* ---- lazy mode (#79) ----------------------------------------------
865
887
  * load_lazy returns a LazyValue wrapping the parsed tree: scalar
@@ -1349,6 +1371,7 @@ static VALUE ext_load_batch(int argc, VALUE *argv, VALUE self) {
1349
1371
 
1350
1372
  static VALUE ext_schema_compile(VALUE self, VALUE str);
1351
1373
  static VALUE ext_schema_validate(VALUE self, VALUE rsch, VALUE str);
1374
+ static VALUE ext_schema_validate_doc(VALUE self, VALUE rsch, VALUE rbdoc);
1352
1375
 
1353
1376
  #ifndef TEPTRIS_INIT_SYMBOL
1354
1377
  #define TEPTRIS_INIT_SYMBOL Init_teptris_ext
@@ -1373,6 +1396,8 @@ void TEPTRIS_INIT_SYMBOL(void) {
1373
1396
  rb_undef_alloc_func(cSchema);
1374
1397
  rb_define_module_function(m, "schema_compile", ext_schema_compile, 1);
1375
1398
  rb_define_module_function(m, "schema_validate", ext_schema_validate, 2);
1399
+ rb_define_module_function(m, "schema_validate_doc",
1400
+ ext_schema_validate_doc, 2);
1376
1401
  cLazyOwner = rb_define_class_under(m, "LazyOwner", rb_cObject);
1377
1402
  cLazyValue = rb_define_class_under(m, "LazyValue", rb_cObject);
1378
1403
  rb_define_method(cLazyValue, "kind", lazy_kind, 0);
@@ -1391,6 +1416,7 @@ void TEPTRIS_INIT_SYMBOL(void) {
1391
1416
  rb_define_module_function(m, "edit", ext_edit, 3);
1392
1417
  rb_define_module_function(m, "plan_build", ext_plan_build, 2);
1393
1418
  rb_define_module_function(m, "plan_emit", ext_plan_emit, 2);
1419
+ rb_define_module_function(m, "plan_emit_doc", ext_plan_emit_doc, 2);
1394
1420
  /* error/version load first (teptris.rb), then the ext bundle */
1395
1421
  VALUE t = rb_const_get(rb_cObject, rb_intern("Teptris"));
1396
1422
  eError = rb_const_get(t, rb_intern("Error"));
@@ -1494,3 +1520,20 @@ static VALUE ext_schema_validate(VALUE self, VALUE rsch, VALUE str) {
1494
1520
  free(buf);
1495
1521
  return out;
1496
1522
  }
1523
+
1524
+ /* The retained-document validation (teptris_schema_validate_doc's
1525
+ * own face): validate a load_doc() handle against the compiled
1526
+ * schema — one parse, many validations. Same violations JSON as
1527
+ * schema_validate. */
1528
+ static VALUE ext_schema_validate_doc(VALUE self, VALUE rsch, VALUE rbdoc) {
1529
+ schema_owner *o;
1530
+ TypedData_Get_Struct(rsch, schema_owner, &schema_owner_type, o);
1531
+ doc_owner *d;
1532
+ TypedData_Get_Struct(rbdoc, doc_owner, &doc_owner_type, d);
1533
+ char *buf = NULL;
1534
+ size_t out_len = 0;
1535
+ dump_check(teptris_schema_validate_doc(o->sch, d->doc, &buf, &out_len));
1536
+ VALUE out = rb_str_new(buf, (long)out_len);
1537
+ free(buf);
1538
+ return out;
1539
+ }
@@ -70,4 +70,12 @@ class Teptris::Descriptor
70
70
  def walk(toml)
71
71
  TeptrisExt.plan_emit(@handle, toml)
72
72
  end
73
+
74
+ # Walk a RETAINED document (Teptris::TOML.load_doc): one parse,
75
+ # many walks — the engine's teptris_plan_walk face, which takes the
76
+ # document node. Raw TOML strings belong to #walk. Same shape as
77
+ # #walk.
78
+ def walk_doc(doc)
79
+ TeptrisExt.plan_emit_doc(@handle, doc)
80
+ end
73
81
  end
@@ -32,6 +32,17 @@ class Teptris::Schema
32
32
  def to_h
33
33
  { path: path, schema_path: schema_path, message: message }
34
34
  end
35
+
36
+ # Value semantics: two violations of the same fact are the same
37
+ # violation, wherever they came from (validate vs validate_doc).
38
+ def ==(other)
39
+ other.is_a?(Violation) && other.to_h == to_h
40
+ end
41
+ alias eql? ==
42
+
43
+ def hash
44
+ to_h.hash
45
+ end
35
46
  end
36
47
 
37
48
  class << self
@@ -47,10 +58,7 @@ class Teptris::Schema
47
58
  # Validate raw TOML; an empty array = valid. Raises
48
59
  # Teptris::ParseError when the document does not parse.
49
60
  def validate(toml)
50
- raw = JSON.parse(TeptrisExt.schema_validate(@handle, toml))
51
- raw.map do |v|
52
- Violation.new(v["path"], v["schemaPath"], v["message"])
53
- end
61
+ violations(TeptrisExt.schema_validate(@handle, toml))
54
62
  end
55
63
 
56
64
  # True when the document parses with no violations.
@@ -58,7 +66,31 @@ class Teptris::Schema
58
66
  validate(toml).empty?
59
67
  end
60
68
 
69
+ # Validate a RETAINED document (Teptris::TOML.load_doc): one parse,
70
+ # many validations — the engine's teptris_schema_validate_doc face.
71
+ # Raw TOML strings belong to #validate. Same violations as
72
+ # #validate.
73
+ def validate_doc(doc)
74
+ violations(TeptrisExt.schema_validate_doc(@handle, doc))
75
+ end
76
+
77
+ # The retained-document twin of #valid?.
78
+ def valid_doc?(doc)
79
+ validate_doc(doc).empty?
80
+ end
81
+
61
82
  def inspect
62
83
  "#<#{self.class.name}>"
63
84
  end
85
+
86
+ private
87
+
88
+ # The engine reports violations as a JSON array of
89
+ # {"path", "schemaPath", "message"} objects; the wrapper owns the
90
+ # materialized shape.
91
+ def violations(raw_json)
92
+ JSON.parse(raw_json).map do |v|
93
+ Violation.new(v["path"], v["schemaPath"], v["message"])
94
+ end
95
+ end
64
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teptris
4
- VERSION = "0.3.33.0"
4
+ VERSION = "0.3.33.1"
5
5
  end
data/sig/teptris.rbs CHANGED
@@ -43,7 +43,17 @@ module Teptris
43
43
  def initialize: (untyped handle) -> void
44
44
  def validate: (String toml) -> Array[Violation]
45
45
  def valid?: (String toml) -> bool
46
+ # retained-document faces (teptris-ruby#203): validate a
47
+ # Teptris::TOML.load_doc handle — one parse, many validations
48
+ def validate_doc: (untyped doc) -> Array[Violation]
49
+ def valid_doc?: (untyped doc) -> bool
46
50
  def inspect: () -> String
51
+
52
+ private
53
+
54
+ # the engine's violations JSON -> Violation objects (shared by
55
+ # validate and validate_doc)
56
+ def violations: (String raw_json) -> Array[Violation]
47
57
  end
48
58
 
49
59
  module TOML
@@ -114,6 +124,10 @@ module Teptris
114
124
  attr_reader first_row: Array[Integer]
115
125
 
116
126
  def walk: (String toml) -> Hash[String, untyped]
127
+
128
+ # retained-document face (teptris-ruby#203): walk a
129
+ # Teptris::TOML.load_doc handle — one parse, many walks
130
+ def walk_doc: (untyped doc) -> Hash[String, untyped]
117
131
  end
118
132
  end
119
133
 
@@ -179,12 +193,18 @@ module TeptrisExt
179
193
 
180
194
  def self.plan_emit: (untyped handle, String toml) -> Hash[String, untyped]
181
195
 
196
+ def self.plan_emit_doc: (untyped handle, untyped doc)
197
+ -> Hash[String, untyped]
198
+
182
199
  # schema validation (engine 0.3.20): the compiled schema is an
183
200
  # opaque TypedData handle freed by GC
184
201
  def self.schema_compile: (String schema_json) -> TeptrisExt::Schema
185
202
 
186
203
  def self.schema_validate: (TeptrisExt::Schema schema, String toml) -> String
187
204
 
205
+ def self.schema_validate_doc: (TeptrisExt::Schema schema, untyped doc)
206
+ -> String
207
+
188
208
  class Schema
189
209
  # opaque; owns the native handle
190
210
  end
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.3.33.0
4
+ version: 0.3.33.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - teptris contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-23 00:00:00.000000000 Z
11
+ date: 2026-11-24 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.