psych 5.1.2-java → 5.2.0.beta1-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de2fb8d733d55c79078d206c343c541f29c35e94ba7c00f3f1bbafec78db195c
4
- data.tar.gz: 867fa62c0f0f0c36c5c552f0e68ba3991027fe83b5552460de6a38cc083b2431
3
+ metadata.gz: 62077f615c2d7278e5baeb3bb7c909b5f17782ed816e9fb560f9edb9912fc0e1
4
+ data.tar.gz: 7cfa68a9cc5255ee948ef4084e17b1fe617d426ac340c47e181713586ec54912
5
5
  SHA512:
6
- metadata.gz: 3e82efb8852dfb62ae7cc93e056056d3ea1afd532c091907472e9ff1943f2b646c734a2df60fe28e93dd4bbe1922278a3e1ed5bc2ff6ff0c8258dbc07ee271ff
7
- data.tar.gz: 2585468bb883d8f07d9ebe02d1b37a2f2beee8897901765a9674ee82b2d5a18c372f38a8b4f2674c447de55f2433c6bc75d93fb28db102cf4cb258e52d55c015
6
+ metadata.gz: e5c7c466a685c541f6a48c8b99fe95e210e3ff7119ecb6f639d32536e7f7f637b074b2cd3b367925931df5bc73c2465347b196d84b0ca3e946dbf21338a09bc5
7
+ data.tar.gz: ca4769b88d733f973b95185ca11914c6df57692758fd531f4569f5e12fad02c67360883498bbd7dda7f102d0e9406c27dad9e6ed1f5c3f8e2d4c5c39f62f2990
data/ext/psych/psych.c CHANGED
@@ -23,7 +23,7 @@ VALUE mPsych;
23
23
  void Init_psych(void)
24
24
  {
25
25
  #ifdef HAVE_RB_EXT_RACTOR_SAFE
26
- RB_EXT_RACTOR_SAFE(true);
26
+ RB_EXT_RACTOR_SAFE(true);
27
27
  #endif
28
28
  mPsych = rb_define_module("Psych");
29
29
 
@@ -17,7 +17,7 @@ static ID id_canonical;
17
17
  static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
18
18
  {
19
19
  if(!yaml_emitter_emit(emitter, event))
20
- rb_raise(rb_eRuntimeError, "%s", emitter->problem);
20
+ rb_raise(rb_eRuntimeError, "%s", emitter->problem);
21
21
  }
22
22
 
23
23
  static int writer(void *ctx, unsigned char *buffer, size_t size)
@@ -82,13 +82,13 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
82
82
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
83
83
 
84
84
  if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
85
- line_width = rb_funcall(options, id_line_width, 0);
86
- indent = rb_funcall(options, id_indentation, 0);
87
- canonical = rb_funcall(options, id_canonical, 0);
85
+ line_width = rb_funcall(options, id_line_width, 0);
86
+ indent = rb_funcall(options, id_indentation, 0);
87
+ canonical = rb_funcall(options, id_canonical, 0);
88
88
 
89
- yaml_emitter_set_width(emitter, NUM2INT(line_width));
90
- yaml_emitter_set_indent(emitter, NUM2INT(indent));
91
- yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
89
+ yaml_emitter_set_width(emitter, NUM2INT(line_width));
90
+ yaml_emitter_set_indent(emitter, NUM2INT(indent));
91
+ yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
92
92
  }
93
93
 
94
94
  rb_ivar_set(self, id_io, io);
@@ -136,84 +136,118 @@ static VALUE end_stream(VALUE self)
136
136
  return self;
137
137
  }
138
138
 
139
- /* call-seq: emitter.start_document(version, tags, implicit)
140
- *
141
- * Start a document emission with YAML +version+, +tags+, and an +implicit+
142
- * start.
143
- *
144
- * See Psych::Handler#start_document
145
- */
146
- static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
139
+ struct start_document_data {
140
+ VALUE self;
141
+ VALUE version;
142
+ VALUE tags;
143
+ VALUE imp;
144
+
145
+ yaml_tag_directive_t * head;
146
+ };
147
+
148
+ static VALUE start_document_try(VALUE d)
147
149
  {
150
+ struct start_document_data * data = (struct start_document_data *)d;
151
+ VALUE self = data->self;
152
+ VALUE version = data->version;
153
+ VALUE tags = data->tags;
154
+ VALUE imp = data->imp;
155
+
148
156
  yaml_emitter_t * emitter;
149
- yaml_tag_directive_t * head = NULL;
150
157
  yaml_tag_directive_t * tail = NULL;
151
158
  yaml_event_t event;
152
159
  yaml_version_directive_t version_directive;
153
160
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
154
161
 
155
-
156
162
  Check_Type(version, T_ARRAY);
157
163
 
158
164
  if(RARRAY_LEN(version) > 0) {
159
- VALUE major = rb_ary_entry(version, (long)0);
160
- VALUE minor = rb_ary_entry(version, (long)1);
165
+ VALUE major = rb_ary_entry(version, (long)0);
166
+ VALUE minor = rb_ary_entry(version, (long)1);
161
167
 
162
- version_directive.major = NUM2INT(major);
163
- version_directive.minor = NUM2INT(minor);
168
+ version_directive.major = NUM2INT(major);
169
+ version_directive.minor = NUM2INT(minor);
164
170
  }
165
171
 
166
172
  if(RTEST(tags)) {
167
- long i = 0;
168
- long len;
169
- rb_encoding * encoding = rb_utf8_encoding();
170
-
171
- Check_Type(tags, T_ARRAY);
172
-
173
- len = RARRAY_LEN(tags);
174
- head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
175
- tail = head;
176
-
177
- for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
178
- VALUE tuple = RARRAY_AREF(tags, i);
179
- VALUE name;
180
- VALUE value;
181
-
182
- Check_Type(tuple, T_ARRAY);
183
-
184
- if(RARRAY_LEN(tuple) < 2) {
185
- xfree(head);
186
- rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
187
- }
188
- name = RARRAY_AREF(tuple, 0);
189
- value = RARRAY_AREF(tuple, 1);
190
- StringValue(name);
191
- StringValue(value);
192
- name = rb_str_export_to_enc(name, encoding);
193
- value = rb_str_export_to_enc(value, encoding);
194
-
195
- tail->handle = (yaml_char_t *)StringValueCStr(name);
196
- tail->prefix = (yaml_char_t *)StringValueCStr(value);
197
-
198
- tail++;
199
- }
173
+ long i = 0;
174
+ long len;
175
+ rb_encoding * encoding = rb_utf8_encoding();
176
+
177
+ Check_Type(tags, T_ARRAY);
178
+
179
+ len = RARRAY_LEN(tags);
180
+ data->head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
181
+ tail = data->head;
182
+
183
+ for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
184
+ VALUE tuple = RARRAY_AREF(tags, i);
185
+ VALUE name;
186
+ VALUE value;
187
+
188
+ Check_Type(tuple, T_ARRAY);
189
+
190
+ if(RARRAY_LEN(tuple) < 2) {
191
+ rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
192
+ }
193
+
194
+ name = RARRAY_AREF(tuple, 0);
195
+ value = RARRAY_AREF(tuple, 1);
196
+ StringValue(name);
197
+ StringValue(value);
198
+ name = rb_str_export_to_enc(name, encoding);
199
+ value = rb_str_export_to_enc(value, encoding);
200
+
201
+ tail->handle = (yaml_char_t *)StringValueCStr(name);
202
+ tail->prefix = (yaml_char_t *)StringValueCStr(value);
203
+
204
+ tail++;
205
+ }
200
206
  }
