psych 5.2.1 → 5.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 270858d5e7932bd2a8c72d6861566ebfef58a7c2bea4acd2635a3aa4246b89cc
4
- data.tar.gz: 20f230ccc6bc96cb1bb54fe77263b4545aad9a5028023fc6b2c13dc6e4934ca4
3
+ metadata.gz: 459c567be3d6ef6cb06cab52abb277a79f2f631da2944bd15622f23fdd3b1dec
4
+ data.tar.gz: 72aff05916df6027d69d9fe22562c5f5b700066f9d00670445450cdd2939ce4d
5
5
  SHA512:
6
- metadata.gz: dc1a496280c8d941f7d87924279dfc4e95b23046d0d7c5520fac4ff4c31eb6f2d4f0254bf73ea60f5a0974b8e03ad7005944ce569344908e0835691d1c5d7cba
7
- data.tar.gz: c0018b3e09a66ce9aff01c1d1546b2cae40f15ea2e47045ecccb5eedabdd60f5ca8f59f91eb1e3f5c6540e6dcf0c8b0b47d3518de75ac9ae4e0a6ad5b3c86b3e
6
+ metadata.gz: 87e6d5b1fa471069209207f4bca47d5b3158ce4d2909f18a497cb0b7b9b6d76e086553dc905e5b9fc92e5f620c1571db1db87531f8ba9fcbb2b685c12774d3df
7
+ data.tar.gz: d837ad140affbd97a8a6d4c6d7088d30f907cc0c5c7743367801b2fd8d2e8f0683f53a0e187541e6eee296b0c3fd5a69ad758b841e88548265e39a550eef29ef
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Psych
2
2
 
3
- * https://github.com/ruby/psych
4
- * https://docs.ruby-lang.org/en/master/Psych.html
3
+ * https://github.com/ruby/psych
4
+ * https://docs.ruby-lang.org/en/master/Psych.html
5
5
 
6
6
  ## Description
7
7
 
@@ -22,31 +22,38 @@ Psych.dump("foo") # => "--- foo\n...\n"
22
22
 
23
23
  ## Dependencies
24
24
 
25
- * libyaml
25
+ * libyaml
26
26
 
27
27
  ## Installation
28
28
 
29
29
  Psych has been included with MRI since 1.9.2, and is the default YAML parser
30
30
  in 1.9.3.
31
31
 
32
- If you want a newer gem release of Psych, you can use rubygems:
33
-
34
- gem install psych
32
+ If you want a newer gem release of Psych, you can use RubyGems:
35
33
 
34
+ ```bash
35
+ gem install psych
36
+ ```
36
37
 
37
38
  Psych supported the static build with specific version of libyaml sources. You can build psych with libyaml-0.2.5 like this.
38
39
 
39
- gem install psych -- --with-libyaml-source-dir=/path/to/libyaml-0.2.5
40
+ ```bash
41
+ gem install psych -- --with-libyaml-source-dir=/path/to/libyaml-0.2.5
42
+ ```
40
43
 
41
44
  In order to use the gem release in your app, and not the stdlib version,
42
45
  you'll need the following:
43
46
 
44
- gem 'psych'
45
- require 'psych'
47
+ ```ruby
48
+ gem 'psych'
49
+ require 'psych'
50
+ ```
46
51
 
47
52
  Or if you use Bundler add this to your `Gemfile`:
48
53
 
49
- gem 'psych'
54
+ ```ruby
55
+ gem 'psych'
56
+ ```
50
57
 
51
58
  JRuby ships with a pure Java implementation of Psych.
52
59
 
data/ext/psych/psych.c CHANGED
@@ -34,4 +34,3 @@ void Init_psych(void)
34
34
  Init_psych_to_ruby();
35
35
  Init_psych_yaml_tree();
36
36
  }
37
- /* vim: set noet sws=4 sw=4: */
@@ -304,11 +304,12 @@ static VALUE scalar(
304
304
  tag = rb_str_export_to_enc(tag, encoding);
305
305
  }
306
306
 
