psych 3.2.0 → 3.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/README.md +2 -2
- data/lib/psych.rb +27 -10
- data/lib/psych/versions.rb +1 -1
- data/psych.gemspec +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ed655876a483c54babe4a2262f347f87833bcbdd2bb611712935b97f0aa13d
|
4
|
+
data.tar.gz: 7659d9c4c3dc37cc6dc87c82da975d41ac37156cea5baa5361727550110af5f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e23390eaa06a588135456d1e4f826d04526301a3512acb4f34efc911d97a93f126129ada2a0cd312f8374333106402d10aa7f357417f370ddb0dd5cf2b6ce224
|
7
|
+
data.tar.gz: 36d08044e2022d89dcea7f6e589167c6f61bd0a9e24010715e03dba117835d6f4c652c52feb139f602317618aed7a267a8f2a0c95147194a518051c99c24daa5
|
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: ruby
|
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
|
description: |
|
16
16
|
Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.2.0
|
120
|
+
rubygems_version: 3.2.0
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Psych is a YAML parser and emitter
|