201
207
 
202
208
  yaml_document_start_event_initialize(
203
- &event,
204
- (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
205
- head,
206
- tail,
207
- imp ? 1 : 0
208
- );
209
+ &event,
210
+ (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
211
+ data->head,
212
+ tail,
213
+ imp ? 1 : 0
214
+ );
209
215
 
210
216
  emit(emitter, &event);
211
217
 
212
- if(head) xfree(head);
213
-
214
218
  return self;
215
219
  }
216
220
 
221
+ static VALUE start_document_ensure(VALUE d)
222
+ {
223
+ struct start_document_data * data = (struct start_document_data *)d;
224
+
225
+ xfree(data->head);
226
+
227
+ return Qnil;
228
+ }
229
+
230
+ /* call-seq: emitter.start_document(version, tags, implicit)
231
+ *
232
+ * Start a document emission with YAML +version+, +tags+, and an +implicit+
233
+ * start.
234
+ *
235
+ * See Psych::Handler#start_document
236
+ */
237
+ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
238
+ {
239
+ struct start_document_data data = {
240
+ .self = self,
241
+ .version = version,
242
+ .tags = tags,
243
+ .imp = imp,
244
+
245
+ .head = NULL,
246
+ };
247
+
248
+ return rb_ensure(start_document_try, (VALUE)&data, start_document_ensure, (VALUE)&data);
249
+ }
250
+
217
251
  /* call-seq: emitter.end_document(implicit)
218
252
  *
219
253
  * End a document emission with an +implicit+ ending.
@@ -241,14 +275,14 @@ static VALUE end_document(VALUE self, VALUE imp)
241
275
  * See Psych::Handler#scalar
242
276
  */
