psych 4.0.6-java → 5.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: e9f42a29eed9ab87717ca14e50f27e94e287823b0557748a320cc981622589b8
4
- data.tar.gz: f2b6bd6ae5d9d36b4c3646e46d922b422f7b422ed6573af33d185b4688924b66
3
+ metadata.gz: 001a97fe892ca5932b978910a510ffc5c36aef259ddb0d7401911f6b4cfcbd90
4
+ data.tar.gz: 7cee10c46efb74ed46e0452c04c17889d958841de1acffe3be5e510f06f4ebd7
5
5
  SHA512:
6
- metadata.gz: 8f5cbdc18603acb58933a59f9fe47af3f33166ab6422c75cae056c9ac2ce14d26855f479efcd4db91f8470103b60e03144989220ea37e21aa25fb5810f2002e9
7
- data.tar.gz: 63b22e07d7c7df12f9e449fa71c7426225c6628da18493604180064280137793d5046c4a9803e9912a5673c8d19c67e739dcfbc0510fd20faa2353bace6599d0
6
+ metadata.gz: 8261903c1caed6f5021088c7c4560732a311a543565816f37273461066d2d835a714f7eb03399ba2f5211ddf74bbbc5f3b482043c636a7edcaf325d579e0a832
7
+ data.tar.gz: abc5036d8987090e91abcdda8dc6ad1fd73072b378f7a49f8d5bb5f3b7454a687d67351ae1260b031ccf093c4ba2cf91ca5cebe7e631bd8e709b319f77d8e277
@@ -108,13 +108,6 @@ public class PsychParser extends RubyObject {
108
108
  super(runtime, klass);
109
109
  }
110
110
 
111
- @JRubyMethod
112
- public IRubyObject parse(ThreadContext context, IRubyObject yaml) {
113
- Ruby runtime = context.runtime;
114
-
115
- return parse(context, yaml, runtime.getNil());
116
- }
117
-
118
111
  private IRubyObject stringOrNilFor(ThreadContext context, String value, boolean tainted) {
119
112
  if (value == null) return context.nil;
120
113
 
@@ -192,8 +185,8 @@ public class PsychParser extends RubyObject {
192
185
  }
193
186
  }
194
187
 
195
- @JRubyMethod
196
- public IRubyObject parse(ThreadContext context, IRubyObject yaml, IRubyObject path) {
188
+ @JRubyMethod(name = "_native_parse")
189
+ public IRubyObject parse(ThreadContext context, IRubyObject handler, IRubyObject yaml, IRubyObject path) {
197
190
  Ruby runtime = context.runtime;
198
191
  boolean tainted = yaml.isTaint() || yaml instanceof RubyIO;
199
192
 
@@ -204,8 +197,6 @@ public class PsychParser extends RubyObject {
204
197
  path = yaml.callMethod(context, "path");
205
198
  }
206
199
 
207
- IRubyObject handler = getInstanceVariable("@handler");
208
-
209
200
  while (true) {
210
201
  event = parser.getEvent();
211
202
 
data/ext/psych/depend CHANGED
@@ -1,4 +1,16 @@
1
- $(OBJS): $(YAML_H)
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
2
14
 
3
15
  $(OBJS): $(HDRS) $(ruby_headers) \
4
16
  $(hdrdir)/ruby/encoding.h \
data/ext/psych/extconf.rb CHANGED
@@ -1,43 +1,53 @@
1
1
  # -*- coding: us-ascii -*-
2
2
  # frozen_string_literal: true
3
3
  require 'mkmf'
4
- require 'fileutils'
5
4
 
6
- # :stopdoc:
7
-
8
- dir_config 'libyaml'
9
-
10
- if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
11
- # Embed libyaml since we could not find it.
12
-
13
- $VPATH << "$(srcdir)/yaml"
14
- $INCFLAGS << " -I$(srcdir)/yaml"
15
-
16
- $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}.sort
5
+ if $mswin or $mingw or $cygwin
6
+ $CPPFLAGS << " -DYAML_DECLARE_STATIC"
7
+ end
17
8
 
18
- header = 'yaml/yaml.h'
19
- header = "{$(VPATH)}#{header}" if $nmake
20
- if have_macro("_WIN32")
21
- $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}"
22
16
  end
23
17
 
24
- have_header 'dlfcn.h'
25
- have_header 'inttypes.h'
26
- have_header 'memory.h'
27
- have_header 'stdint.h'
28
- have_header 'stdlib.h'
29
- have_header 'strings.h'
30
- have_header 'string.h'
31
- have_header 'sys/stat.h'
32
- have_header 'sys/types.h'
33
- have_header 'unistd.h'
34
-
35
- find_header 'yaml.h'
36
- 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-/, '-')}",
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"
37
44
  end
