psych 3.3.2 → 5.2.2

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +24 -0
  3. data/README.md +6 -5
  4. data/ext/psych/depend +13 -1
  5. data/ext/psych/extconf.rb +40 -30
  6. data/ext/psych/psych.c +1 -1
  7. data/ext/psych/psych_emitter.c +155 -120
  8. data/ext/psych/psych_parser.c +267 -281
  9. data/lib/psych/class_loader.rb +5 -5
  10. data/lib/psych/core_ext.rb +1 -1
  11. data/lib/psych/exception.rb +16 -2
  12. data/lib/psych/handlers/document_stream.rb +1 -1
  13. data/lib/psych/handlers/recorder.rb +1 -1
  14. data/lib/psych/json/stream.rb +2 -2
  15. data/lib/psych/json/tree_builder.rb +1 -1
  16. data/lib/psych/nodes/node.rb +5 -5
  17. data/lib/psych/nodes.rb +7 -7
  18. data/lib/psych/parser.rb +13 -0
  19. data/lib/psych/scalar_scanner.rb +24 -19
  20. data/lib/psych/syntax_error.rb +1 -1
  21. data/lib/psych/tree_builder.rb +3 -3
  22. data/lib/psych/versions.rb +2 -2
  23. data/lib/psych/visitors/json_tree.rb +1 -1
  24. data/lib/psych/visitors/to_ruby.rb +12 -11
  25. data/lib/psych/visitors/yaml_tree.rb +71 -27
  26. data/lib/psych/visitors.rb +6 -6
  27. data/lib/psych.rb +204 -106
  28. metadata +37 -25
  29. data/.gitignore +0 -16
  30. data/Gemfile +0 -9
  31. data/Mavenfile +0 -7
  32. data/Rakefile +0 -41
  33. data/bin/console +0 -7
  34. data/bin/setup +0 -6
  35. data/ext/psych/yaml/LICENSE +0 -19
  36. data/ext/psych/yaml/api.c +0 -1393
  37. data/ext/psych/yaml/config.h +0 -80
  38. data/ext/psych/yaml/dumper.c +0 -394
  39. data/ext/psych/yaml/emitter.c +0 -2358
  40. data/ext/psych/yaml/loader.c +0 -544
  41. data/ext/psych/yaml/parser.c +0 -1375
  42. data/ext/psych/yaml/reader.c +0 -469
  43. data/ext/psych/yaml/scanner.c +0 -3598
  44. data/ext/psych/yaml/writer.c +0 -141
  45. data/ext/psych/yaml/yaml.h +0 -1985
  46. data/ext/psych/yaml/yaml_private.h +0 -688
  47. data/psych.gemspec +0 -67
data/lib/psych.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
- require 'psych/versions'
2
+ require 'date'
3
+
4
+ require_relative 'psych/versions'
3
5
  case RUBY_ENGINE
4
6
  when 'jruby'
5
- require 'psych_jars'
7
+ require_relative 'psych_jars'
6
8
  if JRuby::Util.respond_to?(:load_ext)
7
9
  JRuby::Util.load_ext('org.jruby.ext.psych.PsychLibrary')
8
10
  else
@@ -12,28 +14,28 @@ when 'jruby'
12
14
  else
13
15
  require 'psych.so'
14
16
  end
15
- require 'psych/nodes'
16
- require 'psych/streaming'
17
- require 'psych/visitors'
18
- require 'psych/handler'
19
- require 'psych/tree_builder'
20
- require 'psych/parser'
21
- require 'psych/omap'
22
- require 'psych/set'
23
- require 'psych/coder'
24
- require 'psych/core_ext'
25
- require 'psych/stream'
26
- require 'psych/json/tree_builder'
27
- require 'psych/json/stream'
28
- require 'psych/handlers/document_stream'
29
- require 'psych/class_loader'
17
+ require_relative 'psych/nodes'
18
+ require_relative 'psych/streaming'
19
+ require_relative 'psych/visitors'
20
+ require_relative 'psych/handler'
21
+ require_relative 'psych/tree_builder'
22
+ require_relative 'psych/parser'
23
+ require_relative 'psych/omap'
24
+ require_relative 'psych/set'
25
+ require_relative 'psych/coder'
26
+ require_relative 'psych/core_ext'
27
+ require_relative 'psych/stream'
28
+ require_relative 'psych/json/tree_builder'
29
+ require_relative 'psych/json/stream'
30
+ require_relative 'psych/handlers/document_stream'
31
+ require_relative 'psych/class_loader'
30
32
 