243
277
  static VALUE scalar(
244
- VALUE self,
245
- VALUE value,
246
- VALUE anchor,
247
- VALUE tag,
248
- VALUE plain,
249
- VALUE quoted,
250
- VALUE style
251
- ) {
278
+ VALUE self,
279
+ VALUE value,
280
+ VALUE anchor,
281
+ VALUE tag,
282
+ VALUE plain,
283
+ VALUE quoted,
284
+ VALUE style
285
+ ) {
252
286
  yaml_emitter_t * emitter;
253
287
  yaml_event_t event;
254
288
  rb_encoding *encoding;
@@ -261,25 +295,25 @@ static VALUE scalar(
261
295
  value = rb_str_export_to_enc(value, encoding);
262
296
 
263
297
  if(!NIL_P(anchor)) {
264
- Check_Type(anchor, T_STRING);
265
- anchor = rb_str_export_to_enc(anchor, encoding);
298
+ Check_Type(anchor, T_STRING);
299
+ anchor = rb_str_export_to_enc(anchor, encoding);
266
300
  }
267
301
 
268
302
  if(!NIL_P(tag)) {
269
- Check_Type(tag, T_STRING);
270
- tag = rb_str_export_to_enc(tag, encoding);
303
+ Check_Type(tag, T_STRING);
304
+ tag = rb_str_export_to_enc(tag, encoding);
271
305
  }
272
306
 
273
307
  yaml_scalar_event_initialize(
274
- &event,
275
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
276
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
277
- (yaml_char_t*)StringValuePtr(value),
278
- (int)RSTRING_LEN(value),
279
- plain ? 1 : 0,
280
- quoted ? 1 : 0,
281
- (yaml_scalar_style_t)NUM2INT(style)
282
- );
308
+ &event,
309
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
310
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
311
+ (yaml_char_t*)StringValuePtr(value),
312
+ (int)RSTRING_LEN(value),
313
+ plain ? 1 : 0,
314
+ quoted ? 1 : 0,
315
+ (yaml_scalar_style_t)NUM2INT(style)
316
+ );
283
317
 
284
318
  emit(emitter, &event);
285
319
 
@@ -294,36 +328,36 @@ static VALUE scalar(
294
328
  * See Psych::Handler#start_sequence
295
329
  */
296
330
  static VALUE start_sequence(
297
- VALUE self,
298
- VALUE anchor,
299
- VALUE tag,
300
- VALUE implicit,
301
- VALUE style
302
- ) {
331
+ VALUE self,
332
+ VALUE anchor,
333
+ VALUE tag,
334
+ VALUE implicit,
335
+ VALUE style
336
+ ) {
303
337
  yaml_emitter_t * emitter;
304
338
  yaml_event_t event;
305
339
 
306
340
  rb_encoding * encoding = rb_utf8_encoding();
307
341
 
308
342
  if(!NIL_P(anchor)) {
309
- Check_Type(anchor, T_STRING);
310
- anchor = rb_str_export_to_enc(anchor, encoding);
343
+ Check_Type(anchor, T_STRING);
344
+ anchor = rb_str_export_to_enc(anchor, encoding);
311
345
  }
312
346
 
313
347
  if(!NIL_P(tag)) {
314
- Check_Type(tag, T_STRING);
315
- tag = rb_str_export_to_enc(tag, encoding);
348
+ Check_Type(tag, T_STRING);
349
+ tag = rb_str_export_to_enc(tag, encoding);
316
350
  }
317
351
 
318
352
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
319
353
 
320
354
  yaml_sequence_start_event_initialize(
321
- &event,
322
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
323
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
324
- implicit ? 1 : 0,
325
- (yaml_sequence_style_t)NUM2INT(style)
326
- );
355
+ &event,
356
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
357
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
358
+ implicit ? 1 : 0,
359
+ (yaml_sequence_style_t)NUM2INT(style)
360
+ );
327
361
 
328
362
  emit(emitter, &event);
329
363
 
@@ -357,12 +391,12 @@ static VALUE end_sequence(VALUE self)
357
391
  * See Psych::Handler#start_mapping
358
392
  */
359
393
  static VALUE start_mapping(
360
- VALUE self,
361
- VALUE anchor,
362
- VALUE tag,
363
- VALUE implicit,
364
- VALUE style
365
- ) {
394
+ VALUE self,
395
+ VALUE anchor,
396
+ VALUE tag,
397
+ VALUE implicit,
398
+ VALUE style
399
+ ) {
366
400
  yaml_emitter_t * emitter;
367
401
  yaml_event_t event;
368
402
  rb_encoding *encoding;
@@ -372,22 +406,22 @@ static VALUE start_mapping(
372
406
  encoding = rb_utf8_encoding();
373
407
 
374
408
  if(!NIL_P(anchor)) {
375
- Check_Type(anchor, T_STRING);
376
- anchor = rb_str_export_to_enc(anchor, encoding);
409
+ Check_Type(anchor, T_STRING);
410
+ anchor = rb_str_export_to_enc(anchor, encoding);
377
411
  }
378
412
 
379
413
  if(!NIL_P(tag)) {
380
- Check_Type(tag, T_STRING);
381
- tag = rb_str_export_to_enc(tag, encoding);
414
+ Check_Type(tag, T_STRING);
415
+ tag = rb_str_export_to_enc(tag, encoding);
382
416
  }
383
417
 
384
418
  yaml_mapping_start_event_initialize(
385
- &event,
386
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
387
- (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
388
- implicit ? 1 : 0,
389
- (yaml_mapping_style_t)NUM2INT(style)
390
- );
419
+ &event,
420
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
421
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
422
+ implicit ? 1 : 0,
423
+ (yaml_mapping_style_t)NUM2INT(style)
424
+ );
391
425
 
392
426
  emit(emitter, &event);
393
427
 
@@ -426,14 +460,14 @@ static VALUE alias(VALUE self, VALUE anchor)
426
460
  TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
427
461
 
428
462
  if(!NIL_P(anchor)) {
429
- Check_Type(anchor, T_STRING);
430
- anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
463
+ Check_Type(anchor, T_STRING);
464
+ anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
431
465
  }
432
466
 
433
467
  yaml_alias_event_initialize(
434
- &event,
435
- (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
436
- );
468
+ &event,
469
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
470
+ );
437
471
 
438
472
  emit(emitter, &event);
439
473
 
@@ -32,9 +32,9 @@ static int io_reader(void * data, unsigned char *buf, size_t size, size_t *read)
32
32
  *read = 0;
33
33
 
34
34
  if(! NIL_P(string)) {
35
- void * str = (void *)StringValuePtr(string);
36
- *read = (size_t)RSTRING_LEN(string);
37
- memcpy(buf, str, *read);
35
+ void * str = (void *)StringValuePtr(string);
36
+ *read = (size_t)RSTRING_LEN(string);
37
+ memcpy(buf, str, *read);
38
38
  }
39
39
 
40
40
  return 1;
@@ -80,23 +80,23 @@ static VALUE allocate(VALUE klass)
80
80
  static VALUE make_exception(yaml_parser_t * parser, VALUE path)
81
81
  {
82
82
  if (parser->error == YAML_MEMORY_ERROR) {
83
- return rb_eNoMemError;
83
+ return rb_eNoMemError;
84
84
  } else {
85
- size_t line, column;
86
- VALUE ePsychSyntaxError;
85
+ size_t line, column;
86
+ VALUE ePsychSyntaxError;
87
87
 
88
- line = parser->context_mark.line + 1;
89
- column = parser->context_mark.column + 1;
88
+ line = parser->context_mark.line + 1;
89
+ column = parser->context_mark.column + 1;
90
90
 
91
- ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
91
+ ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
92
92
 
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);
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
100
  }
101
101
  }
102
102
 
@@ -108,18 +108,18 @@ static VALUE transcode_string(VALUE src, int * parser_encoding)
108
108
  int source_encoding = rb_enc_get_index(src);
109
109
 
110
110
  if (source_encoding == utf8) {
111
- *parser_encoding = YAML_UTF8_ENCODING;
112
- return src;
111
+ *parser_encoding = YAML_UTF8_ENCODING;
112
+ return src;
113
113
  }
114
114
 
115
115
  if (source_encoding == utf16le) {
116
- *parser_encoding = YAML_UTF16LE_ENCODING;
117
- return src;
116
+ *parser_encoding = YAML_UTF16LE_ENCODING;
117
+ return src;
118
118
  }
119
119
 
120
120
  if (source_encoding == utf16be) {
121
- *parser_encoding = YAML_UTF16BE_ENCODING;
122
- return src;
121
+ *parser_encoding = YAML_UTF16BE_ENCODING;
122
+ return src;
123
123
  }
124
124
 
125
125
  src = rb_str_export_to_enc(src, rb_utf8_encoding());
@@ -138,36 +138,36 @@ static VALUE transcode_io(VALUE src, int * parser_encoding)
138
138
 
139
139
  /* if no encoding is returned, assume ascii8bit. */
140
140
  if (NIL_P(io_external_encoding)) {
141
- io_external_enc_index = rb_ascii8bit_encindex();
141
+ io_external_enc_index = rb_ascii8bit_encindex();
142
142
  } else {
143
- io_external_enc_index = rb_to_encoding_index(io_external_encoding);
143
+ io_external_enc_index = rb_to_encoding_index(io_external_encoding);
144
144
  }
145
145
 
146
146
  /* Treat US-ASCII as utf_8 */
147
147
  if (io_external_enc_index == rb_usascii_encindex()) {
148
- *parser_encoding = YAML_UTF8_ENCODING;
149
- return src;
148
+ *parser_encoding = YAML_UTF8_ENCODING;
149
+ return src;
150
150
  }
151
151
 
152
152
  if (io_external_enc_index == rb_utf8_encindex()) {
153
- *parser_encoding = YAML_UTF8_ENCODING;
154
- return src;
153
+ *parser_encoding = YAML_UTF8_ENCODING;
154
+ return src;
155
155
  }
156
156
 
157
157
  if (io_external_enc_index == rb_enc_find_index("UTF-16LE")) {
158
- *parser_encoding = YAML_UTF16LE_ENCODING;
159
- return src;
158
+ *parser_encoding = YAML_UTF16LE_ENCODING;
159
+ return src;
160
160
  }
161
161
 
162
162
  if (io_external_enc_index == rb_enc_find_index("UTF-16BE")) {
163
- *parser_encoding = YAML_UTF16BE_ENCODING;
164
- return src;
163
+ *parser_encoding = YAML_UTF16BE_ENCODING;
164
+ return src;
165
165
  }
166
166
 
167
167
  /* Just guess on ASCII-8BIT */
168
168
  if (io_external_enc_index == rb_ascii8bit_encindex()) {
169
- *parser_encoding = YAML_ANY_ENCODING;
170
- return src;
169
+ *parser_encoding = YAML_ANY_ENCODING;
170
+ return src;
171
171
  }
172
172
 
173
173
  /* If the external encoding is something we don't know how to handle,
@@ -261,238 +261,238 @@ static VALUE parse(VALUE self, VALUE handler, VALUE yaml, VALUE path)
261
261
  yaml_parser_initialize(parser);
262
262
 
263
263
  if (rb_respond_to(yaml, id_read)) {
264
- yaml = transcode_io(yaml, &parser_encoding);
265
- yaml_parser_set_encoding(parser, parser_encoding);
266
- yaml_parser_set_input(parser, io_reader, (void *)yaml);
264
+ yaml = transcode_io(yaml, &parser_encoding);
265
+ yaml_parser_set_encoding(parser, parser_encoding);
266
+ yaml_parser_set_input(parser, io_reader, (void *)yaml);
267
267
  } else {
268
- StringValue(yaml);
269
- yaml = transcode_string(yaml, &parser_encoding);
270
- yaml_parser_set_encoding(parser, parser_encoding);
271
- yaml_parser_set_input_string(
272
- parser,
273
- (const unsigned char *)RSTRING_PTR(yaml),
274
- (size_t)RSTRING_LEN(yaml)
275
- );
268
+ StringValue(yaml);
269
+ yaml = transcode_string(yaml, &parser_encoding);
270
+ yaml_parser_set_encoding(parser, parser_encoding);
271
+ yaml_parser_set_input_string(
272
+ parser,
273
+ (const unsigned char *)RSTRING_PTR(yaml),
274
+ (size_t)RSTRING_LEN(yaml)
275
+ );
276
276
  }
277
277
 
278
278
  while(!done) {
279
- VALUE event_args[5];
280
- VALUE start_line, start_column, end_line, end_column;
281
-
282
- if(parser->error || !yaml_parser_parse(parser, &event)) {
283
- VALUE exception;
284
-
285
- exception = make_exception(parser, path);
286
- yaml_parser_delete(parser);
287
- yaml_parser_initialize(parser);
288
-
289
- rb_exc_raise(exception);
290
- }
291
-
292
- start_line = SIZET2NUM(event.start_mark.line);
293
- start_column = SIZET2NUM(event.start_mark.column);
294
- end_line = SIZET2NUM(event.end_mark.line);
295
- end_column = SIZET2NUM(event.end_mark.column);
296
-
297
- event_args[0] = handler;
298
- event_args[1] = start_line;
299
- event_args[2] = start_column;
300
- event_args[3] = end_line;
301
- event_args[4] = end_column;
302
- rb_protect(protected_event_location, (VALUE)event_args, &state);
303
-
304
- switch(event.type) {
305
- case YAML_STREAM_START_EVENT:
306
- {
307
- VALUE args[2];
308
-
309
- args[0] = handler;
310
- args[1] = INT2NUM(event.data.stream_start.encoding);
311
- rb_protect(protected_start_stream, (VALUE)args, &state);
312
- }
313
- break;
314
- case YAML_DOCUMENT_START_EVENT:
315
- {
316
- VALUE args[4];
317
- /* Get a list of tag directives (if any) */
318
- VALUE tag_directives = rb_ary_new();
319
- /* Grab the document version */
320
- VALUE version = event.data.document_start.version_directive ?
321
- rb_ary_new3(
322
- (long)2,
323
- INT2NUM(event.data.document_start.version_directive->major),
324
- INT2NUM(event.data.document_start.version_directive->minor)
325
- ) : rb_ary_new();
326
-
327
- if(event.data.document_start.tag_directives.start) {
328
- yaml_tag_directive_t *start =
329
- event.data.document_start.tag_directives.start;
330
- yaml_tag_directive_t *end =
331
- event.data.document_start.tag_directives.end;
332
- for(; start != end; start++) {
333
- VALUE handle = Qnil;
334
- VALUE prefix = Qnil;
335
- if(start->handle) {
336
- handle = rb_str_new2((const char *)start->handle);
337
- PSYCH_TRANSCODE(handle, encoding, internal_enc);
338
- }
339
-
340
- if(start->prefix) {
341
- prefix = rb_str_new2((const char *)start->prefix);
342
- PSYCH_TRANSCODE(prefix, encoding, internal_enc);
343
- }
344
-
345
- rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix));
346
- }
347
- }
348
- args[0] = handler;
349
- args[1] = version;
350
- args[2] = tag_directives;
351
- args[3] = event.data.document_start.implicit == 1 ? Qtrue : Qfalse;
352
- rb_protect(protected_start_document, (VALUE)args, &state);
353
- }
354
- break;
355
- case YAML_DOCUMENT_END_EVENT:
356
- {
357
- VALUE args[2];
358
-
359
- args[0] = handler;
360
- args[1] = event.data.document_end.implicit == 1 ? Qtrue : Qfalse;
361
- rb_protect(protected_end_document, (VALUE)args, &state);
362
- }
363
- break;
364
- case YAML_ALIAS_EVENT:
365
- {
366
- VALUE args[2];
367
- VALUE alias = Qnil;
368
- if(event.data.alias.anchor) {
369
- alias = rb_str_new2((const char *)event.data.alias.anchor);
370
- PSYCH_TRANSCODE(alias, encoding, internal_enc);
371
- }
372
-
373
- args[0] = handler;
374
- args[1] = alias;
375
- rb_protect(protected_alias, (VALUE)args, &state);
376
- }
377
- break;
378
- case YAML_SCALAR_EVENT:
379
- {
380
- VALUE args[7];
381
- VALUE anchor = Qnil;
382
- VALUE tag = Qnil;
383
- VALUE plain_implicit, quoted_implicit, style;
384
- VALUE val = rb_str_new(
385
- (const char *)event.data.scalar.value,
386
- (long)event.data.scalar.length
387
- );
388
-
389
- PSYCH_TRANSCODE(val, encoding, internal_enc);
390
-
391
- if(event.data.scalar.anchor) {
392
- anchor = rb_str_new2((const char *)event.data.scalar.anchor);
393
- PSYCH_TRANSCODE(anchor, encoding, internal_enc);
394
- }
395
-
396
- if(event.data.scalar.tag) {
397
- tag = rb_str_new2((const char *)event.data.scalar.tag);
398
- PSYCH_TRANSCODE(tag, encoding, internal_enc);
399
- }
400
-
401
- plain_implicit =
402
- event.data.scalar.plain_implicit == 0 ? Qfalse : Qtrue;
403
-
404
- quoted_implicit =
405
- event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue;
406
-
407
- style = INT2NUM(event.data.scalar.style);
408
-
409
- args[0] = handler;
410
- args[1] = val;
411
- args[2] = anchor;
412
- args[3] = tag;
413
- args[4] = plain_implicit;
414
- args[5] = quoted_implicit;
415
- args[6] = style;
416
- rb_protect(protected_scalar, (VALUE)args, &state);
417
- }
418
- break;
419
- case YAML_SEQUENCE_START_EVENT:
420
- {
421
- VALUE args[5];
422
- VALUE anchor = Qnil;
423
- VALUE tag = Qnil;
424
- VALUE implicit, style;
425
- if(event.data.sequence_start.anchor) {
426
- anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
427
- PSYCH_TRANSCODE(anchor, encoding, internal_enc);
428
- }
429
-
430
- tag = Qnil;
431
- if(event.data.sequence_start.tag) {
432
- tag = rb_str_new2((const char *)event.data.sequence_start.tag);
433
- PSYCH_TRANSCODE(tag, encoding, internal_enc);
434
- }
435
-
436
- implicit =
437
- event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue;
438
-
439
- style = INT2NUM(event.data.sequence_start.style);
440
-
441
- args[0] = handler;
442
- args[1] = anchor;
443
- args[2] = tag;
444
- args[3] = implicit;
445
- args[4] = style;
446
-
447
- rb_protect(protected_start_sequence, (VALUE)args, &state);
448
- }
449
- break;
450
- case YAML_SEQUENCE_END_EVENT:
451
- rb_protect(protected_end_sequence, handler, &state);
452
- break;
453
- case YAML_MAPPING_START_EVENT:
454
- {
455
- VALUE args[5];
456
- VALUE anchor = Qnil;
457
- VALUE tag = Qnil;
458
- VALUE implicit, style;
459
- if(event.data.mapping_start.anchor) {
460
- anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
461
- PSYCH_TRANSCODE(anchor, encoding, internal_enc);
462
- }
463
-
464
- if(event.data.mapping_start.tag) {
465
- tag = rb_str_new2((const char *)event.data.mapping_start.tag);
466
- PSYCH_TRANSCODE(tag, encoding, internal_enc);
467
- }
468
-
469
- implicit =
470
- event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue;
471
-
472
- style = INT2NUM(event.data.mapping_start.style);
473
-
474
- args[0] = handler;
475
- args[1] = anchor;
476
- args[2] = tag;
477
- args[3] = implicit;
478
- args[4] = style;
479
-
480
- rb_protect(protected_start_mapping, (VALUE)args, &state);
481
- }
482
- break;
483
- case YAML_MAPPING_END_EVENT:
484
- rb_protect(protected_end_mapping, handler, &state);
485
- break;
486
- case YAML_NO_EVENT:
487
- rb_protect(protected_empty, handler, &state);
488
- break;
489
- case YAML_STREAM_END_EVENT:
490
- rb_protect(protected_end_stream, handler, &state);
491
- done = 1;
492
- break;
493
- }
494
- yaml_event_delete(&event);
495
- if (state) rb_jump_tag(state);
279
+ VALUE event_args[5];
280
+ VALUE start_line, start_column, end_line, end_column;
281
+
282
+ if(parser->error || !yaml_parser_parse(parser, &event)) {
283
+ VALUE exception;
284
+
285
+ exception = make_exception(parser, path);
286
+ yaml_parser_delete(parser);
287
+ yaml_parser_initialize(parser);
288
+
289
+ rb_exc_raise(exception);
290
+ }
291
+
292
+ start_line = SIZET2NUM(event.start_mark.line);
293
+ start_column = SIZET2NUM(event.start_mark.column);
294
+ end_line = SIZET2NUM(event.end_mark.line);
295
+ end_column = SIZET2NUM(event.end_mark.column);
296
+
297
+ event_args[0] = handler;
298
+ event_args[1] = start_line;
299
+ event_args[2] = start_column;
300
+ event_args[3] = end_line;
301
+ event_args[4] = end_column;
302
+ rb_protect(protected_event_location, (VALUE)event_args, &state);
303
+
304
+ switch(event.type) {
305
+ case YAML_STREAM_START_EVENT:
306
+ {
307
+ VALUE args[2];
308
+
309
+ args[0] = handler;
310
+ args[1] = INT2NUM(event.data.stream_start.encoding);
311
+ rb_protect(protected_start_stream, (VALUE)args, &state);
312
+ }
313
+ break;
314
+ case YAML_DOCUMENT_START_EVENT:
315
+ {
316
+ VALUE args[4];
317
+ /* Get a list of tag directives (if any) */
318
+ VALUE tag_directives = rb_ary_new();
319
+ /* Grab the document version */
320
+ VALUE version = event.data.document_start.version_directive ?
321
+ rb_ary_new3(
322
+ (long)2,
323
+ INT2NUM(event.data.document_start.version_directive->major),
324
+ INT2NUM(event.data.document_start.version_directive->minor)
325
+ ) : rb_ary_new();
326
+
327
+ if(event.data.document_start.tag_directives.start) {
328
+ yaml_tag_directive_t *start =
329
+ event.data.document_start.tag_directives.start;
330
+ yaml_tag_directive_t *end =
331
+ event.data.document_start.tag_directives.end;
332
+ for(; start != end; start++) {
333
+ VALUE handle = Qnil;
334
+ VALUE prefix = Qnil;
335
+ if(start->handle) {
336
+ handle = rb_str_new2((const char *)start->handle);
337
+ PSYCH_TRANSCODE(handle, encoding, internal_enc);
338
+ }
339
+
340
+ if(start->prefix) {
341
+ prefix = rb_str_new2((const char *)start->prefix);
342
+ PSYCH_TRANSCODE(prefix, encoding, internal_enc);
343
+ }
344
+
345
+ rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix));
346
+ }
347
+ }
348
+ args[0] = handler;
349
+ args[1] = version;
350
+ args[2] = tag_directives;
351
+ args[3] = event.data.document_start.implicit == 1 ? Qtrue : Qfalse;
352
+ rb_protect(protected_start_document, (VALUE)args, &state);
353
+ }
354
+ break;
355
+ case YAML_DOCUMENT_END_EVENT:
356
+ {
357
+ VALUE args[2];
358
+
359
+ args[0] = handler;
360
+ args[1] = event.data.document_end.implicit == 1 ? Qtrue : Qfalse;
361
+ rb_protect(protected_end_document, (VALUE)args, &state);
362
+ }
363
+ break;
364
+ case YAML_ALIAS_EVENT:
365
+ {
366
+ VALUE args[2];
367
+ VALUE alias = Qnil;
368
+ if(event.data.alias.anchor) {
369
+ alias = rb_str_new2((const char *)event.data.alias.anchor);
370
+ PSYCH_TRANSCODE(alias, encoding, internal_enc);
371
+ }
372
+
373
+ args[0] = handler;
374
+ args[1] = alias;
375
+ rb_protect(protected_alias, (VALUE)args, &state);
376
+ }
377
+ break;
378
+ case YAML_SCALAR_EVENT:
379
+ {
380
+ VALUE args[7];
381
+ VALUE anchor = Qnil;
382
+ VALUE tag = Qnil;
383
+ VALUE plain_implicit, quoted_implicit, style;
384
+ VALUE val = rb_str_new(
385
+ (const char *)event.data.scalar.value,
386
+ (long)event.data.scalar.length
387
+ );
388
+
389
+ PSYCH_TRANSCODE(val, encoding, internal_enc);
390
+
391
+ if(event.data.scalar.anchor) {
392
+ anchor = rb_str_new2((const char *)event.data.scalar.anchor);
393
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
394
+ }
395
+
396
+ if(event.data.scalar.tag) {
397
+ tag = rb_str_new2((const char *)event.data.scalar.tag);
398
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
399
+ }
400
+
401
+ plain_implicit =
402
+ event.data.scalar.plain_implicit == 0 ? Qfalse : Qtrue;
403
+
404
+ quoted_implicit =
405
+ event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue;
406
+
407
+ style = INT2NUM(event.data.scalar.style);
408
+
409
+ args[0] = handler;
410
+ args[1] = val;
411
+ args[2] = anchor;
412
+ args[3] = tag;
413
+ args[4] = plain_implicit;
414
+ args[5] = quoted_implicit;
415
+ args[6] = style;
416
+ rb_protect(protected_scalar, (VALUE)args, &state);
417
+ }
418
+ break;
419
+ case YAML_SEQUENCE_START_EVENT:
420
+ {
421
+ VALUE args[5];
422
+ VALUE anchor = Qnil;
423
+ VALUE tag = Qnil;
424
+ VALUE implicit, style;
425
+ if(event.data.sequence_start.anchor) {
426
+ anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
427
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
428
+ }
429
+
430
+ tag = Qnil;
431
+ if(event.data.sequence_start.tag) {
432
+ tag = rb_str_new2((const char *)event.data.sequence_start.tag);
433
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
434
+ }
435
+
436
+ implicit =
437
+ event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue;
438
+
439
+ style = INT2NUM(event.data.sequence_start.style);
440
+
441
+ args[0] = handler;
442
+ args[1] = anchor;
443
+ args[2] = tag;
444
+ args[3] = implicit;
445
+ args[4] = style;
446
+
447
+ rb_protect(protected_start_sequence, (VALUE)args, &state);
448
+ }
449
+ break;
450
+ case YAML_SEQUENCE_END_EVENT:
451
+ rb_protect(protected_end_sequence, handler, &state);
452
+ break;
453
+ case YAML_MAPPING_START_EVENT:
454
+ {
455
+ VALUE args[5];
456
+ VALUE anchor = Qnil;
457
+ VALUE tag = Qnil;
458
+ VALUE implicit, style;
459
+ if(event.data.mapping_start.anchor) {
460
+ anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
461
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
462
+ }
463
+
464
+ if(event.data.mapping_start.tag) {
465
+ tag = rb_str_new2((const char *)event.data.mapping_start.tag);
466
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
467
+ }
468
+
469
+ implicit =
470
+ event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue;
471
+
472
+ style = INT2NUM(event.data.mapping_start.style);
473
+
474
+ args[0] = handler;
475
+ args[1] = anchor;
476
+ args[2] = tag;
477
+ args[3] = implicit;
478
+ args[4] = style;
479
+
480
+ rb_protect(protected_start_mapping, (VALUE)args, &state);
481
+ }
482
+ break;
483
+ case YAML_MAPPING_END_EVENT:
484
+ rb_protect(protected_end_mapping, handler, &state);
485
+ break;
486
+ case YAML_NO_EVENT:
487
+ rb_protect(protected_empty, handler, &state);
488
+ break;
489
+ case YAML_STREAM_END_EVENT:
490
+ rb_protect(protected_end_stream, handler, &state);
491
+ done = 1;
492
+ break;
493
+ }
494
+ yaml_event_delete(&event);
495
+ if (state) rb_jump_tag(state);
496
496
  }
