psych 3.0.0.beta3-x64-mingw32 → 3.0.2-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/ext/psych/psych_emitter.c +9 -9
- data/ext/psych/psych_parser.c +36 -13
- data/ext/psych/psych_yaml_tree.c +1 -1
- data/ext/psych/yaml/emitter.c +6 -6
- data/ext/psych/yaml/parser.c +4 -8
- data/ext/psych/yaml/scanner.c +2 -4
- data/lib/psych.rb +47 -12
- data/lib/psych/handler.rb +5 -0
- data/lib/psych/nodes/node.rb +12 -0
- data/lib/psych/tree_builder.rb +44 -4
- data/lib/psych/versions.rb +1 -1
- data/psych.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03a5f0bc9015c76cf9dc6a65d8552bfee56c92e0
|
4
|
+
data.tar.gz: 2002e51e8e245d9239db451ec75b04c731d06c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3493cdb894f39aa1715f15a07221397977c3b858f15add805cf1a83eaa4fb38aaab7f78671c88d1aa3cda25344c36879be608c9f20f2b39f12852e31875d2692
|
7
|
+
data.tar.gz: 51972f47dce580de71c63743a397d9b7852a170c19b93f55b9dc6de03dc89ec16659ebe0ae8e3a8ac6798208eba3cd9d640926486e7a77dd4e709f398b204a47
|
data/.travis.yml
CHANGED
data/ext/psych/psych_emitter.c
CHANGED
@@ -192,8 +192,8 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
|
192
192
|
name = rb_str_export_to_enc(name, encoding);
|
193
193
|
value = rb_str_export_to_enc(value, encoding);
|
194
194
|
|
195
|
-
tail->handle = (yaml_char_t *)
|
196
|
-
tail->prefix = (yaml_char_t *)
|
195
|
+
tail->handle = (yaml_char_t *)StringValueCStr(name);
|
196
|
+
tail->prefix = (yaml_char_t *)StringValueCStr(value);
|
197
197
|
|
198
198
|
tail++;
|
199
199
|
}
|
@@ -272,8 +272,8 @@ static VALUE scalar(
|
|
272
272
|
|
273
273
|
yaml_scalar_event_initialize(
|
274
274
|
&event,
|
275
|
-
(yaml_char_t *)(NIL_P(anchor) ? NULL :
|
276
|
-
(yaml_char_t *)(NIL_P(tag) ? NULL :
|
275
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
|
276
|
+
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
|
277
277
|
(yaml_char_t*)StringValuePtr(value),
|
278
278
|
(int)RSTRING_LEN(value),
|
279
279
|
plain ? 1 : 0,
|
@@ -319,8 +319,8 @@ static VALUE start_sequence(
|
|
319
319
|
|
320
320
|
yaml_sequence_start_event_initialize(
|
321
321
|
&event,
|
322
|
-
(yaml_char_t *)(NIL_P(anchor) ? NULL :
|
323
|
-
(yaml_char_t *)(NIL_P(tag) ? NULL :
|
322
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
|
323
|
+
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
|
324
324
|
implicit ? 1 : 0,
|
325
325
|
(yaml_sequence_style_t)NUM2INT(style)
|
326
326
|
);
|
@@ -383,8 +383,8 @@ static VALUE start_mapping(
|
|
383
383
|
|
384
384
|
yaml_mapping_start_event_initialize(
|
385
385
|
&event,
|
386
|
-
(yaml_char_t *)(NIL_P(anchor) ? NULL :
|
387
|
-
(yaml_char_t *)(NIL_P(tag) ? NULL :
|
386
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
|
387
|
+
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
|
388
388
|
implicit ? 1 : 0,
|
389
389
|
(yaml_mapping_style_t)NUM2INT(style)
|
390
390
|
);
|
@@ -432,7 +432,7 @@ static VALUE alias(VALUE self, VALUE anchor)
|
|
432
432
|
|
433
433
|
yaml_alias_event_initialize(
|
434
434
|
&event,
|
435
|
-
(yaml_char_t *)(NIL_P(anchor) ? NULL :
|
435
|
+
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor))
|
436
436
|
);
|
437
437
|
|
438
438
|
emit(emitter, &event);
|
data/ext/psych/psych_parser.c
CHANGED
@@ -16,6 +16,7 @@ static ID id_start_sequence;
|
|
16
16
|
static ID id_end_sequence;
|
17
17
|
static ID id_start_mapping;
|
18
18
|
static ID id_end_mapping;
|
19
|
+
static ID id_event_location;
|
19
20
|
|
20
21
|
#define PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc) \
|
21
22
|
do { \
|
@@ -232,6 +233,12 @@ static VALUE protected_end_stream(VALUE handler)
|
|
232
233
|
return rb_funcall(handler, id_end_stream, 0);
|
233
234
|
}
|
234
235
|
|
236
|
+
static VALUE protected_event_location(VALUE pointer)
|
237
|
+
{
|
238
|
+
VALUE *args = (VALUE *)pointer;
|
239
|
+
return rb_funcall3(args[0], id_event_location, 4, args + 1);
|
240
|
+
}
|
241
|
+
|
235
242
|
/*
|
236
243
|
* call-seq:
|
237
244
|
* parser.parse(yaml)
|
@@ -285,6 +292,9 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
|
|
285
292
|
}
|
286
293
|
|
287
294
|
while(!done) {
|
295
|
+
VALUE event_args[5];
|
296
|
+
VALUE start_line, start_column, end_line, end_column;
|
297
|
+
|
288
298
|
if(!yaml_parser_parse(parser, &event)) {
|
289
299
|
VALUE exception;
|
290
300
|
|
@@ -295,6 +305,18 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
|
|
295
305
|
rb_exc_raise(exception);
|
296
306
|
}
|
297
307
|
|
308
|
+
start_line = INT2NUM((long)event.start_mark.line);
|
309
|
+
start_column = INT2NUM((long)event.start_mark.column);
|
310
|
+
end_line = INT2NUM((long)event.end_mark.line);
|
311
|
+
end_column = INT2NUM((long)event.end_mark.column);
|
312
|
+
|
313
|
+
event_args[0] = handler;
|
314
|
+
event_args[1] = start_line;
|
315
|
+
event_args[2] = start_column;
|
316
|
+
event_args[3] = end_line;
|
317
|
+
event_args[4] = end_column;
|
318
|
+
rb_protect(protected_event_location, (VALUE)event_args, &state);
|
319
|
+
|
298
320
|
switch(event.type) {
|
299
321
|
case YAML_STREAM_START_EVENT:
|
300
322
|
{
|
@@ -551,18 +573,19 @@ void Init_psych_parser(void)
|
|
551
573
|
rb_define_method(cPsychParser, "parse", parse, -1);
|
552
574
|
rb_define_method(cPsychParser, "mark", mark, 0);
|
553
575
|
|
554
|
-
id_read
|
555
|
-
id_path
|
556
|
-
id_empty
|
557
|
-
id_start_stream
|
558
|
-
id_end_stream
|
559
|
-
id_start_document
|
560
|
-
id_end_document
|
561
|
-
id_alias
|
562
|
-
id_scalar
|
563
|
-
id_start_sequence
|
564
|
-
id_end_sequence
|
565
|
-
id_start_mapping
|
566
|
-
id_end_mapping
|
576
|
+
id_read = rb_intern("read");
|
577
|
+
id_path = rb_intern("path");
|
578
|
+
id_empty = rb_intern("empty");
|
579
|
+
id_start_stream = rb_intern("start_stream");
|
580
|
+
id_end_stream = rb_intern("end_stream");
|
581
|
+
id_start_document = rb_intern("start_document");
|
582
|
+
id_end_document = rb_intern("end_document");
|
583
|
+
id_alias = rb_intern("alias");
|
584
|
+
id_scalar = rb_intern("scalar");
|
585
|
+
id_start_sequence = rb_intern("start_sequence");
|
586
|
+
id_end_sequence = rb_intern("end_sequence");
|
587
|
+
id_start_mapping = rb_intern("start_mapping");
|
588
|
+
id_end_mapping = rb_intern("end_mapping");
|
589
|
+
id_event_location = rb_intern("event_location");
|
567
590
|
}
|
568
591
|
/* vim: set noet sws=4 sw=4: */
|
data/ext/psych/psych_yaml_tree.c
CHANGED
@@ -9,7 +9,7 @@ VALUE cPsychVisitorsYamlTree;
|
|
9
9
|
*/
|
10
10
|
static VALUE private_iv_get(VALUE self, VALUE target, VALUE prop)
|
11
11
|
{
|
12
|
-
return rb_attr_get(target, rb_intern(
|
12
|
+
return rb_attr_get(target, rb_intern(StringValueCStr(prop)));
|
13
13
|
}
|
14
14
|
|
15
15
|
void Init_psych_yaml_tree(void)
|
data/ext/psych/yaml/emitter.c
CHANGED
@@ -24,8 +24,8 @@
|
|
24
24
|
*/
|
25
25
|
|
26
26
|
#define PUT_BREAK(emitter) \
|
27
|
-
(FLUSH(emitter) \
|
28
|
-
|
27
|
+
(FLUSH(emitter) ? \
|
28
|
+
((emitter->line_break == YAML_CR_BREAK ? \
|
29
29
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \
|
30
30
|
emitter->line_break == YAML_LN_BREAK ? \
|
31
31
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : \
|
@@ -34,7 +34,7 @@
|
|
34
34
|
*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : 0), \
|
35
35
|
emitter->column = 0, \
|
36
36
|
emitter->line ++, \
|
37
|
-
1))
|
37
|
+
1) : 0)
|
38
38
|
|
39
39
|
/*
|
40
40
|
* Copy a character from a string into buffer.
|
@@ -221,7 +221,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter);
|
|
221
221
|
|
222
222
|
static int
|
223
223
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
224
|
-
char *indicator, int need_whitespace,
|
224
|
+
const char *indicator, int need_whitespace,
|
225
225
|
int is_whitespace, int is_indention);
|
226
226
|
|
227
227
|
static int
|
@@ -1784,7 +1784,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter)
|
|
1784
1784
|
|
1785
1785
|
static int
|
1786
1786
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
1787
|
-
char *indicator, int need_whitespace,
|
1787
|
+
const char *indicator, int need_whitespace,
|
1788
1788
|
int is_whitespace, int is_indention)
|
1789
1789
|
{
|
1790
1790
|
size_t indicator_length;
|
@@ -2178,7 +2178,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
|
|
2178
2178
|
yaml_string_t string)
|
2179
2179
|
{
|
2180
2180
|
char indent_hint[2];
|
2181
|
-
char *chomp_hint = NULL;
|
2181
|
+
const char *chomp_hint = NULL;
|
2182
2182
|
|
2183
2183
|
if (IS_SPACE(string) || IS_BREAK(string))
|
2184
2184
|
{
|
data/ext/psych/yaml/parser.c
CHANGED
@@ -759,9 +759,8 @@ yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
|
|
759
759
|
|
760
760
|
else if (token->type == YAML_BLOCK_END_TOKEN)
|
761
761
|
{
|
762
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
763
762
|
parser->state = POP(parser, parser->states);
|
764
|
-
|
763
|
+
(void)POP(parser, parser->marks);
|
765
764
|
SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
766
765
|
SKIP_TOKEN(parser);
|
767
766
|
return 1;
|
@@ -869,9 +868,8 @@ yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
|
|
869
868
|
|
870
869
|
else if (token->type == YAML_BLOCK_END_TOKEN)
|
871
870
|
{
|
872
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
873
871
|
parser->state = POP(parser, parser->states);
|
874
|
-
|
872
|
+
(void)POP(parser, parser->marks);
|
875
873
|
MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
876
874
|
SKIP_TOKEN(parser);
|
877
875
|
return 1;
|
@@ -952,7 +950,6 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
|
|
952
950
|
yaml_event_t *event, int first)
|
953
951
|
{
|
954
952
|
yaml_token_t *token;
|
955
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
956
953
|
|
957
954
|
if (first) {
|
958
955
|
token = PEEK_TOKEN(parser);
|
@@ -997,7 +994,7 @@ yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
|
|
997
994
|
}
|
998
995
|
|
999
996
|
parser->state = POP(parser, parser->states);
|
1000
|
-
|
997
|
+
(void)POP(parser, parser->marks);
|
1001
998
|
SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
1002
999
|
SKIP_TOKEN(parser);
|
1003
1000
|
return 1;
|
@@ -1104,7 +1101,6 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
|
|
1104
1101
|
yaml_event_t *event, int first)
|
1105
1102
|
{
|
1106
1103
|
yaml_token_t *token;
|
1107
|
-
yaml_mark_t dummy_mark; /* Used to eliminate a compiler warning. */
|
1108
1104
|
|
1109
1105
|
if (first) {
|
1110
1106
|
token = PEEK_TOKEN(parser);
|
@@ -1158,7 +1154,7 @@ yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
|
|
1158
1154
|
}
|
1159
1155
|
|
1160
1156
|
parser->state = POP(parser, parser->states);
|
1161
|
-
|
1157
|
+
(void)POP(parser, parser->marks);
|
1162
1158
|
MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
|
1163
1159
|
SKIP_TOKEN(parser);
|
1164
1160
|
return 1;
|
data/ext/psych/yaml/scanner.c
CHANGED
@@ -1186,11 +1186,9 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser)
|
|
1186
1186
|
static int
|
1187
1187
|
yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
1188
1188
|
{
|
1189
|
-
yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */
|
1190
|
-
|
1191
1189
|
if (parser->flow_level) {
|
1192
1190
|
parser->flow_level --;
|
1193
|
-
|
1191
|
+
(void)POP(parser, parser->simple_keys);
|
1194
1192
|
}
|
1195
1193
|
|
1196
1194
|
return 1;
|
@@ -1638,7 +1636,7 @@ yaml_parser_fetch_key(yaml_parser_t *parser)
|
|
1638
1636
|
|
1639
1637
|
if (!parser->flow_level)
|
1640
1638
|
{
|
1641
|
-
/* Check if we are allowed to start a new key (not
|
1639
|
+
/* Check if we are allowed to start a new key (not necessary simple). */
|
1642
1640
|
|
1643
1641
|
if (!parser->simple_key_allowed) {
|
1644
1642
|
return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
|
data/lib/psych.rb
CHANGED
@@ -198,12 +198,13 @@ require 'psych/class_loader'
|
|
198
198
|
#
|
199
199
|
# ==== Receiving an events stream
|
200
200
|
#
|
201
|
-
#
|
201
|
+
# recorder = Psych::Handlers::Recorder.new
|
202
|
+
# parser = Psych::Parser.new(recorder)
|
202
203
|
#
|
203
204
|
# parser.parse("---\n - a\n - b")
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
205
|
+
# recorder.events # => [list of [event, args] lists]
|
206
|
+
# # event is one of: Psych::Handler::EVENTS
|
207
|
+
# # args are the arguments passed to the event
|
207
208
|
#
|
208
209
|
# === Emitting
|
209
210
|
#
|
@@ -251,9 +252,18 @@ module Psych
|
|
251
252
|
# ex.file # => 'file.txt'
|
252
253
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
253
254
|
# end
|
254
|
-
|
255
|
-
|
256
|
-
|
255
|
+
#
|
256
|
+
# When the optional +symbolize_names+ keyword argument is set to a
|
257
|
+
# true value, returns symbols for keys in Hash objects (default: strings).
|
258
|
+
#
|
259
|
+
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
|
260
|
+
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
261
|
+
#
|
262
|
+
def self.load yaml, filename = nil, fallback: false, symbolize_names: false
|
263
|
+
result = parse(yaml, filename, fallback: fallback)
|
264
|
+
result = result.to_ruby if result
|
265
|
+
symbolize_names!(result) if symbolize_names
|
266
|
+
result
|
257
267
|
end
|
258
268
|
|
259
269
|
###
|
@@ -290,7 +300,17 @@ module Psych
|
|
290
300
|
#
|
291
301
|
# A Psych::BadAlias exception will be raised if the yaml contains aliases
|
292
302
|
# but the +aliases+ parameter is set to false.
|
293
|
-
|
303
|
+
#
|
304
|
+
# +filename+ will be used in the exception message if any exception is raised
|
305
|
+
# while parsing.
|
306
|
+
#
|
307
|
+
# When the optional +symbolize_names+ keyword argument is set to a
|
308
|
+
# true value, returns symbols for keys in Hash objects (default: strings).
|
309
|
+
#
|
310
|
+
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
311
|
+
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
312
|
+
#
|
313
|
+
def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases = false, filename = nil, symbolize_names: false
|
294
314
|
result = parse(yaml, filename)
|
295
315
|
return unless result
|
296
316
|
|
@@ -302,7 +322,9 @@ module Psych
|
|
302
322
|
else
|
303
323
|
visitor = Visitors::NoAliasRuby.new scanner, class_loader
|
304
324
|
end
|
305
|
-
visitor.accept result
|
325
|
+
result = visitor.accept result
|
326
|
+
symbolize_names!(result) if symbolize_names
|
327
|
+
result
|
306
328
|
end
|
307
329
|
|
308
330
|
###
|
@@ -324,7 +346,7 @@ module Psych
|
|
324
346
|
# end
|
325
347
|
#
|
326
348
|
# See Psych::Nodes for more information about YAML AST.
|
327
|
-
def self.parse yaml, filename = nil, fallback
|
349
|
+
def self.parse yaml, filename = nil, fallback: false
|
328
350
|
parse_stream(yaml, filename) do |node|
|
329
351
|
return node
|
330
352
|
end
|
@@ -471,9 +493,9 @@ module Psych
|
|
471
493
|
# Load the document contained in +filename+. Returns the yaml contained in
|
472
494
|
# +filename+ as a Ruby object, or if the file is empty, it returns
|
473
495
|
# the specified default return value, which defaults to an empty Hash
|
474
|
-
def self.load_file filename, fallback
|
496
|
+
def self.load_file filename, fallback: false
|
475
497
|
File.open(filename, 'r:bom|utf-8') { |f|
|
476
|
-
self.load f, filename, FALLBACK.new(fallback)
|
498
|
+
self.load f, filename, fallback: FALLBACK.new(fallback)
|
477
499
|
}
|
478
500
|
end
|
479
501
|
|
@@ -502,6 +524,19 @@ module Psych
|
|
502
524
|
@dump_tags[klass] = tag
|
503
525
|
end
|
504
526
|
|
527
|
+
def self.symbolize_names!(result)
|
528
|
+
case result
|
529
|
+
when Hash
|
530
|
+
result.keys.each do |key|
|
531
|
+
result[key.to_sym] = symbolize_names!(result.delete(key))
|
532
|
+
end
|
533
|
+
when Array
|
534
|
+
result.map! { |r| symbolize_names!(r) }
|
535
|
+
end
|
536
|
+
result
|
537
|
+
end
|
538
|
+
private_class_method :symbolize_names!
|
539
|
+
|
505
540
|
class << self
|
506
541
|
attr_accessor :load_tags
|
507
542
|
attr_accessor :dump_tags
|
data/lib/psych/handler.rb
CHANGED
@@ -241,6 +241,11 @@ module Psych
|
|
241
241
|
def end_stream
|
242
242
|
end
|
243
243
|
|
244
|
+
###
|
245
|
+
# Called before each event with line/column information.
|
246
|
+
def event_location(start_line, start_column, end_line, end_column)
|
247
|
+
end
|
248
|
+
|
244
249
|
###
|
245
250
|
# Is this handler a streaming handler?
|
246
251
|
def streaming?
|
data/lib/psych/nodes/node.rb
CHANGED
@@ -17,6 +17,18 @@ module Psych
|
|
17
17
|
# An associated tag
|
18
18
|
attr_reader :tag
|
19
19
|
|
20
|
+
# The line number where this node start
|
21
|
+
attr_accessor :start_line
|
22
|
+
|
23
|
+
# The column number where this node start
|
24
|
+
attr_accessor :start_column
|
25
|
+
|
26
|
+
# The line number where this node ends
|
27
|
+
attr_accessor :end_line
|
28
|
+
|
29
|
+
# The column number where this node ends
|
30
|
+
attr_accessor :end_column
|
31
|
+
|
20
32
|
# Create a new Psych::Nodes::Node
|
21
33
|
def initialize
|
22
34
|
@children = []
|
data/lib/psych/tree_builder.rb
CHANGED
@@ -23,6 +23,18 @@ module Psych
|
|
23
23
|
@stack = []
|
24
24
|
@last = nil
|
25
25
|
@root = nil
|
26
|
+
|
27
|
+
@start_line = nil
|
28
|
+
@start_column = nil
|
29
|
+
@end_line = nil
|
30
|
+
@end_column = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def event_location(start_line, start_column, end_line, end_column)
|
34
|
+
@start_line = start_line
|
35
|
+
@start_column = start_column
|
36
|
+
@end_line = end_line
|
37
|
+
@end_column = end_column
|
26
38
|
end
|
27
39
|
|
28
40
|
%w{
|
@@ -32,12 +44,15 @@ module Psych
|
|
32
44
|
class_eval %{
|
33
45
|
def start_#{node.downcase}(anchor, tag, implicit, style)
|
34
46
|
n = Nodes::#{node}.new(anchor, tag, implicit, style)
|
47
|
+
set_start_location(n)
|
35
48
|
@last.children << n
|
36
49
|
push n
|
37
50
|
end
|
38
51
|
|
39
52
|
def end_#{node.downcase}
|
40
|
-
pop
|
53
|
+
n = pop
|
54
|
+
set_end_location(n)
|
55
|
+
n
|
41
56
|
end
|
42
57
|
}
|
43
58
|
end
|
@@ -49,6 +64,7 @@ module Psych
|
|
49
64
|
# See Psych::Handler#start_document
|
50
65
|
def start_document version, tag_directives, implicit
|
51
66
|
n = Nodes::Document.new version, tag_directives, implicit
|
67
|
+
set_start_location(n)
|
52
68
|
@last.children << n
|
53
69
|
push n
|
54
70
|
end
|
@@ -60,26 +76,35 @@ module Psych
|
|
60
76
|
# See Psych::Handler#start_document
|
61
77
|
def end_document implicit_end = !streaming?
|
62
78
|
@last.implicit_end = implicit_end
|
63
|
-
pop
|
79
|
+
n = pop
|
80
|
+
set_end_location(n)
|
81
|
+
n
|
64
82
|
end
|
65
83
|
|
66
84
|
def start_stream encoding
|
67
85
|
@root = Nodes::Stream.new(encoding)
|
86
|
+
set_start_location(@root)
|
68
87
|
push @root
|
69
88
|
end
|
70
89
|
|
71
90
|
def end_stream
|
72
|
-
pop
|
91
|
+
n = pop
|
92
|
+
set_end_location(n)
|
93
|
+
n
|
73
94
|
end
|
74
95
|
|
75
96
|
def scalar value, anchor, tag, plain, quoted, style
|
76
97
|
s = Nodes::Scalar.new(value,anchor,tag,plain,quoted,style)
|
98
|
+
set_location(s)
|
77
99
|
@last.children << s
|
78
100
|
s
|
79
101
|
end
|
80
102
|
|
81
103
|
def alias anchor
|
82
|
-
|
104
|
+
a = Nodes::Alias.new(anchor)
|
105
|
+
set_location(a)
|
106
|
+
@last.children << a
|
107
|
+
a
|
83
108
|
end
|
84
109
|
|
85
110
|
private
|
@@ -93,5 +118,20 @@ module Psych
|
|
93
118
|
@last = @stack.last
|
94
119
|
x
|
95
120
|
end
|
121
|
+
|
122
|
+
def set_location(node)
|
123
|
+
set_start_location(node)
|
124
|
+
set_end_location(node)
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_start_location(node)
|
128
|
+
node.start_line = @start_line
|
129
|
+
node.start_column = @start_column
|
130
|
+
end
|
131
|
+
|
132
|
+
def set_end_location(node)
|
133
|
+
node.end_line = @end_line
|
134
|
+
node.end_column = @end_column
|
135
|
+
end
|
96
136
|
end
|
97
137
|
end
|
data/lib/psych/versions.rb
CHANGED
data/psych.gemspec
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "psych"
|
6
|
-
s.version = "3.0.
|
6
|
+
s.version = "3.0.2"
|
7
7
|
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
|
8
8
|
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
|
9
|
-
s.date = "2017-
|
9
|
+
s.date = "2017-12-04"
|
10
10
|
s.summary = "Psych is a YAML parser and emitter"
|
11
11
|
s.description = <<-DESCRIPTION
|
12
12
|
Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
|
@@ -41,7 +41,7 @@ DESCRIPTION
|
|
41
41
|
s.rdoc_options = ["--main", "README.md"]
|
42
42
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md"]
|
43
43
|
|
44
|
-
s.required_ruby_version = Gem::Requirement.new(">=
|
44
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.2.2")
|
45
45
|
s.rubygems_version = "2.5.1"
|
46
46
|
s.required_rubygems_version = Gem::Requirement.new(">= 0")
|
47
47
|
|
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: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: x64-mingw32
|
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: 2017-
|
13
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake-compiler
|