psych 2.0.15-java → 2.0.16-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/ext/psych/psych_emitter.c +15 -4
- data/ext/psych/yaml/scanner.c +1 -1
- data/lib/psych.jar +0 -0
- data/lib/psych.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +2 -1
- data/lib/psych/visitors/yaml_tree.rb +13 -21
- data/test/psych/helper.rb +1 -1
- data/test/psych/test_encoding.rb +9 -0
- data/test/psych/test_psych.rb +11 -1
- data/test/psych/test_yamldbm.rb +0 -1
- data/test/psych/visitors/test_to_ruby.rb +7 -9
- 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: 6f4110ab7047d2c3994b5bf979138b0b8dbc1df8
|
4
|
+
data.tar.gz: bc958a3e425bc1725b46967c0c7bc1ebf02bcf02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b841b4ac9cb6d5455f34ee0ed82004bbb8d4c354a08fa8b2de478714b503b82d072847db6bb4ed9508e566ae23a27e6ab5c9f34925c542028a01a65174d3bad
|
7
|
+
data.tar.gz: 5c980e0ab8c7dbc86a695f55f868f47ab0b27ee7ed12494671de683588a7a0ed7aa02f8a7e6b1a79d9bab7f951a7edfb99821061e9316af60c8df82808bc3255
|
data/.travis.yml
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
|
}
|
@@ -155,7 +166,7 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
|
155
166
|
}
|
156
167
|
|
157
168
|
if(RTEST(tags)) {
|
158
|
-
|
169
|
+
long i = 0;
|
159
170
|
#ifdef HAVE_RUBY_ENCODING_H
|
160
171
|
rb_encoding * encoding = rb_utf8_encoding();
|
161
172
|
#endif
|
@@ -166,7 +177,7 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
|
166
177
|
tail = head;
|
167
178
|
|
168
179
|
for(i = 0; i < RARRAY_LEN(tags); i++) {
|
169
|
-
VALUE tuple =
|
180
|
+
VALUE tuple = RARRAY_AREF(tags, i);
|
170
181
|
VALUE name;
|
171
182
|
VALUE value;
|
172
183
|
|
@@ -176,8 +187,8 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
|
|
176
187
|
xfree(head);
|
177
188
|
rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
|
178
189
|
}
|
179
|
-
name =
|
180
|
-
value =
|
190
|
+
name = RARRAY_AREF(tuple, 0);
|
191
|
+
value = RARRAY_AREF(tuple, 1);
|
181
192
|
#ifdef HAVE_RUBY_ENCODING_H
|
182
193
|
name = rb_str_export_to_enc(name, encoding);
|
183
194
|
value = rb_str_export_to_enc(value, encoding);
|
data/ext/psych/yaml/scanner.c
CHANGED
@@ -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
|
|
data/lib/psych.jar
CHANGED
Binary file
|
data/lib/psych.rb
CHANGED
@@ -330,12 +330,13 @@ module Psych
|
|
330
330
|
list
|
331
331
|
end
|
332
332
|
|
333
|
+
SHOVEL = '<<'
|
333
334
|
def revive_hash hash, o
|
334
335
|
o.children.each_slice(2) { |k,v|
|
335
336
|
key = accept(k)
|
336
337
|
val = accept(v)
|
337
338
|
|
338
|
-
if key ==
|
339
|
+
if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
|
339
340
|
case v
|
340
341
|
when Nodes::Alias, Nodes::Mapping
|
341
342
|
begin
|
@@ -70,6 +70,14 @@ module Psych
|
|
70
70
|
@ss = ss
|
71
71
|
@options = options
|
72
72
|
@line_width = options[:line_width]
|
73
|
+
if @line_width && @line_width < 0
|
74
|
+
if @line_width == -1
|
75
|
+
# Treat -1 as unlimited line-width, same as libyaml does.
|
76
|
+
@line_width = nil
|
77
|
+
else
|
78
|
+
fail(ArgumentError, "Invalid line_width #{@line_width}, must be non-negative or -1 for unlimited.")
|
79
|
+
end
|
80
|
+
end
|
73
81
|
@coders = []
|
74
82
|
|
75
83
|
@dispatch_cache = Hash.new do |h,klass|
|
@@ -510,27 +518,11 @@ module Psych
|
|
510
518
|
def dump_list o
|
511
519
|
end
|
512
520
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
if time.utc?
|
519
|
-
formatted += " Z"
|
520
|
-
else
|
521
|
-
zone = time.strftime('%z')
|
522
|
-
formatted += " #{zone[0,3]}:#{zone[3,5]}"
|
523
|
-
end
|
524
|
-
|
525
|
-
formatted
|
526
|
-
end
|
527
|
-
else
|
528
|
-
def format_time time
|
529
|
-
if time.utc?
|
530
|
-
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
|
531
|
-
else
|
532
|
-
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
|
533
|
-
end
|
521
|
+
def format_time time
|
522
|
+
if time.utc?
|
523
|
+
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
|
524
|
+
else
|
525
|
+
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
|
534
526
|
end
|
535
527
|
end
|
536
528
|
|
data/test/psych/helper.rb
CHANGED
data/test/psych/test_encoding.rb
CHANGED
@@ -249,6 +249,15 @@ module Psych
|
|
249
249
|
assert_encodings @utf8, @handler.strings
|
250
250
|
end
|
251
251
|
|
252
|
+
def test_dump_non_ascii_string_to_file
|
253
|
+
Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t|
|
254
|
+
h = {'one' => 'いち'}
|
255
|
+
Psych.dump(h, t)
|
256
|
+
t.close
|
257
|
+
assert_equal h, Psych.load_file(t.path)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
252
261
|
private
|
253
262
|
def assert_encodings encoding, strings
|
254
263
|
strings.each do |str|
|
data/test/psych/test_psych.rb
CHANGED
@@ -8,7 +8,17 @@ class TestPsych < Psych::TestCase
|
|
8
8
|
Psych.domain_types.clear
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def test_line_width_invalid
|
12
|
+
assert_raises(ArgumentError) { Psych.dump('x', { :line_width => -2 }) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_line_width_no_limit
|
16
|
+
data = { 'a' => 'a b' * 50}
|
17
|
+
expected = "---\na: #{'a b' * 50}\n"
|
18
|
+
assert_equal(expected, Psych.dump(data, { :line_width => -1 }))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_line_width_limit
|
12
22
|
yml = Psych.dump('123456 7', { :line_width => 5 })
|
13
23
|
assert_match(/^\s*7/, yml)
|
14
24
|
end
|
data/test/psych/test_yamldbm.rb
CHANGED
@@ -166,16 +166,14 @@ description:
|
|
166
166
|
assert_equal Complex(1,2), mapping.to_ruby
|
167
167
|
end
|
168
168
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
end
|
169
|
+
def test_complex_string
|
170
|
+
node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
|
171
|
+
assert_equal Complex(3, 4), node.to_ruby
|
172
|
+
end
|
174
173
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
end
|
174
|
+
def test_rational_string
|
175
|
+
node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
|
176
|
+
assert_equal Rational(1, 2), node.to_ruby
|
179
177
|
end
|
180
178
|
|
181
179
|
def test_range_string
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.16
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jar-dependencies
|