497
497
 
498
498
  return self;
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'stringio'
3
2
  require_relative '../class_loader'
4
3
  require_relative '../scalar_scanner'
5
4
 
@@ -56,6 +55,7 @@ module Psych
56
55
  #
57
56
  # See also Psych::Visitors::Emitter
58
57
  def yaml io = nil, options = {}
58
+ require "stringio"
59
59
  real_io = io || StringIO.new(''.encode('utf-8'))
60
60
 
61
61
  Visitors::Emitter.new(real_io, options).accept self
@@ -4,6 +4,8 @@ module Psych
4
4
  ###
5
5
  # Scan scalars for built in types
6
6
  class ScalarScanner
7
+ autoload :Date, "date"
8
+
7
9
  # Taken from http://yaml.org/type/timestamp.html
8
10
  TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
9
11
 
@@ -61,7 +63,6 @@ module Psych
61
63
  string
62
64
  end
63
65
  elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
64
- require 'date'
65
66
  begin
66
67
  class_loader.date.strptime(string, '%F', Date::GREGORIAN)
67
68
  rescue ArgumentError
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Psych
4
4
  # The version of Psych you are using
5
- VERSION = '5.1.2'
5
+ VERSION = '5.2.0.beta1'
6
6
 
7
7
  if RUBY_ENGINE == 'jruby'