38
45
 
39
46
  create_makefile 'psych' do |mk|
40
- mk << "YAML_H = #{header}".strip << "\n"
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"
41
51
  end
42
52
 
43
53
  # :startdoc:
@@ -79,21 +79,25 @@ static VALUE allocate(VALUE klass)
79
79
 
80
80
  static VALUE make_exception(yaml_parser_t * parser, VALUE path)
81
81
  {
82
- size_t line, column;
83
- VALUE ePsychSyntaxError;
82
+ if (parser->error == YAML_MEMORY_ERROR) {
83
+ return rb_eNoMemError;
84
+ } else {
85
+ size_t line, column;
86
+ VALUE ePsychSyntaxError;
84
87
 
85
- line = parser->context_mark.line + 1;
86
- column = parser->context_mark.column + 1;
88
+ line = parser->context_mark.line + 1;
89
+ column = parser->context_mark.column + 1;
87
90
 
88
- ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
91
+ ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
89
92
 
90
- return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
91
- path,
92
- SIZET2NUM(line),
93
- SIZET2NUM(column),
94
- SIZET2NUM(parser->problem_offset),
95
- parser->problem ? rb_usascii_str_new2(parser->problem) : Qnil,
96
- parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
93
+ return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
94
+ path,
95
+ SIZET2NUM(line),
96
+ SIZET2NUM(column),
97
+ SIZET2NUM(parser->problem_offset),
98
+ parser->problem ? rb_usascii_str_new2(parser->problem) : Qnil,
99
+ parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
100
+ }
97
101
  }
98
102
 
99
103
  static VALUE transcode_string(VALUE src, int * parser_encoding)
@@ -241,18 +245,8 @@ static VALUE protected_event_location(VALUE pointer)
241
245
  return rb_funcall3(args[0], id_event_location, 4, args + 1);
242
246
  }
243
247
 
244
- /*
245
- * call-seq:
246
- * parser.parse(yaml)
247
- *
248
- * Parse the YAML document contained in +yaml+. Events will be called on
249
- * the handler set on the parser instance.
250
- *
251
- * See Psych::Parser and Psych::Parser#handler
252
- */
253
- static VALUE parse(int argc, VALUE *argv, VALUE self)
248
+ static VALUE parse(VALUE self, VALUE handler, VALUE yaml, VALUE path)
254
249
  {
255
- VALUE yaml, path;
256
250
  yaml_parser_t * parser;
257
251
  yaml_event_t event;
258
252
  int done = 0;
@@ -260,14 +254,6 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
260
254
  int parser_encoding = YAML_ANY_ENCODING;
261
255
  int encoding = rb_utf8_encindex();
262
256
  rb_encoding * internal_enc = rb_default_internal_encoding();
263
- VALUE handler = rb_iv_get(self, "@handler");
264
-
265
- if (rb_scan_args(argc, argv, "11", &yaml, &path) == 1) {
266
- if(rb_respond_to(yaml, id_path))
267
- path = rb_funcall(yaml, id_path, 0);
268
- else
269
- path = rb_str_new2("<unknown>");
270
- }
271
257
 
272
258
  TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser);
273
259
 
@@ -293,7 +279,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
293
279
  VALUE event_args[5];
294
280
  VALUE start_line, start_column, end_line, end_column;
295
281
 
