psych 5.0.1-java → 5.1.0.pre1-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: c8a636a31c1720b2efa0ebf3cef2a8a4d13f93028b0859b3559689ae43f1d6d4
4
- data.tar.gz: c243a20bcedab1c7ddbaa9370fd6e643d9abb694422415e07e56d410080228e2
3
+ metadata.gz: 6e3ca9e0683d2ca342865ab6fa4609d505446db917a5745a30d66aa929970190
4
+ data.tar.gz: 2519befec441ec3e4a5637ae31db529ebc70985474a257f2699bc5a6169ef8b7
5
5
  SHA512:
6
- metadata.gz: b69c593028d6a89daa2f390dc70eff0d423c81f180939b7486cc7f8c4d223dacef18047be9b0d012a3eb77b5fe5558d00ca6e139c36d14d2dc509b8bb227b11e
7
- data.tar.gz: '06970e06310e2e3ec81522a79117d8244bcdf017c4532a9ff419e13d0d99a0099104ec8566f85b2a16c84e3b1d8c9871c643914410f0430f72c5245d6eea43c4'
6
+ metadata.gz: '05581e2dbd2f83ccde48d893c1555673b123ba5314589e785f6583c4f89624441d9e2feda37e7b1689ecf78fc9d95272f58a5adc6fddcdf8705f7940c0ad588f'
7
+ data.tar.gz: '0966f93bd2e9bd437205eed8b1f3bf15a6609db548c7f4aca4328514ce7e26f9aff7aa06ae283870f74cd4935ea75a732b67d92bb85044091819acc411ee7ef8'
data/Mavenfile CHANGED
@@ -1,6 +1,6 @@
1
1
  #-*- mode: ruby -*-
2
2
 
3
- jar 'org.yaml:snakeyaml:${snakeyaml.version}'
3
+ jar 'org.snakeyaml:snakeyaml-engine:${snakeyaml.version}'
4
4
 
5
5
  plugin :dependency, '2.8', :outputFile => 'pkg/classpath'
6
6
 
data/Rakefile CHANGED
@@ -21,8 +21,8 @@ if RUBY_PLATFORM =~ /java/
21
21
  # this is basically the same as running from the commandline:
22
22
  # rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
23
23
  Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')
24
- ext.source_version = '1.7'
25
- ext.target_version = '1.7'
24
+ ext.source_version = '1.8'
25
+ ext.target_version = '1.8'
26
26
  ext.classpath = File.read('pkg/classpath')
27
27
  ext.ext_dir = 'ext/java'
28
28
  end
@@ -27,57 +27,59 @@
27
27
  ***** END LICENSE BLOCK *****/
28
28
  package org.jruby.ext.psych;
29
29
 
30
- import java.io.IOException;
31
- import java.io.OutputStreamWriter;
32
- import java.io.Writer;
33
- import java.nio.charset.Charset;
34
- import java.util.HashMap;
35
- import java.util.Map;
36
-
37
30
  import org.jcodings.Encoding;
38
31
  import org.jcodings.specific.UTF8Encoding;
39
32
  import org.jruby.Ruby;
40
33
  import org.jruby.RubyArray;
41
34
  import org.jruby.RubyBoolean;
42
35
  import org.jruby.RubyClass;
43
- import org.jruby.RubyFixnum;
36
+ import org.jruby.RubyEncoding;
44
37
  import org.jruby.RubyModule;
45
38
  import org.jruby.RubyObject;
46
39
  import org.jruby.RubyString;
47
40
  import org.jruby.anno.JRubyMethod;
48
- import org.jruby.runtime.ObjectAllocator;
49
41
  import org.jruby.runtime.ThreadContext;
50
42
  import org.jruby.runtime.builtin.IRubyObject;
43
+ import org.jruby.util.ByteList;
51
44
  import org.jruby.util.IOOutputStream;
52
45
  import org.jruby.util.TypeConverter;
53
46
  import org.jruby.util.io.EncodingUtils;