8
8
  DEFAULT_SNAKEYAML_VERSION = '2.7'.freeze
@@ -17,19 +17,15 @@ module Psych
17
17
  def initialize
18
18
  @obj_to_id = {}.compare_by_identity
19
19
  @obj_to_node = {}.compare_by_identity
20
- @targets = []
21
20
  @counter = 0
22
21
  end
23
22
 
24
23
  def register target, node
25
- @targets << target
26
24
  @obj_to_node[target] = node
27
25
  end
28
26
 
29
27
  def key? target
30
28
  @obj_to_node.key? target
31
- rescue NoMethodError
32
- false
33
29
  end
34
30
 
35
31
  def id_for target
@@ -69,6 +65,7 @@ module Psych
69
65
  fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
70
66
  end
71
67
  end
68
+ @stringify_names = options[:stringify_names]
72
69
  @coders = []
73
70
 
74
71
  @dispatch_cache = Hash.new do |h,klass|
@@ -271,7 +268,7 @@ module Psych
271
268
  tag = 'tag:yaml.org,2002:str'
272
269
  plain = false
273
270
  quote = false
274
- elsif o == 'y' || o == 'n'
271
+ elsif o == 'y' || o == 'Y' || o == 'n' || o == 'N'
275
272
  style = Nodes::Scalar::DOUBLE_QUOTED