296
- if(!yaml_parser_parse(parser, &event)) {
282
+ if(parser->error || !yaml_parser_parse(parser, &event)) {
297
283
  VALUE exception;
298
284
 
299
285
  exception = make_exception(parser, path);
@@ -558,7 +544,7 @@ void Init_psych_parser(void)
558
544
 
559
545
  rb_require("psych/syntax_error");
560
546
 
561
- rb_define_method(cPsychParser, "parse", parse, -1);
547
+ rb_define_private_method(cPsychParser, "_native_parse", parse, 3);
562
548
  rb_define_method(cPsychParser, "mark", mark, 0);
563
549
 
564
550
  id_read = rb_intern("read");
@@ -6,6 +6,20 @@ module Psych
6
6
  class BadAlias < Exception
7
7
  end
8
8
 
9
+ # Subclasses `BadAlias` for backwards compatibility
10
+ class AliasesNotEnabled < BadAlias
11
+ def initialize
12
+ super "Alias parsing was not enabled. To enable it, pass `aliases: true` to `Psych::load` or `Psych::safe_load`."
13
+ end
14
+ end
15
+
16
+ # Subclasses `BadAlias` for backwards compatibility
17
+ class AnchorNotDefined < BadAlias
18
+ def initialize anchor_name
19
+ super "An alias referenced an unknown anchor: #{anchor_name}"
20
+ end
21
+ end
22
+
9
23
  class DisallowedClass < Exception
10
24
  def initialize action, klass_name
11
25
  super "Tried to #{action} unspecified class: #{klass_name}"
data/lib/psych/parser.rb CHANGED
@@ -48,5 +48,18 @@ module Psych
48
48
  @handler = handler
49
49
  @external_encoding = ANY
50
50
  end
51
+
52
+ ###
53
+ # call-seq:
54
+ # parser.parse(yaml)
55
+ #
56
+ # Parse the YAML document contained in +yaml+. Events will be called on
57
+ # the handler set on the parser instance.
58
+ #
59
+ # See Psych::Parser and Psych::Parser#handler
60
+
61
+ def parse yaml, path = yaml.respond_to?(:path) ? yaml.path : "<unknown>"
62
+ _native_parse @handler, yaml, path
63
+ end
51
64
  end
52
65
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '4.0.6'
5
+ VERSION = '5.0.0'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
8
  DEFAULT_SNAKEYAML_VERSION = '1.33'.freeze
@@ -325,7 +325,7 @@ module Psych
325
325
  end
326
326
 
327
327
  def visit_Psych_Nodes_Alias o
328
- @st.fetch(o.anchor) { raise BadAlias, "Unknown alias: #{o.anchor}" }
328
+ @st.fetch(o.anchor) { raise AnchorNotDefined, o.anchor }
329
329
  end
330
330
 
331
331
  private
@@ -429,7 +429,7 @@ module Psych
429
429
 
430
430
  class NoAliasRuby < ToRuby
431
431
  def visit_Psych_Nodes_Alias o
432
- raise BadAlias, "Unknown alias: #{o.anchor}"
432
+ raise AliasesNotEnabled
433
433
  end
434
434
  end
435
435
  end
data/lib/psych.rb CHANGED
@@ -307,7 +307,7 @@ module Psych
307
307
  # A Psych::DisallowedClass exception will be raised if the yaml contains a
308
308
  # class that isn't in the +permitted_classes+ list.
309
309
  #
310
- # A Psych::BadAlias exception will be raised if the yaml contains aliases
310
+ # A Psych::AliasesNotEnabled exception will be raised if the yaml contains aliases
311
311
  # but the +aliases+ keyword argument is set to false.
312
312
  #
313
313
  # +filename+ will be used in the exception message if any exception is raised
data/psych.gemspec CHANGED
@@ -27,9 +27,6 @@ DESCRIPTION
27
27
  "bin/setup", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
28
28
  "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
29
29
  "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h",
30
- "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c",
31
- "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c",
32
- "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h",
33
30
  "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/exception.rb",
34
31
  "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb",
35
32
  "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb",
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: 4.0.6
4
+ version: 5.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: 2022-12-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
@@ -64,18 +64,6 @@ files:
64
64
  - ext/psych/psych_to_ruby.h
65
65
  - ext/psych/psych_yaml_tree.c
66
66
  - ext/psych/psych_yaml_tree.h
67
- - ext/psych/yaml/LICENSE
68
- - ext/psych/yaml/api.c
69
- - ext/psych/yaml/config.h
70
- - ext/psych/yaml/dumper.c
71
- - ext/psych/yaml/emitter.c
72
- - ext/psych/yaml/loader.c
73
- - ext/psych/yaml/parser.c
74
- - ext/psych/yaml/reader.c
75
- - ext/psych/yaml/scanner.c
76
- - ext/psych/yaml/writer.c
77
- - ext/psych/yaml/yaml.h
78
- - ext/psych/yaml/yaml_private.h
79
67
  - lib/psych.jar
80
68
  - lib/psych.rb
81
69
  - lib/psych/class_loader.rb
@@ -138,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
126
  version: '0'
139
127
  requirements:
140
128
  - jar org.yaml:snakeyaml, 1.33
141
- rubygems_version: 3.2.29
129
+ rubygems_version: 3.3.25
142
130
  signing_key:
143
131
  specification_version: 4
144
132
  summary: Psych is a YAML parser and emitter
@@ -1,19 +0,0 @@
1
- Copyright (c) 2006 Kirill Simonov
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:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.