psych 3.2.0-java → 3.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/psych.rb +27 -10
- data/lib/psych/versions.rb +1 -1
- data/psych.gemspec +0 -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: 41080752c6cb77f7ba4d02b6ecbe2ad1aa2c09d65a8517f382b058b0c6403eea
|
4
|
+
data.tar.gz: 811715a35a69851bc6bafece15c79044a90fa1f41f4244edf9f849f46bae6a42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24f57e51181b8e2e37fe56521ff187259af539d1fd5857ffa07702e398ae1fdf2a7675bc528249afb860e6bab6eee77aa0fcbe89d75b762cd3a1895e6e44abcd
|
7
|
+
data.tar.gz: 63f862bae8f2abf207bc0b27e4b473820188b4e4ae0f1e0d774a76c641dad97c83fa29021a237e40ecfb1ece05560843936630618a005bd530954fde216fdf2b
|
data/README.md
CHANGED
@@ -12,8 +12,8 @@ serialize and de-serialize most Ruby objects to and from the YAML format.
|
|
12
12
|
## Examples
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
#
|
16
|
-
Psych.
|
15
|
+
# Safely load YAML in to a Ruby object
|
16
|
+
Psych.safe_load('--- foo') # => 'foo'
|
17
17
|
|
18
18
|
# Emit YAML from a Ruby object
|
19
19
|
Psych.dump("foo") # => "--- foo\n...\n"
|
data/lib/psych.rb
CHANGED
@@ -74,12 +74,15 @@ require 'psych/class_loader'
|
|
74
74
|
#
|
75
75
|
# ==== Reading from a string
|
76
76
|
#
|
77
|
-
# Psych.
|
78
|
-
# Psych.
|
77
|
+
# Psych.safe_load("--- a") # => 'a'
|
78
|
+
# Psych.safe_load("---\n - a\n - b") # => ['a', 'b']
|
79
|
+
# # From a trusted string:
|
80
|
+
# Psych.load("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n") # => 0..42
|
79
81
|
#
|
80
82
|
# ==== Reading from a file
|
81
83
|
#
|
82
|
-
# Psych.
|
84
|
+
# Psych.safe_load_file("data.yml", permitted_classes: [Date])
|
85
|
+
# Psych.load_file("trusted_database.yml")
|
83
86
|
#
|
84
87
|
# ==== Exception handling
|
85
88
|
#
|
@@ -276,8 +279,7 @@ module Psych
|
|
276
279
|
|
277
280
|
result = parse(yaml, filename: filename)
|
278
281
|
return fallback unless result
|
279
|
-
result
|
280
|
-
result
|
282
|
+
result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
|
281
283
|
end
|
282
284
|
|
283
285
|
###
|
@@ -549,7 +551,7 @@ module Psych
|
|
549
551
|
# end
|
550
552
|
# list # => ['foo', 'bar']
|
551
553
|
#
|
552
|
-
def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
|
554
|
+
def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: [], **kwargs
|
553
555
|
if legacy_filename != NOT_GIVEN
|
554
556
|
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
|
555
557
|
filename = legacy_filename
|
@@ -557,10 +559,10 @@ module Psych
|
|
557
559
|
|
558
560
|
result = if block_given?
|
559
561
|
parse_stream(yaml, filename: filename) do |node|
|
560
|
-
yield node.to_ruby
|
562
|
+
yield node.to_ruby(**kwargs)
|
561
563
|
end
|
562
564
|
else
|
563
|
-
parse_stream(yaml, filename: filename).children.map(
|
565
|
+
parse_stream(yaml, filename: filename).children.map { |node| node.to_ruby(**kwargs) }
|
564
566
|
end
|
565
567
|
|
566
568
|
return fallback if result.is_a?(Array) && result.empty?
|
@@ -571,9 +573,24 @@ module Psych
|
|
571
573
|
# Load the document contained in +filename+. Returns the yaml contained in
|
572
574
|
# +filename+ as a Ruby object, or if the file is empty, it returns
|
573
575
|
# the specified +fallback+ return value, which defaults to +false+.
|
574
|
-
|
576
|
+
#
|
577
|
+
# NOTE: This method *should not* be used to parse untrusted documents, such as
|
578
|
+
# YAML documents that are supplied via user input. Instead, please use the
|
579
|
+
# safe_load_file method.
|
580
|
+
def self.load_file filename, **kwargs
|
581
|
+
File.open(filename, 'r:bom|utf-8') { |f|
|
582
|
+
self.load f, filename: filename, **kwargs
|
583
|
+
}
|
584
|
+
end
|
585
|
+
|
586
|
+
###
|
587
|
+
# Safely loads the document contained in +filename+. Returns the yaml contained in
|
588
|
+
# +filename+ as a Ruby object, or if the file is empty, it returns
|
589
|
+
# the specified +fallback+ return value, which defaults to +false+.
|
590
|
+
# See safe_load for options.
|
591
|
+
def self.safe_load_file filename, **kwargs
|
575
592
|
File.open(filename, 'r:bom|utf-8') { |f|
|
576
|
-
self.
|
593
|
+
self.safe_load f, filename: filename, **kwargs
|
577
594
|
}
|
578
595
|
end
|
579
596
|
|
data/lib/psych/versions.rb
CHANGED
data/psych.gemspec
CHANGED
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: 3.2.
|
4
|
+
version: 3.2.1
|
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: 2020-
|
13
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|