psych 3.3.4-java → 4.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e314c5613e0b86ac2a12afd58de21b4b2253bbce98c9f5059f193b07abbbe47
4
- data.tar.gz: 53031659a8f278e7003f36b3732401a4c63e7ec3d05f7a5302bb3610f7d0b18c
3
+ metadata.gz: 5149acda4b0d41732db12bc694d4e72b0f5a511b628389ec0add96cef04d3b23
4
+ data.tar.gz: 4706cd6d83b23b106bdf5b5ef5953cdb416992bfa5ae774bb5f57e2f5394c1c8
5
5
  SHA512:
6
- metadata.gz: 64ffd8d7ccacad0f5c934e0756343a131b07d245972e5e0d58526c8ea3e7b19d2259f89b19b8eeb123d0746da61e8373e91ecc3f7db73f9db25eba46e5a90310
7
- data.tar.gz: 949dccd16148d62ac4c7b3fc61ea16739470ad213c06070b9f93f71d5d595696e4e6d7e4b50755cdf6d04b31a580c07ea5283136a33d228ae8bc1fe466a86176
6
+ metadata.gz: 109458fa5a2da076004e322aa34f8b777be41d9dd3f51e27e4f6282e14896d84b8c9964f5a748803ba4873fbcf3857e72aa9993952997ea962c9104f9a4af969
7
+ data.tar.gz: cf2cb03494fade26c250914388b11ade2d529e81ddfa4bee119c9a5a149681239c6d9c81261f5ec247540a40a137a14e96fcaac4190b9db94ca0a92167410fe8
@@ -34,7 +34,7 @@ module Psych
34
34
 
35
35
  # Check for a String type, being careful not to get caught by hash keys, hex values, and
36
36
  # special floats (e.g., -.inf).
37
- if string.match?(%r{^[^\d.:-]?[[:alpha:]_\s!@#$%\^&*(){}<>|/\\~;=]+}) || string.match?(/\n/)
37
+ if string.match?(/^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/) || string.match?(/\n/)
38
38
  return string if string.length > 5
39
39
 
40
40
  if string.match?(/^[^ytonf~]/i)
@@ -57,7 +57,7 @@ module Psych
57
57
  elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
58
58
  require 'date'
59
59
  begin
60
- class_loader.date.strptime(string, '%F', Date::GREGORIAN)
60
+ class_loader.date.strptime(string, '%Y-%m-%d')
61
61
  rescue ArgumentError
62
62
  string
63
63
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '3.3.4'
5
+ VERSION = '4.0.0'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
- DEFAULT_SNAKEYAML_VERSION = '1.33'.freeze
8
+ DEFAULT_SNAKEYAML_VERSION = '1.28'.freeze
9
9
  end
10
10
  end
@@ -80,9 +80,7 @@ module Psych
80
80
  when "!ruby/object:DateTime"
81
81
  class_loader.date_time
82
82
  require 'date' unless defined? DateTime
83
- t = @ss.parse_time(o.value)
84
- DateTime.civil(*t.to_a[0, 6].reverse, Rational(t.utc_offset, 86400)) +
85
- (t.subsec/86400)
83
+ @ss.parse_time(o.value).to_datetime
86
84
  when '!ruby/encoding'
87
85
  ::Encoding.find o.value
88
86
  when "!ruby/object:Complex"
@@ -192,13 +192,12 @@ module Psych
192
192
  register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
193
193
  end
194
194
 
195
- def visit_Date o
196
- register o, visit_Integer(o.gregorian)
197
- end
198
-
199
195
  def visit_DateTime o
200
- t = o.italy
201
- formatted = format_time t, t.offset.zero?
196
+ formatted = if o.offset.zero?
197
+ o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
198
+ else
199
+ o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
200
+ end
202
201
  tag = '!ruby/object:DateTime'
203
202
  register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
204
203
  end
@@ -236,6 +235,7 @@ module Psych
236
235
  end
237
236
  alias :visit_TrueClass :visit_Integer
238
237
  alias :visit_FalseClass :visit_Integer
238
+ alias :visit_Date :visit_Integer
239
239
 
240
240
  def visit_Float o
241
241
  if o.nan?
@@ -480,8 +480,8 @@ module Psych
480
480
  @emitter.end_mapping
481
481
  end
482
482
 
483
- def format_time time, utc = time.utc?
484
- if utc
483
+ def format_time time
484
+ if time.utc?
485
485
  time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
486
486
  else
487
487
  time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
data/lib/psych.jar CHANGED
Binary file
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
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.4
4
+ version: 4.0.0
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: 2022-09-28 00:00:00.000000000 Z
13
+ date: 2021-05-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
@@ -19,8 +19,8 @@ dependencies:
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.1.7
21
21
  name: jar-dependencies
22
- prerelease: false
23
22
  type: :runtime
23
+ prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
@@ -137,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements:
140
- - jar org.yaml:snakeyaml, 1.33
141
- rubygems_version: 3.2.29
140
+ - jar org.yaml:snakeyaml, 1.28
141
+ rubygems_version: 3.0.6
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Psych is a YAML parser and emitter