psych 2.0.12 → 5.2.3

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 (115) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +24 -0
  3. data/{ext/psych/yaml/LICENSE → LICENSE} +9 -7
  4. data/README.md +80 -0
  5. data/ext/psych/depend +14 -0
  6. data/ext/psych/extconf.rb +43 -28
  7. data/ext/psych/psych.c +6 -4
  8. data/ext/psych/psych.h +0 -3
  9. data/ext/psych/psych_emitter.c +165 -132
  10. data/ext/psych/psych_parser.c +298 -331
  11. data/ext/psych/psych_to_ruby.c +0 -5
  12. data/ext/psych/psych_yaml_tree.c +0 -13
  13. data/lib/psych/class_loader.rb +11 -8
  14. data/lib/psych/coder.rb +1 -0
  15. data/lib/psych/core_ext.rb +3 -19
  16. data/lib/psych/exception.rb +17 -2
  17. data/lib/psych/handler.rb +8 -2
  18. data/lib/psych/handlers/document_stream.rb +2 -1
  19. data/lib/psych/handlers/recorder.rb +2 -1
  20. data/lib/psych/json/ruby_events.rb +1 -0
  21. data/lib/psych/json/stream.rb +3 -2
  22. data/lib/psych/json/tree_builder.rb +2 -1
  23. data/lib/psych/json/yaml_events.rb +1 -0
  24. data/lib/psych/nodes/alias.rb +3 -0
  25. data/lib/psych/nodes/document.rb +3 -0
  26. data/lib/psych/nodes/mapping.rb +3 -0
  27. data/lib/psych/nodes/node.rb +25 -5
  28. data/lib/psych/nodes/scalar.rb +4 -1
  29. data/lib/psych/nodes/sequence.rb +3 -0
  30. data/lib/psych/nodes/stream.rb +3 -0
  31. data/lib/psych/nodes.rb +8 -7
  32. data/lib/psych/omap.rb +1 -0
  33. data/lib/psych/parser.rb +14 -0
  34. data/lib/psych/scalar_scanner.rb +41 -49
  35. data/lib/psych/set.rb +1 -0
  36. data/lib/psych/stream.rb +1 -0
  37. data/lib/psych/streaming.rb +1 -0
  38. data/lib/psych/syntax_error.rb +2 -1
  39. data/lib/psych/tree_builder.rb +48 -7
  40. data/lib/psych/versions.rb +10 -0
  41. data/lib/psych/visitors/depth_first.rb +1 -0
  42. data/lib/psych/visitors/emitter.rb +1 -0
  43. data/lib/psych/visitors/json_tree.rb +2 -1
  44. data/lib/psych/visitors/to_ruby.rb +64 -33
  45. data/lib/psych/visitors/visitor.rb +18 -3
  46. data/lib/psych/visitors/yaml_tree.rb +128 -149
  47. data/lib/psych/visitors.rb +7 -6
  48. data/lib/psych/y.rb +1 -0
  49. data/lib/psych.rb +360 -95
  50. metadata +36 -169
  51. data/.autotest +0 -18
  52. data/.gemtest +0 -0
  53. data/.travis.yml +0 -11
  54. data/CHANGELOG.rdoc +0 -562
  55. data/Manifest.txt +0 -112
  56. data/README.rdoc +0 -71
  57. data/Rakefile +0 -74
  58. data/ext/psych/yaml/api.c +0 -1415
  59. data/ext/psych/yaml/config.h +0 -10
  60. data/ext/psych/yaml/dumper.c +0 -394
  61. data/ext/psych/yaml/emitter.c +0 -2329
  62. data/ext/psych/yaml/loader.c +0 -459
  63. data/ext/psych/yaml/parser.c +0 -1370
  64. data/ext/psych/yaml/reader.c +0 -469
  65. data/ext/psych/yaml/scanner.c +0 -3583
  66. data/ext/psych/yaml/writer.c +0 -141
  67. data/ext/psych/yaml/yaml.h +0 -1971
  68. data/ext/psych/yaml/yaml_private.h +0 -664
  69. data/lib/psych/deprecated.rb +0 -85
  70. data/test/psych/handlers/test_recorder.rb +0 -25
  71. data/test/psych/helper.rb +0 -114
  72. data/test/psych/json/test_stream.rb +0 -109
  73. data/test/psych/nodes/test_enumerable.rb +0 -43
  74. data/test/psych/test_alias_and_anchor.rb +0 -96
  75. data/test/psych/test_array.rb +0 -57
  76. data/test/psych/test_boolean.rb +0 -36
  77. data/test/psych/test_class.rb +0 -36
  78. data/test/psych/test_coder.rb +0 -184
  79. data/test/psych/test_date_time.rb +0 -38
  80. data/test/psych/test_deprecated.rb +0 -214
  81. data/test/psych/test_document.rb +0 -46
  82. data/test/psych/test_emitter.rb +0 -93
  83. data/test/psych/test_encoding.rb +0 -259
  84. data/test/psych/test_exception.rb +0 -157
  85. data/test/psych/test_hash.rb +0 -94
  86. data/test/psych/test_json_tree.rb +0 -65
  87. data/test/psych/test_marshalable.rb +0 -54
  88. data/test/psych/test_merge_keys.rb +0 -180
  89. data/test/psych/test_nil.rb +0 -18
  90. data/test/psych/test_null.rb +0 -19
  91. data/test/psych/test_numeric.rb +0 -45
  92. data/test/psych/test_object.rb +0 -44
  93. data/test/psych/test_object_references.rb +0 -71
  94. data/test/psych/test_omap.rb +0 -75
  95. data/test/psych/test_parser.rb +0 -339
  96. data/test/psych/test_psych.rb +0 -168
  97. data/test/psych/test_safe_load.rb +0 -97
  98. data/test/psych/test_scalar.rb +0 -11
  99. data/test/psych/test_scalar_scanner.rb +0 -106
  100. data/test/psych/test_serialize_subclasses.rb +0 -38
  101. data/test/psych/test_set.rb +0 -49
  102. data/test/psych/test_stream.rb +0 -93
  103. data/test/psych/test_string.rb +0 -226
  104. data/test/psych/test_struct.rb +0 -49
  105. data/test/psych/test_symbol.rb +0 -25
  106. data/test/psych/test_tainted.rb +0 -130
  107. data/test/psych/test_to_yaml_properties.rb +0 -63
  108. data/test/psych/test_tree_builder.rb +0 -79
  109. data/test/psych/test_yaml.rb +0 -1288
  110. data/test/psych/test_yamldbm.rb +0 -193
  111. data/test/psych/test_yamlstore.rb +0 -85
  112. data/test/psych/visitors/test_depth_first.rb +0 -49
  113. data/test/psych/visitors/test_emitter.rb +0 -144
  114. data/test/psych/visitors/test_to_ruby.rb +0 -326
  115. data/test/psych/visitors/test_yaml_tree.rb +0 -173
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 38ed899f0b22c57d8a653dfb84f54a92d9c51ccd
4
- data.tar.gz: b9fe79097035b8594dff79dacb4c85e55451be5f
2
+ SHA256:
3
+ metadata.gz: e8c48b70d7c4ff53b1d536997a6e63173cb7e123e3f6e70f82c5de8596d93c4c
4
+ data.tar.gz: c49d610314f1628a1e84267010dcfac5a076276eac2cad8dbbba9079ede9e08f
5
5
  SHA512:
6
- metadata.gz: 705e8c7667b4a841aab3a868a3a77cb5e55eb0e6a3d76c1169eba8244ab8b5307c83f85d5fa546f4fdbbdf62ee1a82d2336a30a17443556875ffa8b29fd60bfc
7
- data.tar.gz: 76f6c273cd9a0570fc64c1f0e789f907cb3ceeeabe6764549713a59fbbf06d83953afa4fcb53b6ca9527c724778b459b4bfac3310eb6e8ebe342b15e8589678e
6
+ metadata.gz: 2d3d710995bfd6eb317994dd13024e5e3fd2967dbd379a1d510f86f7517177d2cc5e292a7d3b14c999071cc35ce625715ee3549fab90ce966567ba6e91f2475c
7
+ data.tar.gz: f1570e565d5dd8c9e5984155dfbc1418a594aaa871fab7b7fabe62f05bc0a3e72ab141dd9f39c09689f8f4949a5c6e58fa9b1ca99c26db3552b0c9866a6032ad
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,24 @@
1
+ ## How to contribute to Psych
2
+
3
+ Full details [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute)
4
+
5
+ #### **Did you find a bug?**
6
+
7
+ * **Do not open an issue if the bug is a security vulnerability
8
+ in Psych**, instead refer to our [security policy](https://www.ruby-lang.org/en/security/) and email [here](security@ruby-lang.org).
9
+
10
+ * **Ensure the bug was not already reported** by searching on ruby-core, the ruby github repo and on Psych's github repo. More info [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReport)
11
+
12
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://bugs.ruby-lang.org/). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
13
+
14
+ #### **Did you write a patch that fixes a bug?**
15
+
16
+ * Open a new GitHub pull request with the patch for small fixes. Anything larger look [here](https://bugs.ruby-lang.org/projects/ruby/wiki/HowToContribute); submit a Feature.
17
+
18
+ * Ensure you clearly describe the problem and solution. Include the relevant ticket/issue number if applicable.
19
+
20
+ Psych is a volunteer effort. We encourage you to pitch in and [join the team](https://github.com/ruby/psych/contributors)!
21
+
22
+ Thanks! :heart: :heart: :heart:
23
+
24
+ The Psych Team
@@ -1,11 +1,13 @@
1
- Copyright (c) 2006 Kirill Simonov
1
+ MIT License
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- this software and associated documentation files (the "Software"), to deal in
5
- the Software without restriction, including without limitation the rights to
6
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
- of the Software, and to permit persons to whom the Software is furnished to do
8
- so, subject to the following conditions:
3
+ Copyright (c) 2009 Aaron Patterson, et al.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
9
11
 
10
12
  The above copyright notice and this permission notice shall be included in all
11
13
  copies or substantial portions of the Software.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # Psych
2
+
3
+ * https://github.com/ruby/psych
4
+ * https://docs.ruby-lang.org/en/master/Psych.html
5
+
6
+ ## Description
7
+
8
+ Psych is a YAML parser and emitter. Psych leverages
9
+ [libyaml](https://pyyaml.org/wiki/LibYAML) for its YAML parsing and emitting
10
+ capabilities. In addition to wrapping libyaml, Psych also knows how to
11
+ serialize and de-serialize most Ruby objects to and from the YAML format.
12
+
13
+ ## Examples
14
+
15
+ ```ruby
16
+ # Safely load YAML in to a Ruby object
17
+ Psych.safe_load('--- foo') # => 'foo'
18
+
19
+ # Emit YAML from a Ruby object
20
+ Psych.dump("foo") # => "--- foo\n...\n"
21
+ ```
22
+
23
+ ## Dependencies
24
+
25
+ * libyaml
26
+
27
+ ## Installation
28
+
29
+ Psych has been included with MRI since 1.9.2, and is the default YAML parser
30
+ in 1.9.3.
31
+
32
+ If you want a newer gem release of Psych, you can use RubyGems:
33
+
34
+ ```bash
35
+ gem install psych
36
+ ```
37
+
38
+ Psych supported the static build with specific version of libyaml sources. You can build psych with libyaml-0.2.5 like this.
39
+
40
+ ```bash
41
+ gem install psych -- --with-libyaml-source-dir=/path/to/libyaml-0.2.5
42
+ ```
43
+
44
+ In order to use the gem release in your app, and not the stdlib version,
45
+ you'll need the following:
46
+
47
+ ```ruby
48
+ gem 'psych'
49
+ require 'psych'
50
+ ```
51
+
52
+ Or if you use Bundler add this to your `Gemfile`:
53
+
54
+ ```ruby
55
+ gem 'psych'
56
+ ```
57
+
58
+ JRuby ships with a pure Java implementation of Psych.
59
+
60
+ ## License
61
+
62
+ Copyright 2009 Aaron Patterson, et al.
63
+
64
+ Permission is hereby granted, free of charge, to any person obtaining a copy
65
+ of this software and associated documentation files (the 'Software'), to deal
66
+ in the Software without restriction, including without limitation the rights
67
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
68
+ copies of the Software, and to permit persons to whom the Software is
69
+ furnished to do so, subject to the following conditions:
70
+
71
+ The above copyright notice and this permission notice shall be included in all
72
+ copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
76
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
77
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
78
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
79
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
80
+ SOFTWARE.
data/ext/psych/depend CHANGED
@@ -1,3 +1,17 @@
1
+ $(TARGET_SO): $(LIBYAML)
2
+
3
+ libyaml $(LIBYAML):
4
+ cd libyaml && $(MAKE)
5
+ $(AR) $(ARFLAGS) $(LIBYAML) $(LIBYAML_OBJDIR)/*.$(OBJEXT)
6
+ $(RANLIB) $(LIBYAML)
7
+
8
+ clean-so::
9
+ -cd libyaml && $(MAKE) clean
10
+
11
+ distclean-so::
12
+ -cd libyaml && $(MAKE) distclean
13
+ -$(Q)$(RMDIRS) libyaml/* libyaml
14
+
1
15
  $(OBJS): $(HDRS) $(ruby_headers) \
2
16
  $(hdrdir)/ruby/encoding.h \
3
17
  $(hdrdir)/ruby/oniguruma.h
data/ext/psych/extconf.rb CHANGED
@@ -1,38 +1,53 @@
1
1
  # -*- coding: us-ascii -*-
2
+ # frozen_string_literal: true
2
3
  require 'mkmf'
3
- require 'fileutils'
4
4
 
5
- # :stopdoc:
6
-
7
- dir_config 'libyaml'
8
-
9
- if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
10
- # Embed libyaml since we could not find it.
11
-
12
- $VPATH << "$(srcdir)/yaml"
13
- $INCFLAGS << " -I$(srcdir)/yaml"
14
-
15
- $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}
5
+ if $mswin or $mingw or $cygwin
6
+ $CPPFLAGS << " -DYAML_DECLARE_STATIC"
7
+ end
16
8
 
17
- if have_macro("_WIN32")
18
- $CPPFLAGS << " -DYAML_DECLARE_STATIC -DHAVE_CONFIG_H"
9
+ yaml_source = with_config("libyaml-source-dir")
10
+ if yaml_source
11
+ yaml_source = yaml_source.gsub(/\$\((\w+)\)|\$\{(\w+)\}/) {ENV[$1||$2]}
12
+ yaml_source = yaml_source.chomp("/")
13
+ yaml_configure = "#{File.expand_path(yaml_source)}/configure"
14
+ unless File.exist?(yaml_configure)
15
+ raise "Configure script not found in #{yaml_source.quote}"
19
16
  end
20
17
 
21
- have_header 'dlfcn.h'
22
- have_header 'inttypes.h'
23
- have_header 'memory.h'
24
- have_header 'stdint.h'
25
- have_header 'stdlib.h'
26
- have_header 'strings.h'
27
- have_header 'string.h'
28
- have_header 'sys/stat.h'
29
- have_header 'sys/types.h'
30
- have_header 'unistd.h'
31
-
32
- find_header 'yaml.h'
33
- have_header 'config.h'
18
+ puts("Configuring libyaml source in #{yaml_source.quote}")
19
+ yaml = "libyaml"
20
+ Dir.mkdir(yaml) unless File.directory?(yaml)
21
+ shared = $enable_shared || !$static
22
+ args = [
23
+ yaml_configure,
24
+ "--enable-#{shared ? 'shared' : 'static'}",
25
+ "--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-').sub(/arm64/, 'arm')}",
26
+ "CC=#{RbConfig::CONFIG['CC']}",
27
+ *(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
28
+ ]
29
+ puts(args.quote.join(' '))
30
+ unless system(*args, chdir: yaml)
31
+ raise "failed to configure libyaml"
32
+ end
33
+ inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
34
+ $INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
35
+ puts("INCFLAGS=#$INCFLAGS")
36
+ libyaml = "libyaml.#$LIBEXT"
37
+ $cleanfiles << libyaml
38
+ $LOCAL_LIBS.prepend("$(LIBYAML) ")
39
+ else # default to pre-installed libyaml
40
+ pkg_config('yaml-0.1')
41
+ dir_config('libyaml')
42
+ find_header('yaml.h') or abort "yaml.h not found"
43
+ find_library('yaml', 'yaml_get_version') or abort "libyaml not found"
34
44
  end
35
45
 
36
- create_makefile 'psych'
46
+ create_makefile 'psych' do |mk|
47
+ mk << "LIBYAML = #{libyaml}".strip << "\n"
48
+ mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
49
+ mk << "OBJEXT = #$OBJEXT"
50
+ mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
51
+ end
37
52
 
38
53
  # :startdoc:
data/ext/psych/psych.c CHANGED
@@ -11,9 +11,9 @@ static VALUE libyaml_version(VALUE module)
11
11
 
12
12
  yaml_get_version(&major, &minor, &patch);
13
13
 
14
- list[0] = INT2NUM((long)major);
15
- list[1] = INT2NUM((long)minor);
16
- list[2] = INT2NUM((long)patch);
14
+ list[0] = INT2NUM(major);
15
+ list[1] = INT2NUM(minor);
16
+ list[2] = INT2NUM(patch);
17
17
 
18
18
  return rb_ary_new4((long)3, list);
19
19
  }
@@ -22,6 +22,9 @@ VALUE mPsych;
22
22
 
23
23
  void Init_psych(void)
24
24
  {
25
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
26
+ RB_EXT_RACTOR_SAFE(true);
27
+ #endif
25
28
  mPsych = rb_define_module("Psych");
26
29
 
27
30
  rb_define_singleton_method(mPsych, "libyaml_version", libyaml_version, 0);
@@ -31,4 +34,3 @@ void Init_psych(void)
31
34
  Init_psych_to_ruby();
32
35
  Init_psych_yaml_tree();
33
36
  }
34
- /* vim: set noet sws=4 sw=4: */
data/ext/psych/psych.h CHANGED
@@ -2,10 +2,7 @@
2
2
  #define PSYCH_H
3
3
 
4
4
  #include <ruby.h>
5
-
6
- #ifdef HAVE_RUBY_ENCODING_H
7
5
  #include <ruby/encoding.h>
8
- #endif
9
6
 
10
7
  #include <yaml.h>
11
8