yeptris 0.5.2.1 → 0.6.1.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/lib/yeptris/psych/visitors.rb +5 -1
- data/lib/yeptris/yaml.rb +36 -7
- data/lib/yeptris.rb +1 -1
- 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: d9b0f5f6a0bcddd8467c3226cbe4438ad2ac119daecbc28395c125045a827825
|
|
4
|
+
data.tar.gz: 111a48659d2f3f8f23e3b04ae3dffc1d85fb632a4436887106f89edb583350f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc31a785a9e1bfb683ac4808a9cb58de25d75258d88e7871f8a57d8098e4e84667fb0810b0016eed80c2230260ca6e1a173b1befdbffc2c17d07fdaf07085c2a
|
|
7
|
+
data.tar.gz: ea6db1c0c50fe7d6fdd5ebd7bcfdd913e321fc15041deb4f024d03e6558438ff09511591462327279c7e1877b6beb298573c8e5f8067fb36544c08b05d5dc54b
|
|
@@ -116,8 +116,12 @@ module Yeptris
|
|
|
116
116
|
text =
|
|
117
117
|
if obj.is_a?(::Date) || obj.is_a?(::Time)
|
|
118
118
|
obj.iso8601 # canonical timestamp form, not to_s
|
|
119
|
+
elsif obj.nil?
|
|
120
|
+
"" # libyaml's null rendering rides bare (issue #290)
|
|
121
|
+
elsif obj.is_a?(::Float)
|
|
122
|
+
::Yeptris::YAML::BulkBuilder.float_text(obj)
|
|
119
123
|
else
|
|
120
|
-
obj.
|
|
124
|
+
obj.to_s
|
|
121
125
|
end
|
|
122
126
|
n =
|
|
123
127
|
if obj.is_a?(::String)
|
data/lib/yeptris/yaml.rb
CHANGED
|
@@ -101,9 +101,22 @@ module Yeptris
|
|
|
101
101
|
STYLE_PLAIN = 1
|
|
102
102
|
STYLE_SQ = 2
|
|
103
103
|
STYLE_DQ = 3
|
|
104
|
+
STYLE_LIT = 4
|
|
104
105
|
|
|
105
106
|
module_function
|
|
106
107
|
|
|
108
|
+
# Psych's float spelling (#290): Infinity/NAN ride the YAML words,
|
|
109
|
+
# not Ruby's to_s (which prints "Infinity"/"NaN" — a STRING on
|
|
110
|
+
# reload)
|
|
111
|
+
def float_text(f)
|
|
112
|
+
return ".nan" if f.respond_to?(:nan?) && f.nan?
|
|
113
|
+
case (inf = f.infinite?)
|
|
114
|
+
when 1 then ".inf"
|
|
115
|
+
when -1 then "-.inf"
|
|
116
|
+
else f.to_s
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
107
120
|
# container entries are constant bytes — no pack per op
|
|
108
121
|
MAP_ENTRY = [Yeptris::FFI::BUILD_MAP, 0, 0, 0].pack("CCx2VV").freeze
|
|
109
122
|
SEQ_ENTRY = [Yeptris::FFI::BUILD_SEQ, 0, 0, 0].pack("CCx2VV").freeze
|
|
@@ -141,10 +154,17 @@ module Yeptris
|
|
|
141
154
|
# Symbol keys emit as bare ":k" plain — the compat
|
|
142
155
|
# reader resolves them back to Symbols; string keys
|
|
143
156
|
# ride the visit_String rules like any other scalar
|
|
157
|
+
# Symbol keys emit as bare ":k" plain — the compat
|
|
158
|
+
# reader resolves them back to Symbols; Integer/Float/
|
|
159
|
+
# bool keys ride plain like their values (Psych emits
|
|
160
|
+
# 1: unquoted — #290 family 5); string keys ride the
|
|
161
|
+
# visit_String rules like any other scalar
|
|
144
162
|
if k.is_a?(Symbol)
|
|
145
163
|
scalar(":#{k}", STYLE_PLAIN, emit, blob, off)
|
|
164
|
+
elsif k.is_a?(String)
|
|
165
|
+
place(k, emit, blob, off, seen)
|
|
146
166
|
else
|
|
147
|
-
|
|
167
|
+
scalar(k.to_s, STYLE_PLAIN, emit, blob, off)
|
|
148
168
|
end
|
|
149
169
|
place(v, emit, blob, off, seen)
|
|
150
170
|
end
|
|
@@ -158,9 +178,10 @@ module Yeptris
|
|
|
158
178
|
end
|
|
159
179
|
when String then scalar(obj, STYLE_BY_NAME[string_style(obj)], emit, blob, off)
|
|
160
180
|
when Symbol then scalar(":#{obj}", STYLE_PLAIN, emit, blob, off)
|
|
161
|
-
when Integer
|
|
181
|
+
when Integer then scalar(obj.to_s, STYLE_PLAIN, emit, blob, off)
|
|
182
|
+
when Float then scalar(float_text(obj), STYLE_PLAIN, emit, blob, off)
|
|
162
183
|
when true, false then scalar(obj.to_s, STYLE_PLAIN, emit, blob, off)
|
|
163
|
-
when nil then scalar("
|
|
184
|
+
when nil then scalar("", STYLE_PLAIN, emit, blob, off)
|
|
164
185
|
when Date, Time then scalar(obj.iso8601, STYLE_PLAIN, emit, blob, off)
|
|
165
186
|
else
|
|
166
187
|
raise DumpError,
|
|
@@ -235,9 +256,14 @@ module Yeptris
|
|
|
235
256
|
# otherwise → plain
|
|
236
257
|
# psych's literal/folded/binary forms and its !!str tag for
|
|
237
258
|
# "<<" are follow-ups; those strings double-quote today.
|
|
238
|
-
STYLE_BY_NAME = { plain: STYLE_PLAIN, single: STYLE_SQ, double: STYLE_DQ
|
|
259
|
+
STYLE_BY_NAME = { plain: STYLE_PLAIN, single: STYLE_SQ, double: STYLE_DQ,
|
|
260
|
+
literal: STYLE_LIT }.freeze
|
|
239
261
|
|
|
240
262
|
def string_style(s)
|
|
263
|
+
# psych's visit_String: any interior newline rides a literal
|
|
264
|
+
# block (the C writer's libyaml indicator rules render it) —
|
|
265
|
+
# first, exactly as psych orders it (#290 family 4)
|
|
266
|
+
return :literal if s.match?(/\n(?!\z)/)
|
|
241
267
|
return :double if s == "y" || s == "Y" || s == "n" || s == "N"
|
|
242
268
|
return :double if !s.empty? && !s.include?('"') && s.match?(/\A[^[:word:]]/)
|
|
243
269
|
return :single if s.match?(/\A0[0-7]*[89]/)
|
|
@@ -267,9 +293,10 @@ module Yeptris
|
|
|
267
293
|
when Array then build_seq(doc, obj, seen)
|
|
268
294
|
when String then build_string(doc, obj)
|
|
269
295
|
when Symbol then new_scalar(doc, ":#{obj}")
|
|
270
|
-
when Integer
|
|
296
|
+
when Integer then new_scalar(doc, obj.to_s)
|
|
297
|
+
when Float then new_scalar(doc, BulkBuilder.float_text(obj))
|
|
271
298
|
when true, false then new_scalar(doc, obj.to_s)
|
|
272
|
-
when nil then new_scalar(doc, "
|
|
299
|
+
when nil then new_scalar(doc, "")
|
|
273
300
|
when Date, Time then new_scalar(doc, obj.iso8601)
|
|
274
301
|
else
|
|
275
302
|
raise DumpError,
|
|
@@ -301,6 +328,7 @@ module Yeptris
|
|
|
301
328
|
case BulkBuilder.string_style(s)
|
|
302
329
|
when :single then new_scalar(doc, s, :force_str_sq)
|
|
303
330
|
when :double then new_scalar(doc, s, :force_str)
|
|
331
|
+
when :literal then new_scalar(doc, s, :force_lit)
|
|
304
332
|
else new_scalar(doc, s)
|
|
305
333
|
end
|
|
306
334
|
end
|
|
@@ -313,7 +341,8 @@ module Yeptris
|
|
|
313
341
|
def new_scalar(doc, text, mode = nil)
|
|
314
342
|
doc.new_scalar(text.to_s,
|
|
315
343
|
mode == :force_str ? :double_quoted :
|
|
316
|
-
mode == :force_str_sq ? :single_quoted :
|
|
344
|
+
mode == :force_str_sq ? :single_quoted :
|
|
345
|
+
mode == :force_lit ? :literal : :plain)
|
|
317
346
|
end
|
|
318
347
|
|
|
319
348
|
def cycle_guard(obj, seen)
|
data/lib/yeptris.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Yeptris
|
|
4
4
|
# The gem's version lives in the parent namespace's file — the last
|
|
5
5
|
# internal require (yeptris/version) retired with it.
|
|
6
|
-
VERSION = "0.
|
|
6
|
+
VERSION = "0.6.1.1".freeze
|
|
7
7
|
# The error hierarchy lives in THIS file (the parent namespace's
|
|
8
8
|
# own file): nested constants do not trigger a parent-constant
|
|
9
9
|
# autoload, and the law forbids internal requires — defining the
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yeptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|