276
273
  elsif @line_width && o.length > @line_width
277
274
  style = Nodes::Scalar::FOLDED
@@ -327,7 +324,7 @@ module Psych
327
324
  if o.class == ::Hash
328
325
  register(o, @emitter.start_mapping(nil, nil, true, Psych::Nodes::Mapping::BLOCK))
329
326
  o.each do |k,v|
330
- accept k
327
+ accept(@stringify_names && Symbol === k ? k.to_s : k)
331
328
  accept v
332
329
  end
333
330
  @emitter.end_mapping
@@ -340,7 +337,7 @@ module Psych
340
337
  register(o, @emitter.start_mapping(nil, '!set', false, Psych::Nodes::Mapping::BLOCK))
341
338
 
342
339
  o.each do |k,v|
343
- accept k
340
+ accept(@stringify_names && Symbol === k ? k.to_s : k)
344
341
  accept v
345
342
  end
346
343
 
data/lib/psych.jar CHANGED
Binary file
data/lib/psych.rb CHANGED
@@ -340,7 +340,7 @@ module Psych
340
340
  # provided, the object contained in the first document will be returned.
341
341
  # +filename+ will be used in the exception message if any exception
342
342
  # is raised while parsing. If +yaml+ is empty, it returns
343
- # the specified +fallback+ return value, which defaults to +false+.
343
+ # the specified +fallback+ return value, which defaults to +nil+.
344
344
  #
