psych 5.1.0-java → 5.1.1-java
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 +4 -4
- data/CONTRIBUTING.md +24 -0
- data/ext/java/org/jruby/ext/psych/PsychParser.java +89 -80
- data/lib/psych/versions.rb +2 -2
- data/lib/psych.jar +0 -0
- data/lib/psych.rb +23 -19
- metadata +6 -12
- data/.gitignore +0 -16
- data/Gemfile +0 -9
- data/Mavenfile +0 -7
- data/Rakefile +0 -41
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/psych.gemspec +0 -67
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3ecd8fde6ca54e687dc27ddad89dee04ffaf1e751432b15197e9bc36bd3880d
|
|
4
|
+
data.tar.gz: 18d653fe1080e1aa8b3d882e5a2927526c112eece374d2d231e1295b672e3b3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28aa613c31c1f3dcefd42687af26e49981a08162545b673c7f5ba6cbc6aa59cf0b7851100fd37ff6492cb99ed54e20c9040321c8a2c8cff6be8aa335bc5c4f16
|
|
7
|
+
data.tar.gz: 9ea353b134a59478df9cf327840601d4fbff544fe1cf4f2bde68cf12d8ee82ef9291e179e170b9e48c4f5369e50c7519e4611fe5446ab57996a2c39578dc2166
|
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
|
|
@@ -37,15 +37,19 @@ import org.jruby.RubyArray;
|
|
|
37
37
|
import org.jruby.RubyBoolean;
|
|
38
38
|
import org.jruby.RubyClass;
|
|
39
39
|
import org.jruby.RubyEncoding;
|
|
40
|
+
import org.jruby.RubyException;
|
|
40
41
|
import org.jruby.RubyFixnum;
|
|
41
42
|
import org.jruby.RubyIO;
|
|
42
43
|
import org.jruby.RubyKernel;
|
|
43
44
|
import org.jruby.RubyModule;
|
|
45
|
+
import org.jruby.RubyNumeric;
|
|
44
46
|
import org.jruby.RubyObject;
|
|
45
47
|
import org.jruby.RubyString;
|
|
46
48
|
import org.jruby.anno.JRubyMethod;
|
|
49
|
+
import org.jruby.javasupport.JavaUtil;
|
|
47
50
|
import org.jruby.runtime.Block;
|
|
48
51
|
import org.jruby.runtime.Helpers;
|
|
52
|
+
import org.jruby.runtime.JavaSites;
|
|
49
53
|
import org.jruby.runtime.ThreadContext;
|
|
50
54
|
import org.jruby.runtime.builtin.IRubyObject;
|
|
51
55
|
import org.jruby.runtime.callsite.CachingCallSite;
|
|
@@ -96,42 +100,40 @@ import static org.jruby.runtime.Helpers.invoke;
|
|
|
96
100
|
public class PsychParser extends RubyObject {
|
|
97
101
|
|
|
98
102
|
public static final String JRUBY_CALL_SITES = "_jruby_call_sites";
|
|
103
|
+
public static final String ENCODING_ANY = "ANY";
|
|
104
|
+
public static final String ENCODING_UTF8 = "UTF8";
|
|
105
|
+
public static final String ENCODING_UTF16LE = "UTF16LE";
|
|
106
|
+
public static final String ENCODING_UTF16BE = "UTF16BE";
|
|
107
|
+
public static final String CODE_POINT_LIMIT = "code_point_limit";
|
|
99
108
|
|
|
100
109
|
public static void initPsychParser(Ruby runtime, RubyModule psych) {
|
|
101
110
|
RubyClass psychParser = runtime.defineClassUnder("Parser", runtime.getObject(), PsychParser::new, psych);
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
Arrays.stream(Call.values())
|
|
105
|
-
.map((call) -> new FunctionalCachingCallSite(call.name()))
|
|
106
|
-
.toArray(CachingCallSite[]::new);
|
|
107
|
-
psychParser.setInternalVariable(JRUBY_CALL_SITES, sites);
|
|
112
|
+
psychParser.setInternalVariable(JRUBY_CALL_SITES, new CallSites());
|
|
108
113
|
|
|
109
114
|
runtime.getLoadService().require("psych/syntax_error");
|
|
110
|
-
psychParser.defineConstant(
|
|
111
|
-
psychParser.defineConstant(
|
|
112
|
-
psychParser.defineConstant(
|
|
113
|
-
psychParser.defineConstant(
|
|
115
|
+
psychParser.defineConstant(ENCODING_ANY, runtime.newFixnum(YAML_ANY_ENCODING.ordinal()));
|
|
116
|
+
psychParser.defineConstant(ENCODING_UTF8, runtime.newFixnum(YAML_UTF8_ENCODING.ordinal()));
|
|
117
|
+
psychParser.defineConstant(ENCODING_UTF16LE, runtime.newFixnum(YAML_UTF16LE_ENCODING.ordinal()));
|
|
118
|
+
psychParser.defineConstant(ENCODING_UTF16BE, runtime.newFixnum(YAML_UTF16BE_ENCODING.ordinal()));
|
|
114
119
|
|
|
115
120
|
psychParser.defineAnnotatedMethods(PsychParser.class);
|
|
121
|
+
|
|
122
|
+
// defaults for SnakeYAML load settings
|
|
123
|
+
LoadSettings defaults = LoadSettings.builder().build();
|
|
124
|
+
psychParser.setInternalVariable(CODE_POINT_LIMIT, runtime.newFixnum(defaults.getCodePointLimit()));
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
public PsychParser(Ruby runtime, RubyClass klass) {
|
|
119
128
|
super(runtime, klass);
|
|
120
129
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.
|
|
128
|
-
this.scalar = sites[Call.scalar.ordinal()];
|
|
129
|
-
this.start_sequence = sites[Call.start_sequence.ordinal()];
|
|
130
|
-
this.end_sequence = sites[Call.end_sequence.ordinal()];
|
|
131
|
-
this.start_mapping = sites[Call.start_mapping.ordinal()];
|
|
132
|
-
this.end_mapping = sites[Call.end_mapping.ordinal()];
|
|
133
|
-
this.end_stream = sites[Call.end_stream.ordinal()];
|
|
134
|
-
this.loadSettingsBuilder = LoadSettings.builder().setSchema(new CoreSchema());
|
|
130
|
+
this.sites = (CallSites) klass.getInternalVariable(JRUBY_CALL_SITES);
|
|
131
|
+
|
|
132
|
+
// prepare settings builder and apply global defaults
|
|
133
|
+
LoadSettingsBuilder lsb = LoadSettings.builder();
|
|
134
|
+
lsb.setSchema(new CoreSchema());
|
|
135
|
+
lsb.setCodePointLimit(((IRubyObject) klass.getInternalVariable(CODE_POINT_LIMIT)).convertToInteger().getIntValue());
|
|
136
|
+
this.loadSettingsBuilder = lsb;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
private IRubyObject stringOrNilForAnchor(ThreadContext context, Optional<Anchor> value) {
|
|
@@ -238,8 +240,9 @@ public class PsychParser extends RubyObject {
|
|
|
238
240
|
LoadSettings loadSettings = loadSettingsBuilder.build();
|
|
239
241
|
parser = new ParserImpl(loadSettings, new ScannerImpl(loadSettings, readerFor(context, yaml, loadSettings)));
|
|
240
242
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
+
JavaSites.CheckedSites pathSites = sites.path;
|
|
244
|
+
if (path.isNil() && pathSites.respond_to_X.respondsTo(context, yaml, yaml)) {
|
|
245
|
+
path = pathSites.site.call(context, this, yaml);
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
while (parser.hasNext()) {
|
|
@@ -253,11 +256,11 @@ public class PsychParser extends RubyObject {
|
|
|
253
256
|
IRubyObject end_line = runtime.newFixnum(end.getLine());
|
|
254
257
|
IRubyObject end_column = runtime.newFixnum(end.getColumn());
|
|
255
258
|
|
|
256
|
-
event_location.call(context, this, handler, start_line, start_column, end_line, end_column);
|
|
259
|
+
sites.event_location.call(context, this, handler, start_line, start_column, end_line, end_column);
|
|
257
260
|
|
|
258
261
|
switch (event.getEventId()) {
|
|
259
262
|
case StreamStart:
|
|
260
|
-
start_stream.call(context, this, handler, runtime.newFixnum(YAML_ANY_ENCODING.ordinal()));
|
|
263
|
+
sites.start_stream.call(context, this, handler, runtime.newFixnum(YAML_ANY_ENCODING.ordinal()));
|
|
261
264
|
break;
|
|
262
265
|
case DocumentStart:
|
|
263
266
|
handleDocumentStart(context, (DocumentStartEvent) event, handler);
|
|
@@ -265,12 +268,12 @@ public class PsychParser extends RubyObject {
|
|
|
265
268
|
case DocumentEnd:
|
|
266
269
|
IRubyObject notExplicit = runtime.newBoolean(!((DocumentEndEvent) event).isExplicit());
|
|
267
270
|
|
|
268
|
-
end_document.call(context, this, handler, notExplicit);
|
|
271
|
+
sites.end_document.call(context, this, handler, notExplicit);
|
|
269
272
|
break;
|
|
270
273
|
case Alias:
|
|
271
274
|
IRubyObject alias = stringOrNilForAnchor(context, ((AliasEvent) event).getAnchor());
|
|
272
275
|
|
|
273
|
-
|
|
276
|
+
sites.alias.call(context, this, handler, alias);
|
|
274
277
|
break;
|
|
275
278
|
case Scalar:
|
|
276
279
|
handleScalar(context, (ScalarEvent) event, handler);
|
|
@@ -279,16 +282,16 @@ public class PsychParser extends RubyObject {
|
|
|
279
282
|
handleSequenceStart(context, (SequenceStartEvent) event, handler);
|
|
280
283
|
break;
|
|
281
284
|
case SequenceEnd:
|
|
282
|
-
end_sequence.call(context, this, handler);
|
|
285
|
+
sites.end_sequence.call(context, this, handler);
|
|
283
286
|
break;
|
|
284
287
|
case MappingStart:
|
|
285
288
|
handleMappingStart(context, (MappingStartEvent) event, handler);
|
|
286
289
|
break;
|
|
287
290
|
case MappingEnd:
|
|
288
|
-
end_mapping.call(context, this, handler);
|
|
291
|
+
sites.end_mapping.call(context, this, handler);
|
|
289
292
|
break;
|
|
290
293
|
case StreamEnd:
|
|
291
|
-
end_stream.call(context, this, handler);
|
|
294
|
+
sites.end_stream.call(context, this, handler);
|
|
292
295
|
break;
|
|
293
296
|
}
|
|
294
297
|
}
|
|
@@ -351,17 +354,18 @@ public class PsychParser extends RubyObject {
|
|
|
351
354
|
|
|
352
355
|
IRubyObject notExplicit = runtime.newBoolean(!dse.isExplicit());
|
|
353
356
|
|
|
354
|
-
start_document.call(context, this, handler, version, tags, notExplicit);
|
|
357
|
+
sites.start_document.call(context, this, handler, version, tags, notExplicit);
|
|
355
358
|
}
|
|
356
359
|
|
|
357
360
|
private void handleMappingStart(ThreadContext context, MappingStartEvent mse, IRubyObject handler) {
|
|
358
361
|
Ruby runtime = context.runtime;
|
|
362
|
+
|
|
359
363
|
IRubyObject anchor = stringOrNilForAnchor(context, mse.getAnchor());
|
|
360
364
|
IRubyObject tag = stringOrNilFor(context, mse.getTag());
|
|
361
365
|
IRubyObject implicit = runtime.newBoolean(mse.isImplicit());
|
|
362
366
|
IRubyObject style = runtime.newFixnum(translateFlowStyle(mse.getFlowStyle()));
|
|
363
367
|
|
|
364
|
-
start_mapping.call(context, this, handler, anchor, tag, implicit, style);
|
|
368
|
+
sites.start_mapping.call(context, this, handler, anchor, tag, implicit, style);
|
|
365
369
|
}
|
|
366
370
|
|
|
367
371
|
private void handleScalar(ThreadContext context, ScalarEvent se, IRubyObject handler) {
|
|
@@ -375,28 +379,30 @@ public class PsychParser extends RubyObject {
|
|
|
375
379
|
IRubyObject style = runtime.newFixnum(translateStyle(se.getScalarStyle()));
|
|
376
380
|
IRubyObject val = stringFor(context, se.getValue());
|
|
377
381
|
|
|
378
|
-
scalar.call(context, this, handler, val, anchor, tag, plain_implicit,
|
|
382
|
+
sites.scalar.call(context, this, handler, val, anchor, tag, plain_implicit,
|
|
379
383
|
quoted_implicit, style);
|
|
380
384
|
}
|
|
381
385
|
|
|
382
386
|
private void handleSequenceStart(ThreadContext context, SequenceStartEvent sse, IRubyObject handler) {
|
|
383
387
|
Ruby runtime = context.runtime;
|
|
388
|
+
|
|
384
389
|
IRubyObject anchor = stringOrNilForAnchor(context, sse.getAnchor());
|
|
385
390
|
IRubyObject tag = stringOrNilFor(context, sse.getTag());
|
|
386
391
|
IRubyObject implicit = runtime.newBoolean(sse.isImplicit());
|
|
387
392
|
IRubyObject style = runtime.newFixnum(translateFlowStyle(sse.getFlowStyle()));
|
|
388
393
|
|
|
389
|
-
start_sequence.call(context, this, handler, anchor, tag, implicit, style);
|
|
394
|
+
sites.start_sequence.call(context, this, handler, anchor, tag, implicit, style);
|
|
390
395
|
}
|
|
391
396
|
|
|
392
397
|
private static void raiseParserException(ThreadContext context, ReaderException re, IRubyObject rbPath) {
|
|
393
398
|
Ruby runtime = context.runtime;
|
|
399
|
+
|
|
394
400
|
RubyClass se;
|
|
395
|
-
|
|
401
|
+
RubyException exception;
|
|
396
402
|
|
|
397
403
|
se = (RubyClass) runtime.getModule("Psych").getConstant("SyntaxError");
|
|
398
404
|
|
|
399
|
-
exception = se.newInstance(context,
|
|
405
|
+
exception = (RubyException) se.newInstance(context,
|
|
400
406
|
new IRubyObject[] {
|
|
401
407
|
rbPath,
|
|
402
408
|
RubyFixnum.zero(runtime),
|
|
@@ -407,20 +413,23 @@ public class PsychParser extends RubyObject {
|
|
|
407
413
|
},
|
|
408
414
|
Block.NULL_BLOCK);
|
|
409
415
|
|
|
416
|
+
exception.setCause(JavaUtil.convertJavaToUsableRubyObject(runtime, re));
|
|
417
|
+
|
|
410
418
|
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
|
|
411
419
|
}
|
|
412
420
|
|
|
413
421
|
private static void raiseParserException(ThreadContext context, MarkedYamlEngineException mye, IRubyObject rbPath) {
|
|
414
422
|
Ruby runtime = context.runtime;
|
|
423
|
+
|
|
415
424
|
Mark mark;
|
|
416
425
|
RubyClass se;
|
|
417
|
-
|
|
426
|
+
RubyException exception;
|
|
418
427
|
|
|
419
428
|
se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError");
|
|
420
429
|
|
|
421
430
|
mark = mye.getProblemMark().get();
|
|
422
431
|
|
|
423
|
-
exception = se.newInstance(context,
|
|
432
|
+
exception = (RubyException) se.newInstance(context,
|
|
424
433
|
new IRubyObject[] {
|
|
425
434
|
rbPath,
|
|
426
435
|
runtime.newFixnum(mark.getLine() + 1),
|
|
@@ -431,19 +440,22 @@ public class PsychParser extends RubyObject {
|
|
|
431
440
|
},
|
|
432
441
|
Block.NULL_BLOCK);
|
|
433
442
|
|
|
443
|
+
exception.setCause(JavaUtil.convertJavaToUsableRubyObject(runtime, mye));
|
|
444
|
+
|
|
434
445
|
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
|
|
435
446
|
}
|
|
436
447
|
|
|
437
448
|
private static void raiseParserException(ThreadContext context, MalformedInputException mie, IRubyObject rbPath) {
|
|
438
449
|
Ruby runtime = context.runtime;
|
|
450
|
+
|
|
439
451
|
RubyClass se;
|
|
440
|
-
|
|
452
|
+
RubyException exception;
|
|
441
453
|
|
|
442
454
|
se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError");
|
|
443
455
|
|
|
444
456
|
mie.getInputLength();
|
|
445
457
|
|
|
446
|
-
exception = se.newInstance(context,
|
|
458
|
+
exception = (RubyException) se.newInstance(context,
|
|
447
459
|
arrayOf(
|
|
448
460
|
rbPath,
|
|
449
461
|
RubyFixnum.minus_one(runtime),
|
|
@@ -454,6 +466,8 @@ public class PsychParser extends RubyObject {
|
|
|
454
466
|
),
|
|
455
467
|
Block.NULL_BLOCK);
|
|
456
468
|
|
|
469
|
+
exception.setCause(JavaUtil.convertJavaToUsableRubyObject(runtime, mie));
|
|
470
|
+
|
|
457
471
|
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
|
|
458
472
|
}
|
|
459
473
|
|
|
@@ -515,52 +529,36 @@ public class PsychParser extends RubyObject {
|
|
|
515
529
|
);
|
|
516
530
|
}
|
|
517
531
|
|
|
518
|
-
@JRubyMethod(name = "
|
|
519
|
-
public IRubyObject
|
|
520
|
-
loadSettingsBuilder.
|
|
521
|
-
|
|
522
|
-
return max;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
@JRubyMethod(name = "max_aliases_for_collections")
|
|
526
|
-
public IRubyObject max_aliases_for_collections(ThreadContext context) {
|
|
527
|
-
return context.runtime.newFixnum(buildSettings().getMaxAliasesForCollections());
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
@JRubyMethod(name = "allow_duplicate_keys=")
|
|
531
|
-
public IRubyObject allow_duplicate_keys_set(IRubyObject allow) {
|
|
532
|
-
loadSettingsBuilder.setAllowDuplicateKeys(allow.isTrue());
|
|
532
|
+
@JRubyMethod(name = "code_point_limit=")
|
|
533
|
+
public IRubyObject code_point_limit_set(IRubyObject limit) {
|
|
534
|
+
loadSettingsBuilder.setCodePointLimit(limit.convertToInteger().getIntValue());
|
|
533
535
|
|
|
534
|
-
return
|
|
536
|
+
return limit;
|
|
535
537
|
}
|
|
536
538
|
|
|
537
|
-
@JRubyMethod(name =
|
|
538
|
-
public IRubyObject
|
|
539
|
-
return
|
|
539
|
+
@JRubyMethod(name = CODE_POINT_LIMIT)
|
|
540
|
+
public IRubyObject code_point_limit(ThreadContext context) {
|
|
541
|
+
return context.runtime.newFixnum(buildSettings().getCodePointLimit());
|
|
540
542
|
}
|
|
541
543
|
|
|
542
|
-
|
|
543
|
-
public IRubyObject allow_recursive_keys_set(IRubyObject allow) {
|
|
544
|
-
loadSettingsBuilder.setAllowRecursiveKeys(allow.isTrue());
|
|
544
|
+
// class-level accessors for default values
|
|
545
545
|
|
|
546
|
-
|
|
547
|
-
|
|
546
|
+
@JRubyMethod(name = "code_point_limit=", meta = true)
|
|
547
|
+
public static IRubyObject code_point_limit_set(ThreadContext context, IRubyObject self, IRubyObject limit) {
|
|
548
|
+
int codePointLimit = RubyNumeric.num2int(limit);
|
|
548
549
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
550
|
+
if (codePointLimit <= 0) {
|
|
551
|
+
throw context.runtime.newRangeError("code_point_limit must be positive");
|
|
552
|
+
}
|
|
553
553
|
|
|
554
|
-
|
|
555
|
-
public IRubyObject code_point_limit_set(IRubyObject limit) {
|
|
556
|
-
loadSettingsBuilder.setCodePointLimit(limit.convertToInteger().getIntValue());
|
|
554
|
+
self.getInternalVariables().setInternalVariable(CODE_POINT_LIMIT, limit);
|
|
557
555
|
|
|
558
556
|
return limit;
|
|
559
557
|
}
|
|
560
558
|
|
|
561
|
-
@JRubyMethod(name =
|
|
562
|
-
public IRubyObject code_point_limit(ThreadContext context) {
|
|
563
|
-
return
|
|
559
|
+
@JRubyMethod(name = CODE_POINT_LIMIT, meta = true)
|
|
560
|
+
public static IRubyObject code_point_limit(ThreadContext context, IRubyObject self) {
|
|
561
|
+
return (IRubyObject) self.getInternalVariables().getInternalVariable(CODE_POINT_LIMIT);
|
|
564
562
|
}
|
|
565
563
|
|
|
566
564
|
private LoadSettings buildSettings() {
|
|
@@ -570,10 +568,21 @@ public class PsychParser extends RubyObject {
|
|
|
570
568
|
private Parser parser;
|
|
571
569
|
private Event event;
|
|
572
570
|
private final LoadSettingsBuilder loadSettingsBuilder;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
571
|
+
private final CallSites sites;
|
|
572
|
+
|
|
573
|
+
private static class CallSites {
|
|
574
|
+
private final JavaSites.CheckedSites path = new JavaSites.CheckedSites("path");
|
|
575
|
+
private final CachingCallSite event_location = new FunctionalCachingCallSite("event_location");
|
|
576
|
+
private final CachingCallSite start_stream = new FunctionalCachingCallSite("start_stream");
|
|
577
|
+
private final CachingCallSite start_document = new FunctionalCachingCallSite("start_document");
|
|
578
|
+
private final CachingCallSite end_document = new FunctionalCachingCallSite("end_document");
|
|
579
|
+
private final CachingCallSite alias = new FunctionalCachingCallSite("alias");
|
|
580
|
+
private final CachingCallSite scalar = new FunctionalCachingCallSite("scalar");
|
|
581
|
+
private final CachingCallSite start_sequence = new FunctionalCachingCallSite("start_sequence");
|
|
582
|
+
private final CachingCallSite end_sequence = new FunctionalCachingCallSite("end_sequence");
|
|
583
|
+
private final CachingCallSite start_mapping = new FunctionalCachingCallSite("start_mapping");
|
|
584
|
+
private final CachingCallSite end_mapping = new FunctionalCachingCallSite("end_mapping");
|
|
585
|
+
private final CachingCallSite end_stream = new FunctionalCachingCallSite("end_stream");
|
|
576
586
|
}
|
|
577
587
|
|
|
578
|
-
private final CachingCallSite path, event_location, start_stream, start_document, end_document, alias, scalar, start_sequence, end_sequence, start_mapping, end_mapping, end_stream;
|
|
579
588
|
}
|
data/lib/psych/versions.rb
CHANGED
data/lib/psych.jar
CHANGED
|
Binary file
|
data/lib/psych.rb
CHANGED
|
@@ -694,26 +694,8 @@ module Psych
|
|
|
694
694
|
dump_tags[klass] = tag
|
|
695
695
|
end
|
|
696
696
|
|
|
697
|
-
# Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
|
|
698
|
-
def self.warn_with_uplevel(message, uplevel: 1)
|
|
699
|
-
at = parse_caller(caller[uplevel]).join(':')
|
|
700
|
-
warn "#{at}: #{message}"
|
|
701
|
-
end
|
|
702
|
-
|
|
703
|
-
def self.parse_caller(at)
|
|
704
|
-
if /^(.+?):(\d+)(?::in `.*')?/ =~ at
|
|
705
|
-
file = $1
|
|
706
|
-
line = $2.to_i
|
|
707
|
-
[file, line]
|
|
708
|
-
end
|
|
709
|
-
end
|
|
710
|
-
private_class_method :warn_with_uplevel, :parse_caller
|
|
711
|
-
|
|
712
697
|
class << self
|
|
713
698
|
if defined?(Ractor)
|
|
714
|
-
require 'forwardable'
|
|
715
|
-
extend Forwardable
|
|
716
|
-
|
|
717
699
|
class Config
|
|
718
700
|
attr_accessor :load_tags, :dump_tags, :domain_types
|
|
719
701
|
def initialize
|
|
@@ -727,7 +709,29 @@ module Psych
|
|
|
727
709
|
Ractor.current[:PsychConfig] ||= Config.new
|
|
728
710
|
end
|
|
729
711
|
|
|
730
|
-
|
|
712
|
+
def load_tags
|
|
713
|
+
config.load_tags
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
def dump_tags
|
|
717
|
+
config.dump_tags
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
def domain_types
|
|
721
|
+
config.domain_types
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
def load_tags=(value)
|
|
725
|
+
config.load_tags = value
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
def dump_tags=(value)
|
|
729
|
+
config.dump_tags = value
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
def domain_types=(value)
|
|
733
|
+
config.domain_types = value
|
|
734
|
+
end
|
|
731
735
|
else
|
|
732
736
|
attr_accessor :load_tags
|
|
733
737
|
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: 5.1.
|
|
4
|
+
version: 5.1.1
|
|
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: 2023-
|
|
13
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,14 +39,9 @@ extensions: []
|
|
|
39
39
|
extra_rdoc_files:
|
|
40
40
|
- README.md
|
|
41
41
|
files:
|
|
42
|
-
-
|
|
43
|
-
- Gemfile
|
|
42
|
+
- CONTRIBUTING.md
|
|
44
43
|
- LICENSE
|
|
45
|
-
- Mavenfile
|
|
46
44
|
- README.md
|
|
47
|
-
- Rakefile
|
|
48
|
-
- bin/console
|
|
49
|
-
- bin/setup
|
|
50
45
|
- ext/java/org/jruby/ext/psych/PsychEmitter.java
|
|
51
46
|
- ext/java/org/jruby/ext/psych/PsychLibrary.java
|
|
52
47
|
- ext/java/org/jruby/ext/psych/PsychParser.java
|
|
@@ -102,7 +97,6 @@ files:
|
|
|
102
97
|
- lib/psych/visitors/yaml_tree.rb
|
|
103
98
|
- lib/psych/y.rb
|
|
104
99
|
- lib/psych_jars.rb
|
|
105
|
-
- psych.gemspec
|
|
106
100
|
homepage: https://github.com/ruby/psych
|
|
107
101
|
licenses:
|
|
108
102
|
- MIT
|
|
@@ -118,15 +112,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
118
112
|
requirements:
|
|
119
113
|
- - ">="
|
|
120
114
|
- !ruby/object:Gem::Version
|
|
121
|
-
version: 2.
|
|
115
|
+
version: 2.5.0
|
|
122
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
117
|
requirements:
|
|
124
118
|
- - ">="
|
|
125
119
|
- !ruby/object:Gem::Version
|
|
126
120
|
version: '0'
|
|
127
121
|
requirements:
|
|
128
|
-
- jar org.snakeyaml:snakeyaml-engine, 2.
|
|
129
|
-
rubygems_version: 3.3.
|
|
122
|
+
- jar org.snakeyaml:snakeyaml-engine, 2.7
|
|
123
|
+
rubygems_version: 3.3.26
|
|
130
124
|
signing_key:
|
|
131
125
|
specification_version: 4
|
|
132
126
|
summary: Psych is a YAML parser and emitter
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Mavenfile
DELETED
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.8'
|
|
25
|
-
ext.target_version = '1.8'
|
|
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/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
data/bin/setup
DELETED
data/psych.gemspec
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
version_module = Module.new do
|
|
5
|
-
version_rb = File.join(__dir__, "lib/psych/versions.rb")
|
|
6
|
-
module_eval(File.read(version_rb), version_rb)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
Gem::Specification.new do |s|
|
|
10
|
-
s.name = "psych"
|
|
11
|
-
s.version = version_module::Psych::VERSION
|
|
12
|
-
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
|
|
13
|
-
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
|
|
14
|
-
s.summary = "Psych is a YAML parser and emitter"
|
|
15
|
-
s.description = <<-DESCRIPTION
|
|
16
|
-
Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
|
|
17
|
-
for its YAML parsing and emitting capabilities. In addition to wrapping libyaml,
|
|
18
|
-
Psych also knows how to serialize and de-serialize most Ruby objects to and from the YAML format.
|
|
19
|
-
DESCRIPTION
|
|
20
|
-
s.homepage = "https://github.com/ruby/psych"
|
|
21
|
-
s.licenses = ["MIT"]
|
|
22
|
-
s.require_paths = ["lib"]
|
|
23
|
-
|
|
24
|
-
# for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
-
s.files = [
|
|
26
|
-
".gitignore", "Gemfile", "LICENSE", "Mavenfile", "README.md", "Rakefile", "bin/console",
|
|
27
|
-
"bin/setup", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
|
|
28
|
-
"ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
|
|
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
|
-
"lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/exception.rb",
|
|
31
|
-
"lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb",
|
|
32
|
-
"lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb",
|
|
33
|
-
"lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb",
|
|
34
|
-
"lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb",
|
|
35
|
-
"lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb",
|
|
36
|
-
"lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb",
|
|
37
|
-
"lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb","lib/psych/visitors/depth_first.rb",
|
|
38
|
-
"lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb",
|
|
39
|
-
"lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "psych.gemspec"
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
s.rdoc_options = ["--main", "README.md"]
|
|
43
|
-
s.extra_rdoc_files = ["README.md"]
|
|
44
|
-
|
|
45
|
-
s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
|
46
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0")
|
|
47
|
-
|
|
48
|
-
if RUBY_ENGINE == 'jruby'
|
|
49
|
-
s.platform = 'java'
|
|
50
|
-
s.files.concat [
|
|
51
|
-
"ext/java/org/jruby/ext/psych/PsychEmitter.java",
|
|
52
|
-
"ext/java/org/jruby/ext/psych/PsychLibrary.java",
|
|
53
|
-
"ext/java/org/jruby/ext/psych/PsychParser.java",
|
|
54
|
-
"ext/java/org/jruby/ext/psych/PsychToRuby.java",
|
|
55
|
-
"lib/psych_jars.rb",
|
|
56
|
-
"lib/psych.jar"
|
|
57
|
-
]
|
|
58
|
-
s.requirements = "jar org.snakeyaml:snakeyaml-engine, #{version_module::Psych::DEFAULT_SNAKEYAML_VERSION}"
|
|
59
|
-
s.add_dependency 'jar-dependencies', '>= 0.1.7'
|
|
60
|
-
else
|
|
61
|
-
s.extensions = ["ext/psych/extconf.rb"]
|
|
62
|
-
s.add_dependency 'stringio'
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
s.metadata['msys2_mingw_dependencies'] = 'libyaml'
|
|
66
|
-
|
|
67
|
-
end
|