psych 3.3.3-java → 4.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/psych/scalar_scanner.rb +2 -2
- data/lib/psych/versions.rb +2 -2
- data/lib/psych/visitors/to_ruby.rb +1 -3
- data/lib/psych/visitors/yaml_tree.rb +8 -8
- data/lib/psych.jar +0 -0
- data/lib/psych.rb +53 -60
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5149acda4b0d41732db12bc694d4e72b0f5a511b628389ec0add96cef04d3b23
|
4
|
+
data.tar.gz: 4706cd6d83b23b106bdf5b5ef5953cdb416992bfa5ae774bb5f57e2f5394c1c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 109458fa5a2da076004e322aa34f8b777be41d9dd3f51e27e4f6282e14896d84b8c9964f5a748803ba4873fbcf3857e72aa9993952997ea962c9104f9a4af969
|
7
|
+
data.tar.gz: cf2cb03494fade26c250914388b11ade2d529e81ddfa4bee119c9a5a149681239c6d9c81261f5ec247540a40a137a14e96fcaac4190b9db94ca0a92167410fe8
|
data/lib/psych/scalar_scanner.rb
CHANGED
@@ -34,7 +34,7 @@ module Psych
|
|
34
34
|
|
35
35
|
# Check for a String type, being careful not to get caught by hash keys, hex values, and
|
36
36
|
# special floats (e.g., -.inf).
|
37
|
-
if string.match?(
|
37
|
+
if string.match?(/^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/) || string.match?(/\n/)
|
38
38
|
return string if string.length > 5
|
39
39
|
|
40
40
|
if string.match?(/^[^ytonf~]/i)
|
@@ -57,7 +57,7 @@ module Psych
|
|
57
57
|
elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
|
58
58
|
require 'date'
|
59
59
|
begin
|
60
|
-
class_loader.date.strptime(string, '%
|
60
|
+
class_loader.date.strptime(string, '%Y-%m-%d')
|
61
61
|
rescue ArgumentError
|
62
62
|
string
|
63
63
|
end
|
data/lib/psych/versions.rb
CHANGED
@@ -80,9 +80,7 @@ module Psych
|
|
80
80
|
when "!ruby/object:DateTime"
|
81
81
|
class_loader.date_time
|
82
82
|
require 'date' unless defined? DateTime
|
83
|
-
|
84
|
-
DateTime.civil(*t.to_a[0, 6].reverse, Rational(t.utc_offset, 86400)) +
|
85
|
-
(t.subsec/86400)
|
83
|
+
@ss.parse_time(o.value).to_datetime
|
86
84
|
when '!ruby/encoding'
|
87
85
|
::Encoding.find o.value
|
88
86
|
when "!ruby/object:Complex"
|
@@ -192,13 +192,12 @@ module Psych
|
|
192
192
|
register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
|
193
193
|
end
|
194
194
|
|
195
|
-
def visit_Date o
|
196
|
-
register o, visit_Integer(o.gregorian)
|
197
|
-
end
|
198
|
-
|
199
195
|
def visit_DateTime o
|
200
|
-
|
201
|
-
|
196
|
+
formatted = if o.offset.zero?
|
197
|
+
o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
|
198
|
+
else
|
199
|
+
o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
|
200
|
+
end
|
202
201
|
tag = '!ruby/object:DateTime'
|
203
202
|
register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
|
204
203
|
end
|
@@ -236,6 +235,7 @@ module Psych
|
|
236
235
|
end
|
237
236
|
alias :visit_TrueClass :visit_Integer
|
238
237
|
alias :visit_FalseClass :visit_Integer
|
238
|
+
alias :visit_Date :visit_Integer
|
239
239
|
|
240
240
|
def visit_Float o
|
241
241
|
if o.nan?
|
@@ -480,8 +480,8 @@ module Psych
|
|
480
480
|
@emitter.end_mapping
|
481
481
|
end
|
482
482
|
|
483
|
-
def format_time time
|
484
|
-
if utc
|
483
|
+
def format_time time
|
484
|
+
if time.utc?
|
485
485
|
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
|
486
486
|
else
|
487
487
|
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
|
data/lib/psych.jar
CHANGED
Binary file
|
data/lib/psych.rb
CHANGED
@@ -234,9 +234,6 @@ require 'psych/class_loader'
|
|
234
234
|
module Psych
|
235
235
|
# The version of libyaml Psych is using
|
236
236
|
LIBYAML_VERSION = Psych.libyaml_version.join('.').freeze
|
237
|
-
# Deprecation guard
|
238
|
-
NOT_GIVEN = Object.new.freeze
|
239
|
-
private_constant :NOT_GIVEN
|
240
237
|
|
241
238
|
###
|
242
239
|
# Load +yaml+ in to a Ruby data structure. If multiple documents are
|
@@ -249,11 +246,11 @@ module Psych
|
|
249
246
|
#
|
250
247
|
# Example:
|
251
248
|
#
|
252
|
-
# Psych.
|
253
|
-
# Psych.
|
249
|
+
# Psych.unsafe_load("--- a") # => 'a'
|
250
|
+
# Psych.unsafe_load("---\n - a\n - b") # => ['a', 'b']
|
254
251
|
#
|
255
252
|
# begin
|
256
|
-
# Psych.
|
253
|
+
# Psych.unsafe_load("--- `", filename: "file.txt")
|
257
254
|
# rescue Psych::SyntaxError => ex
|
258
255
|
# ex.file # => 'file.txt'
|
259
256
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
@@ -262,21 +259,16 @@ module Psych
|
|
262
259
|
# When the optional +symbolize_names+ keyword argument is set to a
|
263
260
|
# true value, returns symbols for keys in Hash objects (default: strings).
|
264
261
|
#
|
265
|
-
# Psych.
|
266
|
-
# Psych.
|
262
|
+
# Psych.unsafe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
263
|
+
# Psych.unsafe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
267
264
|
#
|
268
265
|
# Raises a TypeError when `yaml` parameter is NilClass
|
269
266
|
#
|
270
267
|
# NOTE: This method *should not* be used to parse untrusted documents, such as
|
271
268
|
# YAML documents that are supplied via user input. Instead, please use the
|
272
|
-
# safe_load method.
|
269
|
+
# load method or the safe_load method.
|
273
270
|
#
|
274
|
-
def self.unsafe_load yaml,
|
275
|
-
if legacy_filename != NOT_GIVEN
|
276
|
-
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
277
|
-
filename = legacy_filename
|
278
|
-
end
|
279
|
-
|
271
|
+
def self.unsafe_load yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false
|
280
272
|
result = parse(yaml, filename: filename)
|
281
273
|
return fallback unless result
|
282
274
|
result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
|
@@ -327,27 +319,7 @@ module Psych
|
|
327
319
|
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
328
320
|
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
329
321
|
#
|
330
|
-
def self.safe_load yaml,
|
331
|
-
if legacy_permitted_classes != NOT_GIVEN
|
332
|
-
warn_with_uplevel 'Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.', uplevel: 1 if $VERBOSE
|
333
|
-
permitted_classes = legacy_permitted_classes
|
334
|
-
end
|
335
|
-
|
336
|
-
if legacy_permitted_symbols != NOT_GIVEN
|
337
|
-
warn_with_uplevel 'Passing permitted_symbols with the 3rd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_symbols: ...) instead.', uplevel: 1 if $VERBOSE
|
338
|
-
permitted_symbols = legacy_permitted_symbols
|
339
|
-
end
|
340
|
-
|
341
|
-
if legacy_aliases != NOT_GIVEN
|
342
|
-
warn_with_uplevel 'Passing aliases with the 4th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, aliases: ...) instead.', uplevel: 1 if $VERBOSE
|
343
|
-
aliases = legacy_aliases
|
344
|
-
end
|
345
|
-
|
346
|
-
if legacy_filename != NOT_GIVEN
|
347
|
-
warn_with_uplevel 'Passing filename with the 5th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
348
|
-
filename = legacy_filename
|
349
|
-
end
|
350
|
-
|
322
|
+
def self.safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false
|
351
323
|
result = parse(yaml, filename: filename)
|
352
324
|
return fallback unless result
|
353
325
|
|
@@ -363,6 +335,46 @@ module Psych
|
|
363
335
|
result
|
364
336
|
end
|
365
337
|
|
338
|
+
###
|
339
|
+
# Load +yaml+ in to a Ruby data structure. If multiple documents are
|
340
|
+
# provided, the object contained in the first document will be returned.
|
341
|
+
# +filename+ will be used in the exception message if any exception
|
342
|
+
# is raised while parsing. If +yaml+ is empty, it returns
|
343
|
+
# the specified +fallback+ return value, which defaults to +false+.
|
344
|
+
#
|
345
|
+
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
|
346
|
+
#
|
347
|
+
# Example:
|
348
|
+
#
|
349
|
+
# Psych.load("--- a") # => 'a'
|
350
|
+
# Psych.load("---\n - a\n - b") # => ['a', 'b']
|
351
|
+
#
|
352
|
+
# begin
|
353
|
+
# Psych.load("--- `", filename: "file.txt")
|
354
|
+
# rescue Psych::SyntaxError => ex
|
355
|
+
# ex.file # => 'file.txt'
|
356
|
+
# ex.message # => "(file.txt): found character that cannot start any token"
|
357
|
+
# end
|
358
|
+
#
|
359
|
+
# When the optional +symbolize_names+ keyword argument is set to a
|
360
|
+
# true value, returns symbols for keys in Hash objects (default: strings).
|
361
|
+
#
|
362
|
+
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
|
363
|
+
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
364
|
+
#
|
365
|
+
# Raises a TypeError when `yaml` parameter is NilClass. This method is
|
366
|
+
# similar to `safe_load` except that `Symbol` objects are allowed by default.
|
367
|
+
#
|
368
|
+
def self.load yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false
|
369
|
+
safe_load yaml, permitted_classes: permitted_classes,
|
370
|
+
permitted_symbols: permitted_symbols,
|
371
|
+
aliases: aliases,
|
372
|
+
filename: filename,
|
373
|
+
fallback: fallback,
|
374
|
+
symbolize_names: symbolize_names,
|
375
|
+
freeze: freeze
|
376
|
+
end
|
377
|
+
|
366
378
|
###
|
367
379
|
# Parse a YAML string in +yaml+. Returns the Psych::Nodes::Document.
|
368
380
|
# +filename+ is used in the exception message if a Psych::SyntaxError is
|
@@ -382,22 +394,12 @@ module Psych
|
|
382
394
|
# end
|
383
395
|
#
|
384
396
|
# See Psych::Nodes for more information about YAML AST.
|
385
|
-
def self.parse yaml,
|
386
|
-
if legacy_filename != NOT_GIVEN
|
387
|
-
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse is deprecated. Use keyword argument like Psych.parse(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
388
|
-
filename = legacy_filename
|
389
|
-
end
|
390
|
-
|
397
|
+
def self.parse yaml, filename: nil
|
391
398
|
parse_stream(yaml, filename: filename) do |node|
|
392
399
|
return node
|
393
400
|
end
|
394
401
|
|
395
|
-
|
396
|
-
warn_with_uplevel 'Passing the `fallback` keyword argument of Psych.parse is deprecated.', uplevel: 1 if $VERBOSE
|
397
|
-
fallback
|
398
|
-
else
|
399
|
-
false
|
400
|
-
end
|
402
|
+
false
|
401
403
|
end
|
402
404
|
|
403
405
|
###
|
@@ -446,12 +448,7 @@ module Psych
|
|
446
448
|
# Raises a TypeError when NilClass is passed.
|
447
449
|
#
|
448
450
|
# See Psych::Nodes for more information about YAML AST.
|
449
|
-
def self.parse_stream yaml,
|
450
|
-
if legacy_filename != NOT_GIVEN
|
451
|
-
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse_stream is deprecated. Use keyword argument like Psych.parse_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
452
|
-
filename = legacy_filename
|
453
|
-
end
|
454
|
-
|
451
|
+
def self.parse_stream yaml, filename: nil, &block
|
455
452
|
if block_given?
|
456
453
|
parser = Psych::Parser.new(Handlers::DocumentStream.new(&block))
|
457
454
|
parser.parse yaml, filename
|
@@ -552,12 +549,7 @@ module Psych
|
|
552
549
|
# end
|
553
550
|
# list # => ['foo', 'bar']
|
554
551
|
#
|
555
|
-
def self.load_stream yaml,
|
556
|
-
if legacy_filename != NOT_GIVEN
|
557
|
-
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
558
|
-
filename = legacy_filename
|
559
|
-
end
|
560
|
-
|
552
|
+
def self.load_stream yaml, filename: nil, fallback: [], **kwargs
|
561
553
|
result = if block_given?
|
562
554
|
parse_stream(yaml, filename: filename) do |node|
|
563
555
|
yield node.to_ruby(**kwargs)
|
@@ -595,6 +587,7 @@ module Psych
|
|
595
587
|
self.safe_load f, filename: filename, **kwargs
|
596
588
|
}
|
597
589
|
end
|
590
|
+
class << self; alias load_file safe_load_file end
|
598
591
|
|
599
592
|
# :stopdoc:
|
600
593
|
def self.add_domain_type domain, type_tag, &block
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -19,8 +19,8 @@ dependencies:
|
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 0.1.7
|
21
21
|
name: jar-dependencies
|
22
|
-
prerelease: false
|
23
22
|
type: :runtime
|
23
|
+
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
@@ -137,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements:
|
140
|
-
- jar org.yaml:snakeyaml, 1.
|
141
|
-
rubygems_version: 3.
|
140
|
+
- jar org.yaml:snakeyaml, 1.28
|
141
|
+
rubygems_version: 3.0.6
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Psych is a YAML parser and emitter
|