psych 2.0.13 → 2.1.0
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/.travis.yml +9 -4
- data/Manifest.txt +2 -0
- data/Rakefile +55 -6
- data/ext/psych/extconf.rb +1 -0
- data/ext/psych/psych_emitter.c +25 -11
- data/ext/psych/psych_parser.c +2 -2
- data/ext/psych/yaml/loader.c +2 -2
- data/ext/psych/yaml/scanner.c +18 -18
- data/lib/psych/class_loader.rb +1 -0
- data/lib/psych/coder.rb +1 -0
- data/lib/psych/core_ext.rb +1 -0
- data/lib/psych/deprecated.rb +1 -0
- data/lib/psych/exception.rb +1 -0
- data/lib/psych/handler.rb +1 -0
- data/lib/psych/handlers/document_stream.rb +1 -0
- data/lib/psych/handlers/recorder.rb +1 -0
- data/lib/psych/json/ruby_events.rb +1 -0
- data/lib/psych/json/stream.rb +1 -0
- data/lib/psych/json/tree_builder.rb +1 -0
- data/lib/psych/json/yaml_events.rb +1 -0
- data/lib/psych/nodes/alias.rb +1 -0
- data/lib/psych/nodes/document.rb +1 -0
- data/lib/psych/nodes/mapping.rb +1 -0
- data/lib/psych/nodes/node.rb +1 -0
- data/lib/psych/nodes/scalar.rb +1 -0
- data/lib/psych/nodes/sequence.rb +1 -0
- data/lib/psych/nodes/stream.rb +1 -0
- data/lib/psych/nodes.rb +1 -0
- data/lib/psych/omap.rb +1 -0
- data/lib/psych/parser.rb +1 -0
- data/lib/psych/scalar_scanner.rb +1 -0
- data/lib/psych/set.rb +1 -0
- data/lib/psych/stream.rb +1 -0
- data/lib/psych/streaming.rb +1 -0
- data/lib/psych/syntax_error.rb +1 -0
- data/lib/psych/tree_builder.rb +1 -0
- data/lib/psych/versions.rb +4 -0
- data/lib/psych/visitors/depth_first.rb +1 -0
- data/lib/psych/visitors/emitter.rb +1 -0
- data/lib/psych/visitors/json_tree.rb +1 -0
- data/lib/psych/visitors/to_ruby.rb +5 -3
- data/lib/psych/visitors/visitor.rb +1 -0
- data/lib/psych/visitors/yaml_tree.rb +17 -24
- data/lib/psych/visitors.rb +1 -0
- data/lib/psych/y.rb +1 -0
- data/lib/psych.rb +21 -9
- data/lib/psych_jars.rb +6 -0
- data/test/psych/handlers/test_recorder.rb +1 -0
- data/test/psych/helper.rb +3 -1
- data/test/psych/json/test_stream.rb +1 -0
- data/test/psych/nodes/test_enumerable.rb +1 -0
- data/test/psych/test_alias_and_anchor.rb +1 -0
- data/test/psych/test_array.rb +1 -0
- data/test/psych/test_boolean.rb +1 -0
- data/test/psych/test_class.rb +1 -0
- data/test/psych/test_coder.rb +1 -0
- data/test/psych/test_date_time.rb +1 -0
- data/test/psych/test_deprecated.rb +1 -0
- data/test/psych/test_document.rb +1 -0
- data/test/psych/test_emitter.rb +18 -0
- data/test/psych/test_encoding.rb +10 -0
- data/test/psych/test_exception.rb +1 -0
- data/test/psych/test_hash.rb +1 -0
- data/test/psych/test_json_tree.rb +1 -0
- data/test/psych/test_merge_keys.rb +1 -0
- data/test/psych/test_nil.rb +1 -0
- data/test/psych/test_null.rb +1 -0
- data/test/psych/test_numeric.rb +1 -0
- data/test/psych/test_object.rb +1 -0
- data/test/psych/test_object_references.rb +1 -0
- data/test/psych/test_omap.rb +1 -0
- data/test/psych/test_parser.rb +1 -0
- data/test/psych/test_psych.rb +17 -1
- data/test/psych/test_safe_load.rb +1 -0
- data/test/psych/test_scalar.rb +1 -0
- data/test/psych/test_scalar_scanner.rb +1 -0
- data/test/psych/test_serialize_subclasses.rb +1 -0
- data/test/psych/test_set.rb +1 -0
- data/test/psych/test_stream.rb +1 -0
- data/test/psych/test_string.rb +1 -0
- data/test/psych/test_struct.rb +1 -0
- data/test/psych/test_symbol.rb +1 -0
- data/test/psych/test_tainted.rb +1 -0
- data/test/psych/test_to_yaml_properties.rb +1 -0
- data/test/psych/test_tree_builder.rb +1 -0
- data/test/psych/test_yaml.rb +1 -0
- data/test/psych/test_yamldbm.rb +1 -1
- data/test/psych/test_yamlstore.rb +1 -0
- data/test/psych/visitors/test_depth_first.rb +1 -0
- data/test/psych/visitors/test_emitter.rb +1 -0
- data/test/psych/visitors/test_to_ruby.rb +15 -9
- data/test/psych/visitors/test_yaml_tree.rb +7 -0
- metadata +10 -55
- data/.gemtest +0 -0
- data/test/psych/test_marshalable.rb +0 -54
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b60d3bf3233df7c3abe9184e81b79eed85129ba1
|
|
4
|
+
data.tar.gz: b06bdbf39cd19feaf29b19d5fb49f2d0ae6cfe0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9a6914218ecaece3214bb8698a6589bb67b3ded99be295fee23894be97e40dac2c67ca730c4c8c7bf12bc89e68ec7974132adb3a81f6f8f54ae8507fda324a6
|
|
7
|
+
data.tar.gz: 105c008b421b79781e25f041a4f5d9ddc99fbf79b8a0db1fad1329abee305387fd10156612279daf0bdcaa4baaf1c13382cef0164833ca9e4fc52448e87060c4
|
data/.travis.yml
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
rvm:
|
|
2
|
-
- 1.9.2
|
|
3
|
-
- 1.9.3
|
|
4
2
|
- 2.0.0
|
|
5
|
-
- 2.1
|
|
3
|
+
- 2.1
|
|
4
|
+
- 2.2
|
|
5
|
+
- 2.3.0
|
|
6
6
|
- ruby-head
|
|
7
|
+
- rbx-2
|
|
7
8
|
before_script:
|
|
8
9
|
- gem install hoe
|
|
9
10
|
- gem install rake-compiler
|
|
10
|
-
- gem install minitest -v '~>
|
|
11
|
+
- gem install minitest -v '~> 5.0'
|
|
11
12
|
script: rake test
|
|
13
|
+
matrix:
|
|
14
|
+
allow_failures:
|
|
15
|
+
- rvm: ruby-head
|
|
16
|
+
- rvm: rbx-2
|
data/Manifest.txt
CHANGED
|
@@ -57,6 +57,7 @@ lib/psych/stream.rb
|
|
|
57
57
|
lib/psych/streaming.rb
|
|
58
58
|
lib/psych/syntax_error.rb
|
|
59
59
|
lib/psych/tree_builder.rb
|
|
60
|
+
lib/psych/versions.rb
|
|
60
61
|
lib/psych/visitors.rb
|
|
61
62
|
lib/psych/visitors/depth_first.rb
|
|
62
63
|
lib/psych/visitors/emitter.rb
|
|
@@ -65,6 +66,7 @@ lib/psych/visitors/to_ruby.rb
|
|
|
65
66
|
lib/psych/visitors/visitor.rb
|
|
66
67
|
lib/psych/visitors/yaml_tree.rb
|
|
67
68
|
lib/psych/y.rb
|
|
69
|
+
lib/psych_jars.rb
|
|
68
70
|
test/psych/handlers/test_recorder.rb
|
|
69
71
|
test/psych/helper.rb
|
|
70
72
|
test/psych/json/test_stream.rb
|
data/Rakefile
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# -*- ruby -*-
|
|
2
2
|
|
|
3
|
+
require 'psych'
|
|
3
4
|
require 'rubygems'
|
|
4
5
|
require 'hoe'
|
|
5
6
|
|
|
7
|
+
def java?
|
|
8
|
+
RUBY_PLATFORM =~ /java/
|
|
9
|
+
end
|
|
10
|
+
|
|
6
11
|
class Hoe
|
|
7
12
|
remove_const :RUBY_FLAGS
|
|
8
|
-
|
|
13
|
+
flags = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
|
|
14
|
+
flags = "--1.9 " + flags if java?
|
|
15
|
+
RUBY_FLAGS = flags
|
|
9
16
|
end
|
|
10
17
|
|
|
11
18
|
gem 'rake-compiler', '>= 0.4.1'
|
|
12
|
-
gem 'minitest', '~>
|
|
19
|
+
gem 'minitest', '~> 5.0'
|
|
13
20
|
require "rake/extensiontask"
|
|
14
21
|
|
|
15
22
|
Hoe.plugin :doofus, :git, :gemspec
|
|
@@ -24,15 +31,57 @@ $hoe = Hoe.spec 'psych' do
|
|
|
24
31
|
self.testlib = :minitest
|
|
25
32
|
|
|
26
33
|
extra_dev_deps << ['rake-compiler', '>= 0.4.1']
|
|
27
|
-
extra_dev_deps << ['minitest', '~>
|
|
34
|
+
extra_dev_deps << ['minitest', '~> 5.0']
|
|
28
35
|
|
|
29
36
|
self.spec_extras = {
|
|
30
|
-
:extensions => ["ext/psych/extconf.rb"],
|
|
31
37
|
:required_ruby_version => '>= 1.9.2'
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
if java?
|
|
41
|
+
require './lib/psych/versions.rb'
|
|
42
|
+
extra_deps << ['jar-dependencies', '>= 0.1.7']
|
|
43
|
+
|
|
44
|
+
# the jar declaration for jar-dependencies
|
|
45
|
+
self.spec_extras[ 'requirements' ] = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
|
|
46
|
+
self.spec_extras[ 'platform' ] = 'java'
|
|
47
|
+
# TODO: clean this section up.
|
|
48
|
+
require "rake/javaextensiontask"
|
|
49
|
+
Rake::JavaExtensionTask.new("psych", spec) do |ext|
|
|
50
|
+
require 'maven/ruby/maven'
|
|
51
|
+
# uses Mavenfile to write classpath into pkg/classpath
|
|
52
|
+
# and tell maven via system properties the snakeyaml version
|
|
53
|
+
# this is basically the same as running from the commandline:
|
|
54
|
+
# rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
|
|
55
|
+
Maven::Ruby::Maven.new.exec( 'dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')#, '--quiet' )
|
|
56
|
+
ext.source_version = '1.7'
|
|
57
|
+
ext.target_version = '1.7'
|
|
58
|
+
ext.classpath = File.read('pkg/classpath')
|
|
59
|
+
ext.ext_dir = 'ext/java'
|
|
60
|
+
end
|
|
61
|
+
else
|
|
62
|
+
self.spec_extras[:extensions] = ["ext/psych/extconf.rb"]
|
|
63
|
+
Rake::ExtensionTask.new "psych", spec do |ext|
|
|
64
|
+
ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def gem_build_path
|
|
70
|
+
File.join 'pkg', $hoe.spec.full_name
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def add_file_to_gem relative_path
|
|
74
|
+
target_path = File.join gem_build_path, relative_path
|
|
75
|
+
target_dir = File.dirname(target_path)
|
|
76
|
+
mkdir_p target_dir unless File.directory?(target_dir)
|
|
77
|
+
rm_f target_path
|
|
78
|
+
safe_ln relative_path, target_path
|
|
79
|
+
$hoe.spec.files.concat [relative_path]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if java?
|
|
83
|
+
task gem_build_path => [:compile] do
|
|
84
|
+
add_file_to_gem 'lib/psych.jar'
|
|
36
85
|
end
|
|
37
86
|
end
|
|
38
87
|
|
data/ext/psych/extconf.rb
CHANGED
data/ext/psych/psych_emitter.c
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
#include <psych.h>
|
|
2
2
|
|
|
3
|
+
#if !defined(RARRAY_CONST_PTR)
|
|
4
|
+
#define RARRAY_CONST_PTR(s) (const VALUE *)RARRAY_PTR(s)
|
|
5
|
+
#endif
|
|
6
|
+
#if !defined(RARRAY_AREF)
|
|
7
|
+
#define RARRAY_AREF(a, i) RARRAY_CONST_PTR(a)[i]
|
|
8
|
+
#endif
|
|
9
|
+
|
|
3
10
|
VALUE cPsychEmitter;
|
|
4
11
|
static ID id_write;
|
|
5
12
|
static ID id_line_width;
|
|
@@ -15,7 +22,11 @@ static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
|
|
|
15
22
|
static int writer(void *ctx, unsigned char *buffer, size_t size)
|
|
16
23
|
{
|
|
17
24
|
VALUE io = (VALUE)ctx;
|
|
25
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
|
26
|
+
VALUE str = rb_enc_str_new((const char *)buffer, (long)size, rb_utf8_encoding());
|
|
27
|
+
#else
|
|
18
28
|
VALUE str = rb_str_new((const char *)buffer, (long)size);
|
|
29
|
+
#endif
|
|
19
30
|
VALUE wrote = rb_funcall(io, id_write, 1, str);
|
|
20
31
|
return (int)NUM2INT(wrote);
|
|
21
32
|
}
|
|
@@ -50,14 +61,13 @@ static const rb_data_type_t psych_emitter_type = {
|
|
|
50
61
|
static VALUE allocate(VALUE klass)
|
|
51
62
|
{
|
|
52
63
|
yaml_emitter_t * emitter;
|
|
53
|
-
|
|
54
|
-
emitter = xmalloc(sizeof(yaml_emitter_t));
|
|
64
|
+
VALUE obj = TypedData_Make_Struct(klass, yaml_emitter_t, &psych_emitter_type, emitter);
|
|
55
65
|
|
|
56
66
|
yaml_emitter_initialize(emitter);
|
|
57
67
|
yaml_emitter_set_unicode(emitter, 1);
|
|
58
68
|
yaml_emitter_set_indent(emitter, 2);
|
|
59
69
|
|
|
60
|
-
return
|
|
70
|
+
return obj;
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
/* call-seq: Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS)
|
|
@@ -156,18 +166,20 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
|
|
156
166
|
}
|
|
157
167
|
|
|
158
168
|
if(RTEST(tags)) {
|
|
159
|
-
|
|
169
|
+
long i = 0;
|
|
170
|
+
long len;
|
|
160
171
|
#ifdef HAVE_RUBY_ENCODING_H
|
|
161
172
|
rb_encoding * encoding = rb_utf8_encoding();
|
|
162
173
|
#endif
|
|
163
174
|
|
|
164
175
|
Check_Type(tags, T_ARRAY);
|
|
165
176
|
|
|
166
|
-
|
|
177
|
+
len = RARRAY_LEN(tags);
|
|
178
|
+
head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t));
|
|
167
179
|
tail = head;
|
|
168
180
|
|
|
169
|
-
for(i = 0; i < RARRAY_LEN(tags); i++) {
|
|
170
|
-
VALUE tuple =
|
|
181
|
+
for(i = 0; i < len && i < RARRAY_LEN(tags); i++) {
|
|
182
|
+
VALUE tuple = RARRAY_AREF(tags, i);
|
|
171
183
|
VALUE name;
|
|
172
184
|
VALUE value;
|
|
173
185
|
|
|
@@ -177,15 +189,17 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
|
|
177
189
|
xfree(head);
|
|
178
190
|
rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
|
|
179
191
|
}
|
|
180
|
-
name =
|
|
181
|
-
value =
|
|
192
|
+
name = RARRAY_AREF(tuple, 0);
|
|
193
|
+
value = RARRAY_AREF(tuple, 1);
|
|
194
|
+
StringValue(name);
|
|
195
|
+
StringValue(value);
|
|
182
196
|
#ifdef HAVE_RUBY_ENCODING_H
|
|
183
197
|
name = rb_str_export_to_enc(name, encoding);
|
|
184
198
|
value = rb_str_export_to_enc(value, encoding);
|
|
185
199
|
#endif
|
|
186
200
|
|
|
187
|
-
tail->handle = (yaml_char_t *)
|
|
188
|
-
tail->prefix = (yaml_char_t *)
|
|
201
|
+
tail->handle = (yaml_char_t *)RSTRING_PTR(name);
|
|
202
|
+
tail->prefix = (yaml_char_t *)RSTRING_PTR(value);
|
|
189
203
|
|
|
190
204
|
tail++;
|
|
191
205
|
}
|
data/ext/psych/psych_parser.c
CHANGED
|
@@ -70,11 +70,11 @@ static const rb_data_type_t psych_parser_type = {
|
|
|
70
70
|
static VALUE allocate(VALUE klass)
|
|
71
71
|
{
|
|
72
72
|
yaml_parser_t * parser;
|
|
73
|
+
VALUE obj = TypedData_Make_Struct(klass, yaml_parser_t, &psych_parser_type, parser);
|
|
73
74
|
|
|
74
|
-
parser = xmalloc(sizeof(yaml_parser_t));
|
|
75
75
|
yaml_parser_initialize(parser);
|
|
76
76
|
|
|
77
|
-
return
|
|
77
|
+
return obj;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
static VALUE make_exception(yaml_parser_t * parser, VALUE path)
|
data/ext/psych/yaml/loader.c
CHANGED
|
@@ -239,8 +239,8 @@ yaml_parser_register_anchor(yaml_parser_t *parser,
|
|
|
239
239
|
if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
|
|
240
240
|
yaml_free(anchor);
|
|
241
241
|
return yaml_parser_set_composer_error_context(parser,
|
|
242
|
-
"found duplicate anchor; first
|
|
243
|
-
alias_data->mark, "second
|
|
242
|
+
"found duplicate anchor; first occurrence",
|
|
243
|
+
alias_data->mark, "second occurrence", data.mark);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
data/ext/psych/yaml/scanner.c
CHANGED
|
@@ -1251,7 +1251,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
|
|
|
1251
1251
|
|
|
1252
1252
|
/*
|
|
1253
1253
|
* Pop indentation levels from the indents stack until the current level
|
|
1254
|
-
* becomes less or equal to the column. For each
|
|
1254
|
+
* becomes less or equal to the column. For each indentation level, append
|
|
1255
1255
|
* the BLOCK-END token.
|
|
1256
1256
|
*/
|
|
1257
1257
|
|
|
@@ -1266,7 +1266,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
|
|
|
1266
1266
|
if (parser->flow_level)
|
|
1267
1267
|
return 1;
|
|
1268
1268
|
|
|
1269
|
-
/* Loop through the
|
|
1269
|
+
/* Loop through the indentation levels in the stack. */
|
|
1270
1270
|
|
|
1271
1271
|
while (parser->indent > column)
|
|
1272
1272
|
{
|
|
@@ -2053,7 +2053,7 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
|
|
|
2053
2053
|
else
|
|
2054
2054
|
{
|
|
2055
2055
|
yaml_parser_set_scanner_error(parser, "while scanning a directive",
|
|
2056
|
-
start_mark, "found
|
|
2056
|
+
start_mark, "found unknown directive name");
|
|
2057
2057
|
goto error;
|
|
2058
2058
|
}
|
|
2059
2059
|
|
|
@@ -2775,15 +2775,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2775
2775
|
|
|
2776
2776
|
if (IS_DIGIT(parser->buffer))
|
|
2777
2777
|
{
|
|
2778
|
-
/* Check that the
|
|
2778
|
+
/* Check that the indentation is greater than 0. */
|
|
2779
2779
|
|
|
2780
2780
|
if (CHECK(parser->buffer, '0')) {
|
|
2781
2781
|
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
|
2782
|
-
start_mark, "found an
|
|
2782
|
+
start_mark, "found an indentation indicator equal to 0");
|
|
2783
2783
|
goto error;
|
|
2784
2784
|
}
|
|
2785
2785
|
|
|
2786
|
-
/* Get the
|
|
2786
|
+
/* Get the indentation level and eat the indicator. */
|
|
2787
2787
|
|
|
2788
2788
|
increment = AS_DIGIT(parser->buffer);
|
|
2789
2789
|
|
|
@@ -2797,7 +2797,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2797
2797
|
{
|
|
2798
2798
|
if (CHECK(parser->buffer, '0')) {
|
|
2799
2799
|
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
|
2800
|
-
start_mark, "found an
|
|
2800
|
+
start_mark, "found an indentation indicator equal to 0");
|
|
2801
2801
|
goto error;
|
|
2802
2802
|
}
|
|
2803
2803
|
|
|
@@ -2847,7 +2847,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2847
2847
|
|
|
2848
2848
|
end_mark = parser->mark;
|
|
2849
2849
|
|
|
2850
|
-
/* Set the
|
|
2850
|
+
/* Set the indentation level if it was specified. */
|
|
2851
2851
|
|
|
2852
2852
|
if (increment) {
|
|
2853
2853
|
indent = parser->indent >= 0 ? parser->indent+increment : increment;
|
|
@@ -2913,7 +2913,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2913
2913
|
|
|
2914
2914
|
if (!READ_LINE(parser, leading_break)) goto error;
|
|
2915
2915
|
|
|
2916
|
-
/* Eat the following
|
|
2916
|
+
/* Eat the following indentation spaces and line breaks. */
|
|
2917
2917
|
|
|
2918
2918
|
if (!yaml_parser_scan_block_scalar_breaks(parser,
|
|
2919
2919
|
&indent, &trailing_breaks, start_mark, &end_mark)) goto error;
|
|
@@ -2948,8 +2948,8 @@ error:
|
|
|
2948
2948
|
}
|
|
2949
2949
|
|
|
2950
2950
|
/*
|
|
2951
|
-
* Scan
|
|
2952
|
-
*
|
|
2951
|
+
* Scan indentation spaces and line breaks for a block scalar. Determine the
|
|
2952
|
+
* indentation level if needed.
|
|
2953
2953
|
*/
|
|
2954
2954
|
|
|
2955
2955
|
static int
|
|
@@ -2961,11 +2961,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
|
2961
2961
|
|
|
2962
2962
|
*end_mark = parser->mark;
|
|
2963
2963
|
|
|
2964
|
-
/* Eat the
|
|
2964
|
+
/* Eat the indentation spaces and line breaks. */
|
|
2965
2965
|
|
|
2966
2966
|
while (1)
|
|
2967
2967
|
{
|
|
2968
|
-
/* Eat the
|
|
2968
|
+
/* Eat the indentation spaces. */
|
|
2969
2969
|
|
|
2970
2970
|
if (!CACHE(parser, 1)) return 0;
|
|
2971
2971
|
|
|
@@ -2978,12 +2978,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
|
2978
2978
|
if ((int)parser->mark.column > max_indent)
|
|
2979
2979
|
max_indent = (int)parser->mark.column;
|
|
2980
2980
|
|
|
2981
|
-
/* Check for a tab character messing the
|
|
2981
|
+
/* Check for a tab character messing the indentation. */
|
|
2982
2982
|
|
|
2983
2983
|
if ((!*indent || (int)parser->mark.column < *indent)
|
|
2984
2984
|
&& IS_TAB(parser->buffer)) {
|
|
2985
2985
|
return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
|
2986
|
-
start_mark, "found a tab character where an
|
|
2986
|
+
start_mark, "found a tab character where an indentation space is expected");
|
|
2987
2987
|
}
|
|
2988
2988
|
|
|
2989
2989
|
/* Have we found a non-empty line? */
|
|
@@ -3504,12 +3504,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
|
3504
3504
|
{
|
|
3505
3505
|
if (IS_BLANK(parser->buffer))
|
|
3506
3506
|
{
|
|
3507
|
-
/* Check for tab character that abuse
|
|
3507
|
+
/* Check for tab character that abuse indentation. */
|
|
3508
3508
|
|
|
3509
3509
|
if (leading_blanks && (int)parser->mark.column < indent
|
|
3510
3510
|
&& IS_TAB(parser->buffer)) {
|
|
3511
3511
|
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
|
3512
|
-
start_mark, "found a tab character that violate
|
|
3512
|
+
start_mark, "found a tab character that violate indentation");
|
|
3513
3513
|
goto error;
|
|
3514
3514
|
}
|
|
3515
3515
|
|
|
@@ -3542,7 +3542,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
|
3542
3542
|
if (!CACHE(parser, 1)) goto error;
|
|
3543
3543
|
}
|
|
3544
3544
|
|
|
3545
|
-
/* Check
|
|
3545
|
+
/* Check indentation level. */
|
|
3546
3546
|
|
|
3547
3547
|
if (!parser->flow_level && (int)parser->mark.column < indent)
|
|
3548
3548
|
break;
|
data/lib/psych/class_loader.rb
CHANGED
data/lib/psych/coder.rb
CHANGED
data/lib/psych/core_ext.rb
CHANGED
data/lib/psych/deprecated.rb
CHANGED
data/lib/psych/exception.rb
CHANGED
data/lib/psych/handler.rb
CHANGED
data/lib/psych/json/stream.rb
CHANGED
data/lib/psych/nodes/alias.rb
CHANGED
data/lib/psych/nodes/document.rb
CHANGED
data/lib/psych/nodes/mapping.rb
CHANGED
data/lib/psych/nodes/node.rb
CHANGED
data/lib/psych/nodes/scalar.rb
CHANGED
data/lib/psych/nodes/sequence.rb
CHANGED
data/lib/psych/nodes/stream.rb
CHANGED
data/lib/psych/nodes.rb
CHANGED
data/lib/psych/omap.rb
CHANGED
data/lib/psych/parser.rb
CHANGED
data/lib/psych/scalar_scanner.rb
CHANGED
data/lib/psych/set.rb
CHANGED
data/lib/psych/stream.rb
CHANGED
data/lib/psych/streaming.rb
CHANGED
data/lib/psych/syntax_error.rb
CHANGED
data/lib/psych/tree_builder.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: false
|
|
1
2
|
require 'psych/scalar_scanner'
|
|
2
3
|
require 'psych/class_loader'
|
|
3
4
|
require 'psych/exception'
|
|
@@ -61,7 +62,7 @@ module Psych
|
|
|
61
62
|
case o.tag
|
|
62
63
|
when '!binary', 'tag:yaml.org,2002:binary'
|
|
63
64
|
o.value.unpack('m').first
|
|
64
|
-
when /^!(?:str|ruby\/string)(?::(.*))
|
|
65
|
+
when /^!(?:str|ruby\/string)(?::(.*))?$/, 'tag:yaml.org,2002:str'
|
|
65
66
|
klass = resolve_class($1)
|
|
66
67
|
if klass
|
|
67
68
|
klass.allocate.replace o.value
|
|
@@ -208,7 +209,7 @@ module Psych
|
|
|
208
209
|
obj
|
|
209
210
|
end
|
|
210
211
|
|
|
211
|
-
when /^!(?:str|ruby\/string)(?::(.*))
|
|
212
|
+
when /^!(?:str|ruby\/string)(?::(.*))?$/, 'tag:yaml.org,2002:str'
|
|
212
213
|
klass = resolve_class($1)
|
|
213
214
|
members = {}
|
|
214
215
|
string = nil
|
|
@@ -330,12 +331,13 @@ module Psych
|
|
|
330
331
|
list
|
|
331
332
|
end
|
|
332
333
|
|
|
334
|
+
SHOVEL = '<<'
|
|
333
335
|
def revive_hash hash, o
|
|
334
336
|
o.children.each_slice(2) { |k,v|
|
|
335
337
|
key = accept(k)
|
|
336
338
|
val = accept(v)
|
|
337
339
|
|
|
338
|
-
if key ==
|
|
340
|
+
if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
|
|
339
341
|
case v
|
|
340
342
|
when Nodes::Alias, Nodes::Mapping
|
|
341
343
|
begin
|