345
345
  # Raises a Psych::SyntaxError when a YAML syntax error is detected.
346
346
  #
@@ -479,6 +479,7 @@ module Psych
479
479
  #
480
480
  # Default: <tt>2</tt>.
481
481
  # [<tt>:line_width</tt>] Max character to wrap line at.
482
+ # For unlimited line width use <tt>-1</tt>.
482
483
  #
483
484
  # Default: <tt>0</tt> (meaning "wrap at 81").
484
485
  # [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
@@ -489,6 +490,10 @@ module Psych
489
490
  #
490
491
  # Default: <tt>false</tt>.
491
492
  #
493
+ # [<tt>:stringify_names</tt>] Dump symbol keys in Hash objects as string.
494
+ #
495
+ # Default: <tt>false</tt>.
496
+ #
492
497
  # Example:
493
498
  #
494
499
  # # Dump an array, get back a YAML string
@@ -502,6 +507,9 @@ module Psych
502
507
  #
503
508
  # # Dump an array to an IO with indentation set
504
509
  # Psych.dump(['a', ['b']], StringIO.new, indentation: 3)
510
+ #
511
+ # # Dump hash with symbol keys as string
512
+ # Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n"
505
513
  def self.dump o, io = nil, options = {}
506
514
  if Hash === io
507
515
  options = io
