fast-sfv 0.2.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +23 -0
- data/lib/fast/sfv/regions.rb +1 -1
- data/lib/fast/sfv/serializer.rb +72 -43
- data/lib/fast/sfv/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c038f41386c09fa8be9123a801e49bbfa2e51827024b0240c3a6075d74f1c8e4
|
|
4
|
+
data.tar.gz: c80c47ef6fc3312a443e48fffc5db0ebfbef2c197d0f1482fcba1bf6ba1cbd42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a398395e55160c7aa41026cb286685c87f3af1cf71705db2d4c4a52cd1238d1a072c16d9ea1951ed780bc260b73546c6f22d168d3d83e58485a9f5df19d690b5
|
|
7
|
+
data.tar.gz: 82352cb33d48328c2bc69d2f5ea907a5faf983754c0812bad81c20d49774d1765f74bcbcb4e59b9670003624ff3db709666788ca8932ece3b7ea6c6fd746bd25
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
- Fixed: the emit boundary never sends a message into the value it is
|
|
6
|
+
checking — the boundary guards (`serialize_item`, `serialize_list`
|
|
7
|
+
and `serialize_dict`, and the inner-list, parameter, key, date and
|
|
8
|
+
display-string walks beneath them) read the value with the
|
|
9
|
+
never-dispatch forms (`case value when Klass`, `Module#===`), so a
|
|
10
|
+
classless value (a `BasicObject` descendant) at a boundary raises
|
|
11
|
+
the documented `SerializeError` instead of escaping the error
|
|
12
|
+
contract as a raw `NoMethodError` — the promise the errors module
|
|
13
|
+
carries. A method is sent into the value only after its type is
|
|
14
|
+
established; the message names the value's class, never a method
|
|
15
|
+
the value itself answers.
|
|
16
|
+
- Fixed: `regions_item`/`regions_list`/`regions_dict`'s shape
|
|
17
|
+
`ArgumentError` leads with the requirement — "the shape must be
|
|
18
|
+
:item, :list or :dictionary, received …" — the wording rule every
|
|
19
|
+
requirement message in the family now follows.
|
|
20
|
+
- Test: negative zero serializes unsigned — `-0.0` emits `"0.0"`
|
|
21
|
+
(§4.1.5 step 5: only a value less than zero carries a sign), now
|
|
22
|
+
pinned by a round-trip assertion.
|
|
23
|
+
- Docs: the API reference's `VERSION` pin matches the released
|
|
24
|
+
version again (it had stayed at `0.1.1` through 0.2.0).
|
|
25
|
+
|
|
3
26
|
## 0.2.0 (2026-11-26)
|
|
4
27
|
|
|
5
28
|
- Fixed: non-ASCII-compatible field input no longer escapes the error
|
data/lib/fast/sfv/regions.rb
CHANGED
|
@@ -94,7 +94,7 @@ module Fast
|
|
|
94
94
|
when :item then scan_item
|
|
95
95
|
when :list then scan_list
|
|
96
96
|
when :dictionary then scan_dictionary
|
|
97
|
-
else raise ArgumentError, "the shape
|
|
97
|
+
else raise ArgumentError, "the shape must be :item, :list or :dictionary, received #{shape.inspect}"
|
|
98
98
|
end
|
|
99
99
|
freeze
|
|
100
100
|
end
|
data/lib/fast/sfv/serializer.rb
CHANGED
|
@@ -158,15 +158,21 @@ module Fast
|
|
|
158
158
|
def emit_inner_list(output, inner_list)
|
|
159
159
|
output << "("
|
|
160
160
|
items = inner_list.items
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
case items
|
|
162
|
+
when Array
|
|
163
|
+
first = true
|
|
164
|
+
items.each do |item|
|
|
165
|
+
output << " " unless first
|
|
166
|
+
first = false
|
|
167
|
+
case item
|
|
168
|
+
when Item
|
|
169
|
+
emit_item(output, item)
|
|
170
|
+
else
|
|
171
|
+
fail_serialize(output, "an inner list member must be an Item (got #{shape(item)})")
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
else
|
|
175
|
+
fail_serialize(output, "an inner list's items must be an Array (got #{shape(items)})")
|
|
170
176
|
end
|
|
171
177
|
output << ")"
|
|
172
178
|
emit_parameters(output, inner_list.params)
|
|
@@ -176,15 +182,18 @@ module Fast
|
|
|
176
182
|
# unless the value is Boolean true — the ";key" short form. The
|
|
177
183
|
# Hash's iteration order is the wire order.
|
|
178
184
|
def emit_parameters(output, params)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
case params
|
|
186
|
+
when Hash
|
|
187
|
+
params.each do |key, value|
|
|
188
|
+
output << ";"
|
|
189
|
+
emit_key(output, key)
|
|
190
|
+
unless value.equal?(true)
|
|
191
|
+
output << "="
|
|
192
|
+
emit_bare_item(output, value)
|
|
193
|
+
end
|
|
187
194
|
end
|
|
195
|
+
else
|
|
196
|
+
fail_serialize(output, "parameters must be a Hash (got #{shape(params)})")
|
|
188
197
|
end
|
|
189
198
|
end
|
|
190
199
|
|
|
@@ -192,8 +201,16 @@ module Fast
|
|
|
192
201
|
# continuation KEY_BODY — the class the parse path reads; then the
|
|
193
202
|
# key's bytes are appended whole.
|
|
194
203
|
def emit_key(output, key)
|
|
195
|
-
|
|
204
|
+
case key
|
|
205
|
+
when String
|
|
206
|
+
emit_key_bytes(output, key)
|
|
207
|
+
else
|
|
208
|
+
fail_serialize(output, "a key must be a String (got #{shape(key)})")
|
|
209
|
+
end
|
|
210
|
+
end
|
|
196
211
|
|
|
212
|
+
# The key's own byte walk — the String the case above handed in.
|
|
213
|
+
def emit_key_bytes(output, key)
|
|
197
214
|
size = key.bytesize
|
|
198
215
|
fail_serialize(output, "a key must not be empty") if size.zero?
|
|
199
216
|
fail_serialize(output, "a key must start with a lowercase letter or '*'") unless KEY_FIRST[key.getbyte(0)]
|
|
@@ -449,9 +466,12 @@ module Fast
|
|
|
449
466
|
def emit_date(output, value)
|
|
450
467
|
output << "@"
|
|
451
468
|
number = value.value
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
469
|
+
case number
|
|
470
|
+
when Integer
|
|
471
|
+
emit_integer(output, number)
|
|
472
|
+
else
|
|
473
|
+
fail_serialize(output, "a date's value must be an Integer (got #{shape(number)})")
|
|
474
|
+
end
|
|
455
475
|
end
|
|
456
476
|
|
|
457
477
|
# §4.1.11 Serializing a Display String: #value UTF-8-encoded (a
|
|
@@ -484,19 +504,21 @@ module Fast
|
|
|
484
504
|
# arrives in another encoding, failed loudly when it cannot be.
|
|
485
505
|
def display_text(output, value)
|
|
486
506
|
text = value.value
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
507
|
+
case text
|
|
508
|
+
when String
|
|
509
|
+
if text.encoding != Encoding::UTF_8
|
|
510
|
+
begin
|
|
511
|
+
text = text.encode(Encoding::UTF_8)
|
|
512
|
+
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError, Encoding::ConverterNotFoundError
|
|
513
|
+
fail_serialize(output, "a display string must be Unicode text")
|
|
514
|
+
end
|
|
495
515
|
end
|
|
496
|
-
|
|
497
|
-
fail_serialize(output, "a display string must be Unicode text") unless text.valid_encoding?
|
|
516
|
+
fail_serialize(output, "a display string must be Unicode text") unless text.valid_encoding?
|
|
498
517
|
|
|
499
|
-
|
|
518
|
+
text
|
|
519
|
+
else
|
|
520
|
+
fail_serialize(output, "a display string's value must be a String (got #{shape(text)})")
|
|
521
|
+
end
|
|
500
522
|
end
|
|
501
523
|
|
|
502
524
|
# The number of base-10 digits of +magnitude+ (1 at zero): the
|
|
@@ -543,9 +565,12 @@ module Fast
|
|
|
543
565
|
# token (a Symbol is wrong-typed input and raises), an ASCII-8BIT
|
|
544
566
|
# String a byte sequence.
|
|
545
567
|
def serialize_item(item)
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
568
|
+
case item
|
|
569
|
+
when Item
|
|
570
|
+
Serializer.item_string(item)
|
|
571
|
+
else
|
|
572
|
+
Serializer.fail_shape("an Item", item)
|
|
573
|
+
end
|
|
549
574
|
end
|
|
550
575
|
|
|
551
576
|
# Serializes an RFC 9651 List (§4.1, field_type "list") — the
|
|
@@ -557,10 +582,12 @@ module Fast
|
|
|
557
582
|
# SerializeError; an Item is never empty, so only the containers
|
|
558
583
|
# answer nil.
|
|
559
584
|
def serialize_list(list)
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
585
|
+
case list
|
|
586
|
+
when Array
|
|
587
|
+
list.empty? ? nil : Serializer.list_string(list)
|
|
588
|
+
else
|
|
589
|
+
Serializer.fail_shape("an Array of Items and InnerLists", list)
|
|
590
|
+
end
|
|
564
591
|
end
|
|
565
592
|
|
|
566
593
|
# Serializes an RFC 9651 Dictionary (§4.1, field_type "dictionary") —
|
|
@@ -572,10 +599,12 @@ module Fast
|
|
|
572
599
|
# Strict: a non-Hash input, a Symbol key or an unwrapped value
|
|
573
600
|
# raises SerializeError.
|
|
574
601
|
def serialize_dict(dict)
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
602
|
+
case dict
|
|
603
|
+
when Hash
|
|
604
|
+
dict.empty? ? nil : Serializer.dictionary_string(dict)
|
|
605
|
+
else
|
|
606
|
+
Serializer.fail_shape("a Hash of String keys to Items and InnerLists", dict)
|
|
607
|
+
end
|
|
579
608
|
end
|
|
580
609
|
end
|
|
581
610
|
end
|
data/lib/fast/sfv/version.rb
CHANGED