54
- import org.yaml.snakeyaml.DumperOptions;
55
- import org.yaml.snakeyaml.emitter.Emitter;
56
- import org.yaml.snakeyaml.emitter.EmitterException;
57
- import org.yaml.snakeyaml.error.Mark;
58
- import org.yaml.snakeyaml.events.AliasEvent;
59
- import org.yaml.snakeyaml.events.DocumentEndEvent;
60
- import org.yaml.snakeyaml.events.DocumentStartEvent;
61
- import org.yaml.snakeyaml.events.Event;
62
- import org.yaml.snakeyaml.events.ImplicitTuple;
63
- import org.yaml.snakeyaml.events.MappingEndEvent;
64
- import org.yaml.snakeyaml.events.MappingStartEvent;
65
- import org.yaml.snakeyaml.events.ScalarEvent;
66
- import org.yaml.snakeyaml.events.SequenceEndEvent;
67
- import org.yaml.snakeyaml.events.SequenceStartEvent;
68
- import org.yaml.snakeyaml.events.StreamEndEvent;
69
- import org.yaml.snakeyaml.events.StreamStartEvent;
70
-
71
- import static org.jruby.runtime.Visibility.*;
47
+ import org.snakeyaml.engine.v2.api.DumpSettings;
48
+ import org.snakeyaml.engine.v2.api.DumpSettingsBuilder;
49
+ import org.snakeyaml.engine.v2.api.StreamDataWriter;
50
+ import org.snakeyaml.engine.v2.api.YamlOutputStreamWriter;
51
+ import org.snakeyaml.engine.v2.common.Anchor;
52
+ import org.snakeyaml.engine.v2.common.FlowStyle;
53
+ import org.snakeyaml.engine.v2.common.ScalarStyle;
54
+ import org.snakeyaml.engine.v2.common.SpecVersion;
55
+ import org.snakeyaml.engine.v2.emitter.Emitter;
56
+ import org.snakeyaml.engine.v2.events.AliasEvent;
57
+ import org.snakeyaml.engine.v2.events.DocumentEndEvent;
58
+ import org.snakeyaml.engine.v2.events.DocumentStartEvent;
59
+ import org.snakeyaml.engine.v2.events.Event;
60
+ import org.snakeyaml.engine.v2.events.ImplicitTuple;
61
+ import org.snakeyaml.engine.v2.events.MappingEndEvent;
62
+ import org.snakeyaml.engine.v2.events.MappingStartEvent;
63
+ import org.snakeyaml.engine.v2.events.ScalarEvent;
64
+ import org.snakeyaml.engine.v2.events.SequenceEndEvent;
65
+ import org.snakeyaml.engine.v2.events.SequenceStartEvent;
66
+ import org.snakeyaml.engine.v2.events.StreamEndEvent;
67
+ import org.snakeyaml.engine.v2.events.StreamStartEvent;
68
+ import org.snakeyaml.engine.v2.exceptions.EmitterException;
69
+ import org.snakeyaml.engine.v2.exceptions.Mark;
70
+
71
+ import java.io.IOException;
72
+ import java.nio.charset.Charset;
73
+ import java.util.HashMap;
74
+ import java.util.Map;
75
+ import java.util.Optional;
76
+
77
+ import static org.jruby.runtime.Visibility.PRIVATE;
72
78
 
73
79
  public class PsychEmitter extends RubyObject {
74
80
  public static void initPsychEmitter(Ruby runtime, RubyModule psych) {
75
81
  RubyClass psychHandler = runtime.defineClassUnder("Handler", runtime.getObject(), runtime.getObject().getAllocator(), psych);
76
- RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, new ObjectAllocator() {
77
- public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
78
- return new PsychEmitter(runtime, klazz);
79
- }
80
- }, psych);
82
+ RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, PsychEmitter::new, psych);
81
83
 
82
84
  psychEmitter.defineAnnotatedMethods(PsychEmitter.class);
83
85
  }