31
33
  ###
32
34
  # = Overview
33
35
  #
34
36
  # Psych is a YAML parser and emitter.
35
37
  # Psych leverages libyaml [Home page: https://pyyaml.org/wiki/LibYAML]
36
- # or [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing
38
+ # or [git repo: https://github.com/yaml/libyaml] for its YAML parsing
37
39
  # and emitting capabilities. In addition to wrapping libyaml, Psych also
38
40
  # knows how to serialize and de-serialize most Ruby objects to and from
39
41
  # the YAML format.
@@ -84,7 +86,7 @@ require 'psych/class_loader'
84
86
  # Psych.safe_load_file("data.yml", permitted_classes: [Date])
85
87
  # Psych.load_file("trusted_database.yml")
86
88
  #
87
- # ==== Exception handling
89
+ # ==== \Exception handling
88
90
  #
89
91
  # begin
90
92
  # # The second argument changes only the exception contents
@@ -148,7 +150,7 @@ require 'psych/class_loader'
148
150
  # # Returns Psych::Nodes::Document
149
151
  # Psych.parse_file('database.yml')
150
152
  #
151
- # ==== Exception handling
153
+ # ==== \Exception handling
152
154
  #
153
155
  # begin
154
156
  # # The second argument changes only the exception contents
@@ -234,9 +236,6 @@ require 'psych/class_loader'
234
236
  module Psych
235
237
  # The version of libyaml Psych is using
236
238
  LIBYAML_VERSION = Psych.libyaml_version.join('.').freeze
237
- # Deprecation guard
238
- NOT_GIVEN = Object.new.freeze
239
- private_constant :NOT_GIVEN
240
239
 
241
240
  ###
242
241
  # Load +yaml+ in to a Ruby data structure. If multiple documents are
@@ -249,11 +248,11 @@ module Psych
249
248
  #
250
249
  # Example:
251
250
  #
252
- # Psych.load("--- a") # => 'a'
253
- # Psych.load("---\n - a\n - b") # => ['a', 'b']
251
+ # Psych.unsafe_load("--- a") # => 'a'
252
+ # Psych.unsafe_load("---\n - a\n - b") # => ['a', 'b']
254
253
  #
255
254
  # begin
256
- # Psych.load("--- `", filename: "file.txt")
255
+ # Psych.unsafe_load("--- `", filename: "file.txt")
257
256
  # rescue Psych::SyntaxError => ex
258
257
  # ex.file # => 'file.txt'
259
258
  # ex.message # => "(file.txt): found character that cannot start any token"
@@ -262,26 +261,20 @@ module Psych
262
261
  # When the optional +symbolize_names+ keyword argument is set to a
263
262
  # true value, returns symbols for keys in Hash objects (default: strings).
264
263
  #
265
- # Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
266
- # Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
264
+ # Psych.unsafe_load("---\n foo: bar") # => {"foo"=>"bar"}
265
+ # Psych.unsafe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
267
266
  #
268
267
  # Raises a TypeError when `yaml` parameter is NilClass
269
268
  #
270
269
  # NOTE: This method *should not* be used to parse untrusted documents, such as
271
270
  # YAML documents that are supplied via user input. Instead, please use the
272
- # safe_load method.
271
+ # load method or the safe_load method.
273
272
  #
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
-
273
+ def self.unsafe_load yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false, strict_integer: false
280
274
  result = parse(yaml, filename: filename)
281
275
  return fallback unless result
282
- result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
276
+ result.to_ruby(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer)
283
277
  end
284
- class << self; alias :load :unsafe_load; end
285
278
 
286
279
  ###
287
280
  # Safely load the yaml string in +yaml+. By default, only the following
@@ -290,7 +283,8 @@ module Psych
290
283
  # * TrueClass
291
284
  # * FalseClass
292
285
  # * NilClass
293
- # * Numeric
286
+ # * Integer
287
+ # * Float
294
288
  # * String
295
289
  # * Array
296
290
  # * Hash
@@ -315,7 +309,7 @@ module Psych
315
309
  # A Psych::DisallowedClass exception will be raised if the yaml contains a
316
310
  # class that isn't in the +permitted_classes+ list.
317
311
  #
318
- # A Psych::BadAlias exception will be raised if the yaml contains aliases
312
+ # A Psych::AliasesNotEnabled exception will be raised if the yaml contains aliases
319
313
  # but the +aliases+ keyword argument is set to false.