307
+ const char *value_ptr = StringValuePtr(value);
307
308
  yaml_scalar_event_initialize(
308
309
  &event,
309
310
  (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
310
311
  (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
311
- (yaml_char_t*)StringValuePtr(value),
312
+ (yaml_char_t*)value_ptr,
312
313
  (int)RSTRING_LEN(value),
313
314
  plain ? 1 : 0,
314
315
  quoted ? 1 : 0,
@@ -586,4 +587,3 @@ void Init_psych_emitter(void)
586
587
  id_indentation = rb_intern("indentation");
587
588
  id_canonical = rb_intern("canonical");
588
589
  }
589
- /* vim: set noet sws=4 sw=4: */
@@ -562,4 +562,3 @@ void Init_psych_parser(void)
562
562
  id_end_mapping = rb_intern("end_mapping");
563
563
  id_event_location = rb_intern("event_location");
564
564
  }
565
- /* vim: set noet sws=4 sw=4: */
@@ -36,4 +36,3 @@ void Init_psych_to_ruby(void)
36
36
  rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
37
37
  rb_define_private_method(class_loader, "path2class", path2class, 1);
38
38
  }
39
- /* vim: set noet sws=4 sw=4: */
@@ -9,4 +9,3 @@ void Init_psych_yaml_tree(void)
9
9
  VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
10
10
  cPsychVisitorsYamlTree = rb_define_class_under(visitors, "YAMLTree", visitor);
11
11
  }
12
- /* vim: set noet sws=4 sw=4: */
@@ -17,3 +17,17 @@ end
17
17
  if defined?(::IRB)
18
18
  require_relative 'y'
19
19
  end
20
+
21
+
22
+ # TODO: how best to check for builtin Set?
23
+ if defined?(::Set) && Object.const_source_location(:Set) == ["ruby", 0]
24
+ class Set
25
+ def encode_with(coder)
26
+ coder["hash"] = to_h
27
+ end
28
+
29
+ def init_with(coder)
30
+ replace(coder["hash"].keys)
31
+ end
32
+ end
33
+ end
@@ -55,7 +55,8 @@ module Psych
55
55
  #
56
56
  # See also Psych::Visitors::Emitter
57
57
  def yaml io = nil, options = {}
58
- require "stringio"
58
+ require "stringio" unless defined?(StringIO)
59
+
59
60
  real_io = io || StringIO.new(''.encode('utf-8'))
60
61
 
61
62
  Visitors::Emitter.new(real_io, options).accept self
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '5.2.1'
5
+ VERSION = '5.2.4'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
- DEFAULT_SNAKEYAML_VERSION = '2.7'.freeze
8
+ DEFAULT_SNAKEYAML_VERSION = '2.9'.freeze
9
9
  end
10
10
  end
@@ -189,7 +189,8 @@ module Psych
189
189
  end
190
190
 
191
191
  def visit_Date o
192
- register o, visit_Integer(o.gregorian)
192
+ formatted = format_date o
193
+ register o, @emitter.scalar(formatted, nil, nil, true, false, Nodes::Scalar::ANY)
193
194
  end
194
195
 
195
196
  def visit_DateTime o
@@ -486,6 +487,10 @@ module Psych
486
487
  end
487
488
  end
488
489
 
490
+ def format_date date
491
+ date.strftime("%Y-%m-%d")
492
+ end
493
+
489
494
  def register target, yaml_obj
490
495
  @st.register target, yaml_obj
491
496
  yaml_obj
data/lib/psych.rb CHANGED
@@ -86,7 +86,7 @@ require_relative 'psych/class_loader'
86
86
  # Psych.safe_load_file("data.yml", permitted_classes: [Date])
87
87
  # Psych.load_file("trusted_database.yml")
88
88
  #
89
- # ==== Exception handling
89
+ # ==== \Exception handling
90
90
  #
91
91
  # begin
92
92
  # # The second argument changes only the exception contents
@@ -150,7 +150,7 @@ require_relative 'psych/class_loader'
150
150
  # # Returns Psych::Nodes::Document
151
151
  # Psych.parse_file('database.yml')
152
152
  #
153
- # ==== Exception handling
153
+ # ==== \Exception handling
154
154
  #
155
155
  # begin
156
156
  # # The second argument changes only the exception contents
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psych
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  - SHIBATA Hiroshi
9
9
  - Charles Oliver Nutter
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-12-02 00:00:00.000000000 Z
13
+ date: 2025-05-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: stringio
@@ -112,7 +112,7 @@ licenses:
112
112
  metadata:
113
113
  msys2_mingw_dependencies: libyaml
114
114
  changelog_uri: https://github.com/ruby/psych/releases
115
- post_install_message:
115
+ post_install_message:
116
116
  rdoc_options:
117
117
  - "--main"
118
118
  - README.md
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubygems_version: 3.5.11
133
- signing_key:
133
+ signing_key:
134
134
  specification_version: 4
135
135
  summary: Psych is a YAML parser and emitter
136
136
  test_files: []