@@ -88,8 +90,7 @@ public class PsychEmitter extends RubyObject {
88
90
 
89
91
  @JRubyMethod(visibility = PRIVATE)
90
92
  public IRubyObject initialize(ThreadContext context, IRubyObject io) {
91
- options = new DumperOptions();
92
- options.setIndent(2);
93
+ dumpSettingsBuilder.setIndent(2);
93
94
 
94
95
  this.io = io;
95
96
 
@@ -102,10 +103,8 @@ public class PsychEmitter extends RubyObject {
102
103
  IRubyObject canonical = rbOptions.callMethod(context, "canonical");
103
104
  IRubyObject level = rbOptions.callMethod(context, "indentation");
104
105
 
105
- options = new DumperOptions();
106
-
107
- options.setCanonical(canonical.isTrue());
108
- options.setIndent((int)level.convertToInteger().getLongValue());
106
+ dumpSettingsBuilder.setCanonical(canonical.isTrue());
107
+ dumpSettingsBuilder.setIndent((int)level.convertToInteger().getLongValue());
109
108
  line_width_set(context, width);
110
109
 
111
110
  this.io = io;
@@ -119,47 +118,45 @@ public class PsychEmitter extends RubyObject {
119
118
 
120
119
  initEmitter(context, encoding);
121
120
 
122
- StreamStartEvent event = new StreamStartEvent(NULL_MARK, NULL_MARK);
123
-
124
- emit(context, event);
121
+ emit(context, NULL_STREAM_START_EVENT);
125
122
 
126
123
  return this;
127
124
  }
128
125
 
129
126
  @JRubyMethod
130
127
  public IRubyObject end_stream(ThreadContext context) {
131
- StreamEndEvent event = new StreamEndEvent(NULL_MARK, NULL_MARK);
132
- emit(context, event);
128
+ emit(context, NULL_STREAM_START_EVENT);
133
129
  return this;
134
130
  }
135
131
 
136
132
  @JRubyMethod
137
133
  public IRubyObject start_document(ThreadContext context, IRubyObject _version, IRubyObject tags, IRubyObject implicit) {
138
- DumperOptions.Version version = null;
134
+ Ruby runtime = context.runtime;
135
+
139
136
  boolean implicitBool = implicit.isTrue();
140
- Map<String, String> tagsMap = null;
141
137
 
142
- TypeConverter.checkType(context, _version, context.runtime.getArray());
138
+ RubyClass arrayClass = runtime.getArray();
139
+ TypeConverter.checkType(context, _version, arrayClass);
143
140
 
144
141
  RubyArray versionAry = _version.convertToArray();
142
+ Optional<SpecVersion> specVersion;
145
143
  if (versionAry.size() == 2) {
146
- int versionInt0 = (int)versionAry.eltInternal(0).convertToInteger().getLongValue();
147
- int versionInt1 = (int)versionAry.eltInternal(1).convertToInteger().getLongValue();
148
-
149
- if (versionInt0 == 1) {
150
- if (versionInt1 == 0) {
151
- version = DumperOptions.Version.V1_0;
152
- } else if (versionInt1 == 1) {
153
- version = DumperOptions.Version.V1_1;
154
- }
155
- }
156
- if (version == null) {
157
- throw context.runtime.newArgumentError("invalid YAML version: " + versionAry);
144
+ int versionInt0 = versionAry.eltInternal(0).convertToInteger().getIntValue();
145
+ int versionInt1 = versionAry.eltInternal(1).convertToInteger().getIntValue();
146
+
147
+ if (versionInt0 != 1) {
148
+ throw runtime.newArgumentError("invalid YAML version: " + versionAry);
158
149
  }
150
+
151
+ specVersion = Optional.of(new SpecVersion(versionInt0, versionInt1));
152
+ } else {
153
+ specVersion = Optional.empty();
159
154
  }
160
155
 
156
+ Map<String, String> tagsMap = new HashMap<>();
157
+
161
158
  if (!tags.isNil()) {
162
- TypeConverter.checkType(context, tags, context.runtime.getArray());
159
+ TypeConverter.checkType(context, tags, arrayClass);
163
160
 
164
161
  RubyArray tagsAry = tags.convertToArray();
165
162
  if (tagsAry.size() > 0) {
@@ -167,7 +164,7 @@ public class PsychEmitter extends RubyObject {
167
164
  for (int i = 0; i < tagsAry.size(); i++) {
168
165
  RubyArray tagsTuple = tagsAry.eltInternal(i).convertToArray();
169
166
  if (tagsTuple.size() != 2) {
170
- throw context.runtime.newRuntimeError("tags tuple must be of length 2");
167
+ throw runtime.newRuntimeError("tags tuple must be of length 2");
171
168
  }
172
169
  IRubyObject key = tagsTuple.eltInternal(0);
173
170
  IRubyObject value = tagsTuple.eltInternal(1);
@@ -178,14 +175,14 @@ public class PsychEmitter extends RubyObject {
178
175
  }
179
176
  }
180
177
 
181
- DocumentStartEvent event = new DocumentStartEvent(NULL_MARK, NULL_MARK, !implicitBool, version, tagsMap);
178
+ DocumentStartEvent event = new DocumentStartEvent(!implicitBool, specVersion, tagsMap, NULL_MARK, NULL_MARK);
182
179
  emit(context, event);
183
180
  return this;
184
181
  }
185
182
 
186
183
  @JRubyMethod
187
184
  public IRubyObject end_document(ThreadContext context, IRubyObject implicit) {
188
- DocumentEndEvent event = new DocumentEndEvent(NULL_MARK, NULL_MARK, !implicit.isTrue());
185
+ DocumentEndEvent event = new DocumentEndEvent(!implicit.isTrue(), NULL_MARK, NULL_MARK);
189
186
  emit(context, event);
190
187
  return this;
191
188
  }
@@ -207,17 +204,17 @@ public class PsychEmitter extends RubyObject {
207
204
 
208
205
  valueStr = EncodingUtils.strConvEnc(context, valueStr, valueStr.getEncoding(), UTF8Encoding.INSTANCE);
209
206
 
210
- RubyString anchorStr = exportToUTF8(context, anchor, stringClass);
211
- RubyString tagStr = exportToUTF8(context, tag, stringClass);
207
+ String anchorStr = exportToUTF8(context, anchor, stringClass);
208
+ String tagStr = exportToUTF8(context, tag, stringClass);
212
209
 
213
210
  ScalarEvent event = new ScalarEvent(
214
- anchorStr == null ? null : anchorStr.asJavaString(),
215
- tagStr == null ? null : tagStr.asJavaString(),
211
+ Optional.ofNullable(anchorStr == null ? null : new Anchor(anchorStr)),
212
+ Optional.ofNullable(tagStr),
216
213
  new ImplicitTuple(plain.isTrue(), quoted.isTrue()),
217
214
  valueStr.asJavaString(),
215
+ SCALAR_STYLES[style.convertToInteger().getIntValue()],
218
216
  NULL_MARK,
219
- NULL_MARK,
220
- SCALAR_STYLES[style.convertToInteger().getIntValue()]);
217
+ NULL_MARK);
221
218
 
222
219
  emit(context, event);
223
220
 
@@ -233,16 +230,16 @@ public class PsychEmitter extends RubyObject {
233
230
 
234
231
  RubyClass stringClass = context.runtime.getString();
235
232
 
236
- RubyString anchorStr = exportToUTF8(context, anchor, stringClass);
237
- RubyString tagStr = exportToUTF8(context, tag, stringClass);
233
+ String anchorStr = exportToUTF8(context, anchor, stringClass);
234
+ String tagStr = exportToUTF8(context, tag, stringClass);
238
235
 
239
236
  SequenceStartEvent event = new SequenceStartEvent(
240
- anchorStr == null ? null : anchorStr.asJavaString(),
241
- tagStr == null ? null : tagStr.asJavaString(),
237
+ Optional.ofNullable(anchorStr == null ? null : new Anchor(anchorStr)),
238
+ Optional.ofNullable(tagStr),
242
239
  implicit.isTrue(),
240
+ FLOW_STYLES[style.convertToInteger().getIntValue()],
243
241
  NULL_MARK,
244
- NULL_MARK,
245
- FLOW_STYLES[style.convertToInteger().getIntValue()]);
242
+ NULL_MARK);
246
243
  emit(context, event);
247
244
  return this;
248
245
  }
@@ -263,16 +260,16 @@ public class PsychEmitter extends RubyObject {
263
260
 
264
261
  RubyClass stringClass = context.runtime.getString();
265
262
 
266
- RubyString anchorStr = exportToUTF8(context, anchor, stringClass);
267
- RubyString tagStr = exportToUTF8(context, tag, stringClass);
263
+ String anchorStr = exportToUTF8(context, anchor, stringClass);
264
+ String tagStr = exportToUTF8(context, tag, stringClass);
268
265
 
269
266
  MappingStartEvent event = new MappingStartEvent(
270
- anchorStr == null ? null : anchorStr.asJavaString(),
271
- tagStr == null ? null : tagStr.asJavaString(),
267
+ Optional.ofNullable(anchorStr == null ? null : new Anchor(anchorStr)),
268
+ Optional.ofNullable(tagStr),
272
269
  implicit.isTrue(),
270
+ FLOW_STYLES[style.convertToInteger().getIntValue()],
273
271
  NULL_MARK,
274
- NULL_MARK,
275
- FLOW_STYLES[style.convertToInteger().getIntValue()]);
272
+ NULL_MARK);
276
273
 
277
274
  emit(context, event);
278
275
 
@@ -290,9 +287,9 @@ public class PsychEmitter extends RubyObject {
290
287
  public IRubyObject alias(ThreadContext context, IRubyObject anchor) {
291
288
  RubyClass stringClass = context.runtime.getString();
292
289
 
293
- RubyString anchorStr = exportToUTF8(context, anchor, stringClass);
290
+ String anchorStr = exportToUTF8(context, anchor, stringClass);
294
291
 
295
- AliasEvent event = new AliasEvent(anchorStr.asJavaString(), NULL_MARK, NULL_MARK);
292
+ AliasEvent event = new AliasEvent(Optional.of(new Anchor(anchorStr)), NULL_MARK, NULL_MARK);
296
293
  emit(context, event);
297
294
  return this;
298
295
  }
@@ -300,40 +297,40 @@ public class PsychEmitter extends RubyObject {
300
297
  @JRubyMethod(name = "canonical=")
301
298
  public IRubyObject canonical_set(ThreadContext context, IRubyObject canonical) {
302
299
  // TODO: unclear if this affects a running emitter
303
- options.setCanonical(canonical.isTrue());
300
+ dumpSettingsBuilder.setCanonical(canonical.isTrue());
304
301
  return canonical;
305
302
  }
306
303
 
307
304
  @JRubyMethod
308
305
  public IRubyObject canonical(ThreadContext context) {
309
306
  // TODO: unclear if this affects a running emitter
310
- return RubyBoolean.newBoolean(context, options.isCanonical());
307
+ return RubyBoolean.newBoolean(context, buildDumpSettings().isCanonical());
311
308
  }
312
309
 
313
310
  @JRubyMethod(name = "indentation=")
314
311
  public IRubyObject indentation_set(ThreadContext context, IRubyObject level) {
315
312
  // TODO: unclear if this affects a running emitter
316
- options.setIndent((int)level.convertToInteger().getLongValue());
313
+ dumpSettingsBuilder.setIndent(level.convertToInteger().getIntValue());
317
314
  return level;
318
315
  }
319
316
 
320
317
  @JRubyMethod
321
318
  public IRubyObject indentation(ThreadContext context) {
322
319
  // TODO: unclear if this affects a running emitter
323
- return context.runtime.newFixnum(options.getIndent());
320
+ return context.runtime.newFixnum(buildDumpSettings().getIndent());
324
321
  }
325
322
 
326
323
  @JRubyMethod(name = "line_width=")
327
324
  public IRubyObject line_width_set(ThreadContext context, IRubyObject width) {
328
- int newWidth = (int)width.convertToInteger().getLongValue();
325
+ int newWidth = width.convertToInteger().getIntValue();
329
326
  if (newWidth <= 0) newWidth = Integer.MAX_VALUE;
330
- options.setWidth(newWidth);
327
+ dumpSettingsBuilder.setWidth(newWidth);
331
328
  return width;
332
329
  }
333
330
 
334
331
  @JRubyMethod
335
332
  public IRubyObject line_width(ThreadContext context) {
336
- return context.runtime.newFixnum(options.getWidth());
333
+ return context.runtime.newFixnum(buildDumpSettings().getWidth());
337
334
  }
338
335
 
339
336
  private void emit(ThreadContext context, Event event) {
@@ -344,8 +341,6 @@ public class PsychEmitter extends RubyObject {
344
341
 
345
342
  // flush writer after each emit
346
343
  writer.flush();
347
- } catch (IOException ioe) {
348
- throw context.runtime.newIOErrorFromException(ioe);
349
344
  } catch (EmitterException ee) {
350
345
  throw context.runtime.newRuntimeError(ee.toString());
351
346
  }
@@ -357,41 +352,55 @@ public class PsychEmitter extends RubyObject {
357
352
  Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding;
358
353
  Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding);
359
354
 
360
- writer = new OutputStreamWriter(new IOOutputStream(io, encoding), charset);
361
- emitter = new Emitter(writer, options);
355
+ writer = new YamlOutputStreamWriter(new IOOutputStream(io, encoding), charset) {
356
+ @Override
357
+ public void processIOException(IOException ioe) {
358
+ throw context.runtime.newIOErrorFromException(ioe);
359
+ }
360
+ };
361
+ emitter = new Emitter(buildDumpSettings(), writer);
362
+ }
363
+
364
+ private DumpSettings buildDumpSettings() {
365
+ return dumpSettingsBuilder.build();
362
366
  }
363
367
 
364
- private RubyString exportToUTF8(ThreadContext context, IRubyObject tag, RubyClass stringClass) {
365
- RubyString tagStr = null;
366
- if (!tag.isNil()) {
367
- TypeConverter.checkType(context, tag, stringClass);
368
- tagStr = (RubyString) tag;
369
- tagStr = EncodingUtils.strConvEnc(context, tagStr, tagStr.getEncoding(), UTF8Encoding.INSTANCE);
368
+ private String exportToUTF8(ThreadContext context, IRubyObject maybeString, RubyClass stringClass) {
369
+ if (maybeString.isNil()) {
370
+ return null;
370
371
  }
371
- return tagStr;
372
+
373
+ RubyString string;
374
+
375
+ TypeConverter.checkType(context, maybeString, stringClass);
376
+ string = (RubyString) maybeString;
377
+ ByteList bytes = string.getByteList();
378
+
379
+ return RubyEncoding.decodeUTF8(bytes.unsafeBytes(), bytes.begin(), bytes.realSize());
372
380
  }
373
381
 
374
382
  Emitter emitter;
375
- Writer writer;
376
- DumperOptions options = new DumperOptions();
383
+ StreamDataWriter writer;
384
+ final DumpSettingsBuilder dumpSettingsBuilder = DumpSettings.builder();
377
385
  IRubyObject io;
378
386
 
379
- private static final Mark NULL_MARK = new Mark("", 0, 0, 0, new int[0], 0);
387
+ private static final Optional<Mark> NULL_MARK = Optional.empty();
388
+ private static final StreamStartEvent NULL_STREAM_START_EVENT = new StreamStartEvent(NULL_MARK, NULL_MARK);
380
389
 
381
390
  // Map style constants from Psych values (ANY = 0 ... FOLDED = 5)
382
391
  // to SnakeYaml values; see psych/nodes/scalar.rb.
383
- private static final DumperOptions.ScalarStyle[] SCALAR_STYLES = {
384
- DumperOptions.ScalarStyle.PLAIN, // ANY
385
- DumperOptions.ScalarStyle.PLAIN,
386
- DumperOptions.ScalarStyle.SINGLE_QUOTED,
387
- DumperOptions.ScalarStyle.DOUBLE_QUOTED,
388
- DumperOptions.ScalarStyle.LITERAL,
389
- DumperOptions.ScalarStyle.FOLDED
392
+ private static final ScalarStyle[] SCALAR_STYLES = {
393
+ ScalarStyle.PLAIN, // ANY
394
+ ScalarStyle.PLAIN,
395
+ ScalarStyle.SINGLE_QUOTED,
396
+ ScalarStyle.DOUBLE_QUOTED,
397
+ ScalarStyle.LITERAL,
398
+ ScalarStyle.FOLDED
390
399
  };
391
400
 
392
- private static final DumperOptions.FlowStyle[] FLOW_STYLES = {
393
- DumperOptions.FlowStyle.AUTO,
394
- DumperOptions.FlowStyle.BLOCK,
395
- DumperOptions.FlowStyle.FLOW
401
+ private static final FlowStyle[] FLOW_STYLES = {
402
+ FlowStyle.AUTO,
403
+ FlowStyle.BLOCK,
404
+ FlowStyle.FLOW
396
405
  };
397
406
  }
@@ -27,10 +27,6 @@
27
27
  ***** END LICENSE BLOCK *****/
28
28
  package org.jruby.ext.psych;
29
29
 
30
- import java.io.InputStream;
31
- import java.io.IOException;
32
- import java.util.Properties;
33
-
34
30
  import org.jcodings.Encoding;
35
31
  import org.jcodings.specific.UTF16BEEncoding;
36
32
  import org.jcodings.specific.UTF16LEEncoding;
@@ -44,7 +40,10 @@ import org.jruby.runtime.ThreadContext;
44
40
  import org.jruby.runtime.Visibility;
45
41
  import org.jruby.runtime.builtin.IRubyObject;
46
42
  import org.jruby.runtime.load.Library;
47
- import org.yaml.snakeyaml.error.Mark;
43
+
44
+ import java.io.IOException;
45
+ import java.io.InputStream;
46
+ import java.util.Properties;
48
47
 
49
48
  public class PsychLibrary implements Library {
50
49
  private static final String DUMMY_VERSION = "0.0";
@@ -54,7 +53,7 @@ public class PsychLibrary implements Library {
54
53
 
55
54
  // load version from properties packed with the jar
56
55
  Properties props = new Properties();
57
- try( InputStream is = runtime.getJRubyClassLoader().getResourceAsStream("META-INF/maven/org.yaml/snakeyaml/pom.properties") ) {
56
+ try( InputStream is = runtime.getJRubyClassLoader().getResourceAsStream("META-INF/maven/org.snakeyaml/snakeyaml-engine/pom.properties") ) {
58
57
  props.load(is);
59
58
  }
60
59
  catch( IOException e ) {
@@ -66,27 +65,6 @@ public class PsychLibrary implements Library {
66
65
  snakeyamlVersion = snakeyamlVersion.substring(0, snakeyamlVersion.length() - "-SNAPSHOT".length());
67
66
  }
68
67
 
69
- // Try to determine if we have a new enough SnakeYAML.
70
- // Versions before 1.21 removed a Mark constructor that JRuby uses.
71
- // See https://github.com/bundler/bundler/issues/6878
72
- if (snakeyamlVersion.equals(DUMMY_VERSION)) {
73
- try {
74
- // Use reflection to try to confirm we have a new enough version
75
- Mark.class.getConstructor(String.class, int.class, int.class, int.class, int[].class, int.class);
76
- } catch (NoSuchMethodException nsme) {
77
- throw runtime.newLoadError("bad SnakeYAML version, required 1.21 or higher; check your CLASSPATH for a conflicting jar");
78
- }
79
- } else {
80
- // Parse version string to check for 1.21+
81
- String[] majorMinor = snakeyamlVersion.split("\\.");
82
-
83
- if (majorMinor.length < 2 || Integer.parseInt(majorMinor[0]) < 1 || Integer.parseInt(majorMinor[1]) < 21) {
84
- throw runtime.newLoadError(
85
- "bad SnakeYAML version " + snakeyamlVersion +
86
- ", required 1.21 or higher; check your CLASSPATH for a conflicting jar");
87
- }
88
- }
89
-
90
68
  RubyString version = runtime.newString(snakeyamlVersion + ".0");
91
69
  version.setFrozen(true);
92
70
  psych.setConstant("SNAKEYAML_VERSION", version);
@@ -105,7 +83,6 @@ public class PsychLibrary implements Library {
105
83
  PsychParser.initPsychParser(runtime, psych);
106
84
  PsychEmitter.initPsychEmitter(runtime, psych);
107
85
  PsychToRuby.initPsychToRuby(runtime, psych);
108
- PsychYamlTree.initPsychYamlTree(runtime, psych);
109
86
  }
110
87
 
111
88
  public enum YAMLEncoding {