psych 3.3.2-java → 4.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/psych.rb +53 -60
  3. data/lib/psych/versions.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f502010ef57ab680b8a273b17cb0c7bcf38cd9e3c9f4885323c8817933bbf7b
4
- data.tar.gz: 2be8f458c94bf961bb3c9681ced9ea2e00e67095e9ce0f4e062111a0b1e6bbaa
3
+ metadata.gz: 5149acda4b0d41732db12bc694d4e72b0f5a511b628389ec0add96cef04d3b23
4
+ data.tar.gz: 4706cd6d83b23b106bdf5b5ef5953cdb416992bfa5ae774bb5f57e2f5394c1c8
5
5
  SHA512:
6
- metadata.gz: 4af84db27ecb5c12a92c8f80b6078a639e75f11ce0284b68e57e4906e62893ffd7cfe77780e6729374d760e136b61c70709050c8aebce345b373ea3fbfd00f77
7
- data.tar.gz: afcf7ee1fac4892db0789448761d325d951904423d914e579a1b51740ae3bdb0c5de9b20590b11ed88aa56c03fff25bb16623b7771c45e9957dc8e07b716d81a
6
+ metadata.gz: 109458fa5a2da076004e322aa34f8b777be41d9dd3f51e27e4f6282e14896d84b8c9964f5a748803ba4873fbcf3857e72aa9993952997ea962c9104f9a4af969
7
+ data.tar.gz: cf2cb03494fade26c250914388b11ade2d529e81ddfa4bee119c9a5a149681239c6d9c81261f5ec247540a40a137a14e96fcaac4190b9db94ca0a92167410fe8
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.load("--- a") # => 'a'
253
- # Psych.load("---\n - a\n - b") # => ['a', 'b']
249
+ # Psych.unsafe_load("--- a") # => 'a'
250
+ # Psych.unsafe_load("---\n - a\n - b") # => ['a', 'b']
254
251
  #
255
252
  # begin
256
- # Psych.load("--- `", filename: "file.txt")
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.load("---\n foo: bar") # => {"foo"=>"bar"}
266
- # Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
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, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false, freeze: false
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, legacy_permitted_classes = NOT_GIVEN, legacy_permitted_symbols = NOT_GIVEN, legacy_aliases = NOT_GIVEN, legacy_filename = NOT_GIVEN, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false
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, legacy_filename = NOT_GIVEN, filename: nil, fallback: NOT_GIVEN
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
- if fallback != NOT_GIVEN
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, legacy_filename = NOT_GIVEN, filename: nil, &block
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, legacy_filename = NOT_GIVEN, filename: nil, fallback: [], **kwargs
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '3.3.2'
5
+ VERSION = '4.0.0'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
8
  DEFAULT_SNAKEYAML_VERSION = '1.28'.freeze
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.3.2
4
+ version: 4.0.0
5
5
  platform: java
6
6
  authors:
7
7
  - Aaron Patterson