320
314
  #
321
315
  # +filename+ will be used in the exception message if any exception is raised
@@ -327,33 +321,13 @@ module Psych
327
321
  # Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
328
322
  # Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
329
323
  #
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
-
324
+ def self.safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false
351
325
  result = parse(yaml, filename: filename)
352
326
  return fallback unless result
353
327
 
354
328
  class_loader = ClassLoader::Restricted.new(permitted_classes.map(&:to_s),
355
329
  permitted_symbols.map(&:to_s))
356
- scanner = ScalarScanner.new class_loader
330
+ scanner = ScalarScanner.new class_loader, strict_integer: strict_integer
357
331
  visitor = if aliases
358
332
  Visitors::ToRuby.new scanner, class_loader, symbolize_names: symbolize_names, freeze: freeze
359
333
  else
@@ -363,6 +337,47 @@ module Psych
363
337
  result
364
338
  end
365
339
 
340
+ ###
341
+ # Load +yaml+ in to a Ruby data structure. If multiple documents are
342
+ # provided, the object contained in the first document will be returned.
343
+ # +filename+ will be used in the exception message if any exception
344
+ # is raised while parsing. If +yaml+ is empty, it returns
345
+ # the specified +fallback+ return value, which defaults to +nil+.
346
+ #
347
+ # Raises a Psych::SyntaxError when a YAML syntax error is detected.
348
+ #
349
+ # Example:
350
+ #
351
+ # Psych.load("--- a") # => 'a'
352
+ # Psych.load("---\n - a\n - b") # => ['a', 'b']
353
+ #
354
+ # begin
355
+ # Psych.load("--- `", filename: "file.txt")
356
+ # rescue Psych::SyntaxError => ex
357
+ # ex.file # => 'file.txt'
358
+ # ex.message # => "(file.txt): found character that cannot start any token"
359
+ # end
360
+ #
361
+ # When the optional +symbolize_names+ keyword argument is set to a
362
+ # true value, returns symbols for keys in Hash objects (default: strings).
363
+ #
364
+ # Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
365
+ # Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
366
+ #
367
+ # Raises a TypeError when `yaml` parameter is NilClass. This method is
368
+ # similar to `safe_load` except that `Symbol` objects are allowed by default.
369
+ #
370
+ def self.load yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false
371
+ safe_load yaml, permitted_classes: permitted_classes,
372
+ permitted_symbols: permitted_symbols,
373
+ aliases: aliases,
374
+ filename: filename,
375
+ fallback: fallback,
376
+ symbolize_names: symbolize_names,
377
+ freeze: freeze,
378
+ strict_integer: strict_integer
379
+ end
380
+
366
381
  ###
367
382
  # Parse a YAML string in +yaml+. Returns the Psych::Nodes::Document.
368
383
  # +filename+ is used in the exception message if a Psych::SyntaxError is
@@ -382,22 +397,12 @@ module Psych
382
397
  # end
383
398
  #
384
399
  # 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
-
400
+ def self.parse yaml, filename: nil
391
401
  parse_stream(yaml, filename: filename) do |node|
392
402
  return node
393
403
  end
394
404
 
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
405
+ false
401
406
  end
402
407
 
403
408
  ###
@@ -446,12 +451,7 @@ module Psych
446
451
  # Raises a TypeError when NilClass is passed.
447
452
  #
448
453
  # 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
-
454
+ def self.parse_stream yaml, filename: nil, &block
455
455
  if block_given?
456
456
  parser = Psych::Parser.new(Handlers::DocumentStream.new(&block))
457
457
  parser.parse yaml, filename
@@ -481,6 +481,7 @@ module Psych
481
481
  #
482
482
  # Default: <tt>2</tt>.
483
483
  # [<tt>:line_width</tt>] Max character to wrap line at.
484
+ # For unlimited line width use <tt>-1</tt>.
484
485
  #
485
486
  # Default: <tt>0</tt> (meaning "wrap at 81").
486
487
  # [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
@@ -491,6 +492,10 @@ module Psych
491
492
  #
492
493
  # Default: <tt>false</tt>.
493
494
  #
495
+ # [<tt>:stringify_names</tt>] Dump symbol keys in Hash objects as string.
496
+ #
497
+ # Default: <tt>false</tt>.
498
+ #
494
499
  # Example:
495
500
  #
