psych 3.0.0.beta4 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/ext/psych/psych_parser.c +3 -3
- data/lib/psych.rb +26 -7
- data/lib/psych/versions.rb +1 -1
- data/lib/psych/visitors/yaml_tree.rb +1 -1
- data/psych.gemspec +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15f0e452b66e7f48f1a879686e22126cdacd1a78367ccb4f8b478f8b5137ff06
|
4
|
+
data.tar.gz: 520db0e8d7f25630c313484cb17cb69df3c68178de00100ec266fd11646d0d31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4335f8ce7d2cbb4ad12d65e0649185e384c64aebf8a78924fd87929979922ba44a95af0dc545c07b9074dc5320d47ff82d47464100bb8cff3ac89a48cd0f34e0
|
7
|
+
data.tar.gz: 3fc3d9273d4e441299936fd021bce4ac94a69a2762daf7fc57b9f51af726f289cf360526544a531d550872a660df728503af17e2590897adaf243cda57b67a57
|
data/.travis.yml
CHANGED
data/ext/psych/psych_parser.c
CHANGED
@@ -292,6 +292,9 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
|
|
292
292
|
}
|
293
293
|
|
294
294
|
while(!done) {
|
295
|
+
VALUE event_args[5];
|
296
|
+
VALUE start_line, start_column, end_line, end_column;
|
297
|
+
|
295
298
|
if(!yaml_parser_parse(parser, &event)) {
|
296
299
|
VALUE exception;
|
297
300
|
|
@@ -302,9 +305,6 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
|
|
302
305
|
rb_exc_raise(exception);
|
303
306
|
}
|
304
307
|
|
305
|
-
VALUE event_args[5];
|
306
|
-
VALUE start_line, start_column, end_line, end_column;
|
307
|
-
|
308
308
|
start_line = INT2NUM((long)event.start_mark.line);
|
309
309
|
start_column = INT2NUM((long)event.start_mark.column);
|
310
310
|
end_line = INT2NUM((long)event.end_mark.line);
|
data/lib/psych.rb
CHANGED
@@ -252,8 +252,15 @@ module Psych
|
|
252
252
|
# ex.file # => 'file.txt'
|
253
253
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
254
254
|
# end
|
255
|
-
|
256
|
-
|
255
|
+
#
|
256
|
+
# When the optional +symbolize_names+ keyword argument is set to a
|
257
|
+
# true value, returns symbols for keys in Hash objects (default: strings).
|
258
|
+
#
|
259
|
+
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
|
260
|
+
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
261
|
+
#
|
262
|
+
def self.load yaml, filename = nil, fallback: false, symbolize_names: false
|
263
|
+
result = parse(yaml, filename, fallback: fallback)
|
257
264
|
result = result.to_ruby if result
|
258
265
|
symbolize_names!(result) if symbolize_names
|
259
266
|
result
|
@@ -293,7 +300,17 @@ module Psych
|
|
293
300
|
#
|
294
301
|
# A Psych::BadAlias exception will be raised if the yaml contains aliases
|
295
302
|
# but the +aliases+ parameter is set to false.
|
296
|
-
|
303
|
+
#
|
304
|
+
# +filename+ will be used in the exception message if any exception is raised
|
305
|
+
# while parsing.
|
306
|
+
#
|
307
|
+
# When the optional +symbolize_names+ keyword argument is set to a
|
308
|
+
# true value, returns symbols for keys in Hash objects (default: strings).
|
309
|
+
#
|
310
|
+
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
311
|
+
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
312
|
+
#
|
313
|
+
def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases = false, filename = nil, symbolize_names: false
|
297
314
|
result = parse(yaml, filename)
|
298
315
|
return unless result
|
299
316
|
|
@@ -305,7 +322,9 @@ module Psych
|
|
305
322
|
else
|
306
323
|
visitor = Visitors::NoAliasRuby.new scanner, class_loader
|
307
324
|
end
|
308
|
-
visitor.accept result
|
325
|
+
result = visitor.accept result
|
326
|
+
symbolize_names!(result) if symbolize_names
|
327
|
+
result
|
309
328
|
end
|
310
329
|
|
311
330
|
###
|
@@ -327,7 +346,7 @@ module Psych
|
|
327
346
|
# end
|
328
347
|
#
|
329
348
|
# See Psych::Nodes for more information about YAML AST.
|
330
|
-
def self.parse yaml, filename = nil, fallback
|
349
|
+
def self.parse yaml, filename = nil, fallback: false
|
331
350
|
parse_stream(yaml, filename) do |node|
|
332
351
|
return node
|
333
352
|
end
|
@@ -474,9 +493,9 @@ module Psych
|
|
474
493
|
# Load the document contained in +filename+. Returns the yaml contained in
|
475
494
|
# +filename+ as a Ruby object, or if the file is empty, it returns
|
476
495
|
# the specified default return value, which defaults to an empty Hash
|
477
|
-
def self.load_file filename, fallback
|
496
|
+
def self.load_file filename, fallback: false
|
478
497
|
File.open(filename, 'r:bom|utf-8') { |f|
|
479
|
-
self.load f, filename, FALLBACK.new(fallback)
|
498
|
+
self.load f, filename, fallback: FALLBACK.new(fallback)
|
480
499
|
}
|
481
500
|
end
|
482
501
|
|
data/lib/psych/versions.rb
CHANGED
@@ -304,7 +304,7 @@ module Psych
|
|
304
304
|
quote = false
|
305
305
|
elsif @line_width && o.length > @line_width
|
306
306
|
style = Nodes::Scalar::FOLDED
|
307
|
-
elsif o =~ /^[^[:word:]][^"]*$/
|
307
|
+
elsif o =~ /^[^[:word:]][^"]*$/
|
308
308
|
style = Nodes::Scalar::DOUBLE_QUOTED
|
309
309
|
elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/ =~ o
|
310
310
|
style = Nodes::Scalar::SINGLE_QUOTED
|
data/psych.gemspec
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "psych"
|
6
|
-
s.version = "3.0.
|
6
|
+
s.version = "3.0.2"
|
7
7
|
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
|
8
8
|
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
|
9
|
-
s.date = "2017-
|
9
|
+
s.date = "2017-12-04"
|
10
10
|
s.summary = "Psych is a YAML parser and emitter"
|
11
11
|
s.description = <<-DESCRIPTION
|
12
12
|
Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
|
@@ -41,7 +41,7 @@ DESCRIPTION
|
|
41
41
|
s.rdoc_options = ["--main", "README.md"]
|
42
42
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md"]
|
43
43
|
|
44
|
-
s.required_ruby_version = Gem::Requirement.new(">=
|
44
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.2.2")
|
45
45
|
s.rubygems_version = "2.5.1"
|
46
46
|
s.required_rubygems_version = Gem::Requirement.new(">= 0")
|
47
47
|
|
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.0.
|
4
|
+
version: 3.0.2
|
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: 2017-
|
13
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake-compiler
|
@@ -155,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
155
|
requirements:
|
156
156
|
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
158
|
+
version: 2.2.2
|
159
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
161
|
- - ">="
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.7.
|
166
|
+
rubygems_version: 2.7.3
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Psych is a YAML parser and emitter
|