@@ -552,6 +560,7 @@ module Psych
552
560
  #
553
561
  # Default: <tt>2</tt>.
554
562
  # [<tt>:line_width</tt>] Max character to wrap line at.
563
+ # For unlimited line width use <tt>-1</tt>.
555
564
  #
556
565
  # Default: <tt>0</tt> (meaning "wrap at 81").
557
566
  # [<tt>:canonical</tt>] Write "canonical" YAML form (very verbose, yet
@@ -562,6 +571,10 @@ module Psych
562
571
  #
563
572
  # Default: <tt>false</tt>.
564
573
  #
574
+ # [<tt>:stringify_names</tt>] Dump symbol keys in Hash objects as string.
575
+ #
576
+ # Default: <tt>false</tt>.
577
+ #
565
578
  # Example:
566
579
  #
567
580
  # # Dump an array, get back a YAML string
@@ -575,6 +588,9 @@ module Psych
575
588
  #
576
589
  # # Dump an array to an IO with indentation set
577
590
  # Psych.safe_dump(['a', ['b']], StringIO.new, indentation: 3)
591
+ #
592
+ # # Dump hash with symbol keys as string
593
+ # Psych.dump({a: "b"}, stringify_names: true) # => "---\na: b\n"
578
594
  def self.safe_dump o, io = nil, options = {}
579
595
  if Hash === io
580
596
  options = io
@@ -653,7 +669,7 @@ module Psych
653
669
  ###
654
670
  # Safely loads the document contained in +filename+. Returns the yaml contained in
655
671
  # +filename+ as a Ruby object, or if the file is empty, it returns
656
- # the specified +fallback+ return value, which defaults to +false+.
672
+ # the specified +fallback+ return value, which defaults to +nil+.
657
673
  # See safe_load for options.
658
674
  def self.safe_load_file filename, **kwargs
659
675
  File.open(filename, 'r:bom|utf-8') { |f|
@@ -664,7 +680,7 @@ module Psych
664
680
  ###
665
681
  # Loads the document contained in +filename+. Returns the yaml contained in
666
682
  # +filename+ as a Ruby object, or if the file is empty, it returns
667
- # the specified +fallback+ return value, which defaults to +false+.
683
+ # the specified +fallback+ return value, which defaults to +nil+.
668
684
  # See load for options.
669
685
  def self.load_file filename, **kwargs
670
686
  File.open(filename, 'r:bom|utf-8') { |f|
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.2
4
+ version: 5.2.0.beta1
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-12-19 00:00:00.000000000 Z
13
+ date: 2024-09-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,7 @@ licenses:
102
102
  - MIT
103
103
  metadata:
104
104
  msys2_mingw_dependencies: libyaml
105
+ changelog_uri: https://github.com/ruby/psych/releases
105
106
  post_install_message:
106
107
  rdoc_options:
107
108
  - "--main"