496
501
  # # Dump an array, get back a YAML string
@@ -504,6 +509,9 @@ module Psych
504
509
  #
505
510
  # # Dump an array to an IO with indentation set
506
511
  # Psych.dump(['a', ['b']], StringIO.new, indentation: 3)
512
+ #
513
+ # # Dump hash with symbol keys as string
514
+ # Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n"
507
515
  def self.dump o, io = nil, options = {}
508
516
  if Hash === io
509
517
  options = io
@@ -515,6 +523,87 @@ module Psych
515
523
  visitor.tree.yaml io, options
516
524
  end
517
525
 
526
+ ###
527
+ # call-seq:
528
+ # Psych.safe_dump(o) -> string of yaml
529
+ # Psych.safe_dump(o, options) -> string of yaml
530
+ # Psych.safe_dump(o, io) -> io object passed in
531
+ # Psych.safe_dump(o, io, options) -> io object passed in
532
+ #
533
+ # Safely dump Ruby object +o+ to a YAML string. Optional +options+ may be passed in
534
+ # to control the output format. If an IO object is passed in, the YAML will
535
+ # be dumped to that IO object. By default, only the following
536
+ # classes are allowed to be serialized:
537
+ #
538
+ # * TrueClass
539
+ # * FalseClass
540
+ # * NilClass
541
+ # * Integer
542
+ # * Float
543
+ # * String
544
+ # * Array
545
+ # * Hash
546
+ #
547
+ # Arbitrary classes can be allowed by adding those classes to the +permitted_classes+
548
+ # keyword argument. They are additive. For example, to allow Date serialization:
549
+ #
550
+ # Psych.safe_dump(yaml, permitted_classes: [Date])
551
+ #
552
+ # Now the Date class can be dumped in addition to the classes listed above.
553
+ #
554
+ # A Psych::DisallowedClass exception will be raised if the object contains a
555
+ # class that isn't in the +permitted_classes+ list.
556
+ #
557
+ # Currently supported options are:
558
+ #
559
+ # [<tt>:indentation</tt>] Number of space characters used to indent.
560
+ # Acceptable value should be in <tt>0..9</tt> range,
561
+ # otherwise option is ignored.
562
+ #
563
+ # Default: <tt>2</tt>.
564
+ # [<tt>:line_width</tt>] Max character to wrap line at.
565
+ # For unlimited line width use <tt>-1</tt>.
566
+ #
567
+ # Default: <tt>0</tt> (meaning "wrap at 81").
568
+ # [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
569
+ # strictly formal).
570
+ #
571
+ # Default: <tt>false</tt>.
572
+ # [<tt>:header</tt>] Write <tt>%YAML [version]</tt> at the beginning of document.
573
+ #
574
+ # Default: <tt>false</tt>.
575
+ #
576
+ # [<tt>:stringify_names</tt>] Dump symbol keys in Hash objects as string.
577
+ #
578
+ # Default: <tt>false</tt>.
579
+ #
580
+ # Example:
581
+ #
582
+ # # Dump an array, get back a YAML string
583
+ # Psych.safe_dump(['a', 'b']) # => "---\n- a\n- b\n"
584
+ #
585
+ # # Dump an array to an IO object
586
+ # Psych.safe_dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>
587
+ #
588
+ # # Dump an array with indentation set
589
+ # Psych.safe_dump(['a', ['b']], indentation: 3) # => "---\n- a\n- - b\n"
590
+ #
591
+ # # Dump an array to an IO with indentation set
592
+ # Psych.safe_dump(['a', ['b']], StringIO.new, indentation: 3)
593
+ #
594
+ # # Dump hash with symbol keys as string
595
+ # Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n"
596
+ def self.safe_dump o, io = nil, options = {}
597
+ if Hash === io
598
+ options = io
599
+ io = nil
600
+ end
601
+
602
+ visitor = Psych::Visitors::RestrictedYAMLTree.create options
603
+ visitor << o
604
+ visitor.tree.yaml io, options
605
+ end
606
+
518
607
  ###
519
608
  # Dump a list of objects as separate documents to a document stream.
520
609
  #
@@ -552,12 +641,7 @@ module Psych
552
641
  # end
553
642
  # list # => ['foo', 'bar']
554
643
  #
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
-
644
+ def self.load_stream yaml, filename: nil, fallback: [], **kwargs
561
645
  result = if block_given?
562
646
  parse_stream(yaml, filename: filename) do |node|
563
647
  yield node.to_ruby(**kwargs)
@@ -583,12 +667,11 @@ module Psych
583
667
  self.unsafe_load f, filename: filename, **kwargs
584
668
  }
585
669
  end
586
- class << self; alias :load_file :unsafe_load_file; end
587
670
 
588
671
  ###
589
672
  # Safely loads the document contained in +filename+. Returns the yaml contained in
590
673
  # +filename+ as a Ruby object, or if the file is empty, it returns
591
- # the specified +fallback+ return value, which defaults to +false+.
674
+ # the specified +fallback+ return value, which defaults to +nil+.
592
675
  # See safe_load for options.
593
676
  def self.safe_load_file filename, **kwargs
594
677
  File.open(filename, 'r:bom|utf-8') { |f|
@@ -596,6 +679,17 @@ module Psych
596
679
  }
597
680
  end
598
681
 
682
+ ###
683
+ # Loads the document contained in +filename+. Returns the yaml contained in
684
+ # +filename+ as a Ruby object, or if the file is empty, it returns
685
+ # the specified +fallback+ return value, which defaults to +nil+.
686
+ # See load for options.
687
+ def self.load_file filename, **kwargs
688
+ File.open(filename, 'r:bom|utf-8') { |f|
689
+ self.load f, filename: filename, **kwargs
690
+ }
691
+ end
692
+
599
693
  # :stopdoc:
600
694
  def self.add_domain_type domain, type_tag, &block
601
695
  key = ['tag', domain, type_tag].join ':'
@@ -618,26 +712,8 @@ module Psych
618
712
  dump_tags[klass] = tag
619
713
  end
620
714
 
621
- # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
622
- def self.warn_with_uplevel(message, uplevel: 1)
623
- at = parse_caller(caller[uplevel]).join(':')
624
- warn "#{at}: #{message}"
625
- end
626
-
627
- def self.parse_caller(at)
628
- if /^(.+?):(\d+)(?::in `.*')?/ =~ at
629
- file = $1
630
- line = $2.to_i
631
- [file, line]
632
- end
633
- end
634
- private_class_method :warn_with_uplevel, :parse_caller
635
-
636
715
  class << self
637
716
  if defined?(Ractor)
638
- require 'forwardable'
639
- extend Forwardable
640
-
641
717
  class Config
642
718
  attr_accessor :load_tags, :dump_tags, :domain_types
643
719
  def initialize
@@ -651,7 +727,29 @@ module Psych
651
727
  Ractor.current[:PsychConfig] ||= Config.new
652
728
  end
653
729
 
654
- def_delegators :config, :load_tags, :dump_tags, :domain_types, :load_tags=, :dump_tags=, :domain_types=
730
+ def load_tags
731
+ config.load_tags
732
+ end
733
+
734
+ def dump_tags
735
+ config.dump_tags
736
+ end
737
+
738
+ def domain_types
739
+ config.domain_types
740
+ end
741
+
742
+ def load_tags=(value)
743
+ config.load_tags = value
744
+ end
745
+
746
+ def dump_tags=(value)
747
+ config.dump_tags = value
748
+ end
749
+
750
+ def domain_types=(value)
751
+ config.domain_types = value
752
+ end
655
753
  else
656
754
  attr_accessor :load_tags
657
755
  attr_accessor :dump_tags
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: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -10,8 +10,36 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-13 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2024-12-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: stringio
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: date
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
15
43
  description: |
16
44
  Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
17
45
  for its YAML parsing and emitting capabilities. In addition to wrapping libyaml,
@@ -26,14 +54,9 @@ extensions:
26
54
  extra_rdoc_files:
27
55
  - README.md
28
56
  files:
29
- - ".gitignore"
30
- - Gemfile
57
+ - CONTRIBUTING.md
31
58
  - LICENSE
32
- - Mavenfile
33
59
  - README.md
34
- - Rakefile
35
- - bin/console
36
- - bin/setup
37
60
  - ext/psych/depend
38
61
  - ext/psych/extconf.rb
39
62
  - ext/psych/psych.c
@@ -46,18 +69,6 @@ files:
46
69
  - ext/psych/psych_to_ruby.h
47
70
  - ext/psych/psych_yaml_tree.c
48
71
  - ext/psych/psych_yaml_tree.h
49
- - ext/psych/yaml/LICENSE
50
- - ext/psych/yaml/api.c
51
- - ext/psych/yaml/config.h
52
- - ext/psych/yaml/dumper.c
53
- - ext/psych/yaml/emitter.c
54
- - ext/psych/yaml/loader.c
55
- - ext/psych/yaml/parser.c
56
- - ext/psych/yaml/reader.c
57
- - ext/psych/yaml/scanner.c
58
- - ext/psych/yaml/writer.c
59
- - ext/psych/yaml/yaml.h
60
- - ext/psych/yaml/yaml_private.h
61
72
  - lib/psych.rb
62
73
  - lib/psych/class_loader.rb
63
74
  - lib/psych/coder.rb
@@ -95,11 +106,12 @@ files:
95
106
  - lib/psych/visitors/visitor.rb
96
107
  - lib/psych/visitors/yaml_tree.rb
97
108
  - lib/psych/y.rb
98
- - psych.gemspec
99
109
  homepage: https://github.com/ruby/psych
100
110
  licenses:
101
111
  - MIT
102
- metadata: {}
112
+ metadata:
113
+ msys2_mingw_dependencies: libyaml
114
+ changelog_uri: https://github.com/ruby/psych/releases
103
115
  post_install_message:
104
116
  rdoc_options:
105
117
  - "--main"
@@ -110,14 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
122
  requirements:
111
123
  - - ">="
112
124
  - !ruby/object:Gem::Version
113
- version: 2.4.0
125
+ version: 2.5.0
114
126
  required_rubygems_version: !ruby/object:Gem::Requirement
115
127
  requirements:
116
128
  - - ">="
117
129
  - !ruby/object:Gem::Version
118
130
  version: '0'
119
131
  requirements: []
120
- rubygems_version: 3.3.0.dev
132
+ rubygems_version: 3.5.11
121
133
  signing_key:
122
134
  specification_version: 4
123
135
  summary: Psych is a YAML parser and emitter
data/.gitignore DELETED
@@ -1,16 +0,0 @@
1
- *.swp
2
- *.bundle
3
- *.so
4
- *.jar
5
- *.class
6
- .mvn
7
- /.bundle/
8
- /.yardoc
9
- /Gemfile.lock
10
- /_yardoc/
11
- /coverage/
12
- /doc/
13
- /pkg/
14
- /spec/reports/
15
- /tmp/
16
- /vendor
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem 'rake-compiler', ">= 0.4.1"
7
- gem 'test-unit'
8
- gem 'ruby-maven', :platforms => :jruby
9
- end
data/Mavenfile DELETED
@@ -1,7 +0,0 @@
1
- #-*- mode: ruby -*-
2
-
3
- jar 'org.yaml:snakeyaml:${snakeyaml.version}'
4
-
5
- plugin :dependency, '2.8', :outputFile => 'pkg/classpath'
6
-
7
- # vim: syntax=Ruby
data/Rakefile DELETED
@@ -1,41 +0,0 @@
1
- require "bundler"
2
- Bundler::GemHelper.install_tasks
3
-
4
- require "rake/testtask"
5
- Rake::TestTask.new(:test) do |t|
6
- t.libs << "test/lib" << "test"
7
- t.ruby_opts << "-rhelper"
8
- t.test_files = FileList['test/**/test_*.rb']
9
- t.verbose = true
10
- t.warning = true
11
- end
12
-
13
- if RUBY_PLATFORM =~ /java/
14
- require 'rake/javaextensiontask'
15
- Rake::JavaExtensionTask.new("psych") do |ext|
16
- require 'maven/ruby/maven'
17
- # force load of versions to overwrite constants with values from repo.
18
- load './lib/psych/versions.rb'
19
- # uses Mavenfile to write classpath into pkg/classpath
20
- # and tell maven via system properties the snakeyaml version
21
- # this is basically the same as running from the commandline:
22
- # rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
23
- Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')
24
- ext.source_version = '1.7'
25
- ext.target_version = '1.7'
26
- ext.classpath = File.read('pkg/classpath')
27
- ext.ext_dir = 'ext/java'
28
- end
29
- else
30
- require 'rake/extensiontask'
31
- Rake::ExtensionTask.new("psych")
32
- end
33
-
34
- task :sync_tool do
35
- require 'fileutils'
36
- FileUtils.cp "../ruby/tool/lib/test/unit/core_assertions.rb", "./test/lib"
37
- FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
38
- FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
39
- end
40
-
41
- task :default => [:compile, :test]
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "psych"
5
-
6
- require "irb"
7
- IRB.start