psych 1.3.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +138 -0
- data/Manifest.txt +27 -8
- data/README.rdoc +23 -2
- data/Rakefile +1 -1
- data/ext/psych/depend +3 -0
- data/ext/psych/extconf.rb +27 -11
- data/ext/psych/psych.h +4 -4
- data/ext/psych/{emitter.c → psych_emitter.c} +0 -0
- data/ext/psych/{emitter.h → psych_emitter.h} +0 -0
- data/ext/psych/{parser.c → psych_parser.c} +1 -1
- data/ext/psych/{parser.h → psych_parser.h} +0 -0
- data/ext/psych/{to_ruby.c → psych_to_ruby.c} +3 -1
- data/ext/psych/{to_ruby.h → psych_to_ruby.h} +0 -0
- data/ext/psych/{yaml_tree.c → psych_yaml_tree.c} +0 -0
- data/ext/psych/{yaml_tree.h → psych_yaml_tree.h} +0 -0
- data/ext/psych/yaml/LICENSE +19 -0
- data/ext/psych/yaml/api.c +1392 -0
- data/ext/psych/yaml/config.h +11 -0
- data/ext/psych/yaml/dumper.c +394 -0
- data/ext/psych/yaml/emitter.c +2329 -0
- data/ext/psych/yaml/loader.c +432 -0
- data/ext/psych/yaml/parser.c +1374 -0
- data/ext/psych/yaml/reader.c +465 -0
- data/ext/psych/yaml/scanner.c +3570 -0
- data/ext/psych/yaml/writer.c +141 -0
- data/ext/psych/yaml/yaml.h +1971 -0
- data/ext/psych/yaml/yaml_private.h +643 -0
- data/lib/psych.rb +217 -51
- data/lib/psych/class_loader.rb +101 -0
- data/lib/psych/core_ext.rb +1 -8
- data/lib/psych/deprecated.rb +3 -1
- data/lib/psych/exception.rb +13 -0
- data/lib/psych/handler.rb +13 -0
- data/lib/psych/handlers/recorder.rb +39 -0
- data/lib/psych/json/stream.rb +1 -0
- data/lib/psych/nodes/node.rb +3 -1
- data/lib/psych/scalar_scanner.rb +46 -25
- data/lib/psych/stream.rb +1 -0
- data/lib/psych/streaming.rb +10 -5
- data/lib/psych/syntax_error.rb +3 -1
- data/lib/psych/visitors/json_tree.rb +5 -2
- data/lib/psych/visitors/to_ruby.rb +123 -75
- data/lib/psych/visitors/yaml_tree.rb +59 -17
- data/lib/psych/y.rb +9 -0
- data/test/psych/handlers/test_recorder.rb +25 -0
- data/test/psych/helper.rb +30 -1
- data/test/psych/test_alias_and_anchor.rb +1 -1
- data/test/psych/test_array.rb +1 -1
- data/test/psych/test_boolean.rb +1 -1
- data/test/psych/test_class.rb +1 -1
- data/test/psych/test_coder.rb +3 -3
- data/test/psych/test_date_time.rb +1 -1
- data/test/psych/test_deprecated.rb +6 -2
- data/test/psych/test_document.rb +1 -1
- data/test/psych/test_emitter.rb +1 -1
- data/test/psych/test_encoding.rb +51 -65
- data/test/psych/test_engine_manager.rb +1 -11
- data/test/psych/test_exception.rb +40 -19
- data/test/psych/test_hash.rb +1 -1
- data/test/psych/test_json_tree.rb +1 -1
- data/test/psych/test_merge_keys.rb +52 -1
- data/test/psych/test_nil.rb +1 -1
- data/test/psych/test_null.rb +1 -1
- data/test/psych/test_numeric.rb +21 -1
- data/test/psych/test_object.rb +1 -1
- data/test/psych/test_object_references.rb +3 -3
- data/test/psych/test_omap.rb +1 -1
- data/test/psych/test_parser.rb +1 -1
- data/test/psych/test_psych.rb +15 -15
- data/test/psych/test_safe_load.rb +97 -0
- data/test/psych/test_scalar.rb +1 -1
- data/test/psych/test_scalar_scanner.rb +17 -2
- data/test/psych/test_serialize_subclasses.rb +1 -1
- data/test/psych/test_set.rb +1 -1
- data/test/psych/test_stream.rb +1 -1
- data/test/psych/test_string.rb +51 -3
- data/test/psych/test_struct.rb +1 -1
- data/test/psych/test_symbol.rb +1 -1
- data/test/psych/test_tainted.rb +8 -8
- data/test/psych/test_to_yaml_properties.rb +1 -1
- data/test/psych/test_tree_builder.rb +1 -1
- data/test/psych/test_yaml.rb +22 -2
- data/test/psych/test_yamldbm.rb +1 -1
- data/test/psych/test_yamlstore.rb +1 -1
- data/test/psych/visitors/test_to_ruby.rb +5 -4
- data/test/psych/visitors/test_yaml_tree.rb +19 -1
- metadata +45 -34
data/test/psych/test_set.rb
CHANGED
data/test/psych/test_stream.rb
CHANGED
data/test/psych/test_string.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'helper'
|
2
2
|
|
3
3
|
module Psych
|
4
4
|
class TestString < TestCase
|
@@ -9,6 +9,37 @@ module Psych
|
|
9
9
|
attr_accessor :val
|
10
10
|
end
|
11
11
|
|
12
|
+
class Z < String
|
13
|
+
def initialize
|
14
|
+
force_encoding Encoding::US_ASCII
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_string_subclass_with_anchor
|
19
|
+
y = Psych.load <<-eoyml
|
20
|
+
---
|
21
|
+
body:
|
22
|
+
string: &70121654388580 !ruby/string
|
23
|
+
str: ! 'foo'
|
24
|
+
x:
|
25
|
+
body: *70121654388580
|
26
|
+
eoyml
|
27
|
+
assert_equal({"body"=>{"string"=>"foo", "x"=>{"body"=>"foo"}}}, y)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_self_referential_string
|
31
|
+
y = Psych.load <<-eoyml
|
32
|
+
---
|
33
|
+
string: &70121654388580 !ruby/string
|
34
|
+
str: ! 'foo'
|
35
|
+
body: *70121654388580
|
36
|
+
eoyml
|
37
|
+
|
38
|
+
assert_equal({"string"=>"foo"}, y)
|
39
|
+
value = y['string']
|
40
|
+
assert_equal value, value.instance_variable_get(:@body)
|
41
|
+
end
|
42
|
+
|
12
43
|
def test_another_subclass_with_attributes
|
13
44
|
y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
|
14
45
|
assert_equal "foo", y
|
@@ -28,6 +59,12 @@ module Psych
|
|
28
59
|
assert_equal X, x.class
|
29
60
|
end
|
30
61
|
|
62
|
+
def test_empty_character_subclass
|
63
|
+
assert_match "!ruby/string:#{Z}", Psych.dump(Z.new)
|
64
|
+
x = Psych.load Psych.dump Z.new
|
65
|
+
assert_equal Z, x.class
|
66
|
+
end
|
67
|
+
|
31
68
|
def test_subclass_with_attributes
|
32
69
|
y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1}
|
33
70
|
assert_equal Y, y.class
|
@@ -40,8 +77,8 @@ module Psych
|
|
40
77
|
assert_equal '01:03:05', Psych.load(yaml)
|
41
78
|
end
|
42
79
|
|
43
|
-
def
|
44
|
-
string = "hello world!"
|
80
|
+
def test_nonascii_string_as_binary
|
81
|
+
string = "hello \x80 world!"
|
45
82
|
string.force_encoding 'ascii-8bit'
|
46
83
|
yml = Psych.dump string
|
47
84
|
assert_match(/binary/, yml)
|
@@ -69,6 +106,13 @@ module Psych
|
|
69
106
|
assert_equal string, Psych.load(yml)
|
70
107
|
end
|
71
108
|
|
109
|
+
def test_ascii_only_8bit_string
|
110
|
+
string = "abc".encode(Encoding::ASCII_8BIT)
|
111
|
+
yml = Psych.dump string
|
112
|
+
refute_match(/binary/, yml)
|
113
|
+
assert_equal string, Psych.load(yml)
|
114
|
+
end
|
115
|
+
|
72
116
|
def test_string_with_ivars
|
73
117
|
food = "is delicious"
|
74
118
|
ivar = "on rock and roll"
|
@@ -83,6 +127,10 @@ module Psych
|
|
83
127
|
assert_cycle string
|
84
128
|
end
|
85
129
|
|
130
|
+
def test_float_confusion
|
131
|
+
assert_cycle '1.'
|
132
|
+
end
|
133
|
+
|
86
134
|
def binary_string percentage = 0.31, length = 100
|
87
135
|
string = ''
|
88
136
|
(percentage * length).to_i.times do |i|
|
data/test/psych/test_struct.rb
CHANGED
data/test/psych/test_symbol.rb
CHANGED
data/test/psych/test_tainted.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative 'helper'
|
2
2
|
|
3
3
|
module Psych
|
4
4
|
class TestStringTainted < TestCase
|
@@ -117,14 +117,14 @@ module Psych
|
|
117
117
|
|
118
118
|
class TestIOTainted < TestStringTainted
|
119
119
|
def assert_taintedness string
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
120
|
+
Tempfile.create(['something', 'yml']) {|t|
|
121
|
+
t.binmode
|
122
|
+
t.write string
|
123
|
+
t.close
|
124
|
+
File.open(t.path, 'r:bom|utf-8') { |f|
|
125
|
+
@parser.parse f
|
126
|
+
}
|
126
127
|
}
|
127
|
-
t.close(true)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
data/test/psych/test_yaml.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*-
|
1
|
+
# -*- coding: us-ascii; mode: ruby; ruby-indent-level: 4; tab-width: 4 -*-
|
2
2
|
# vim:sw=4:ts=4
|
3
3
|
# $Id$
|
4
4
|
#
|
5
|
-
|
5
|
+
require_relative 'helper'
|
6
6
|
require 'ostruct'
|
7
7
|
|
8
8
|
# [ruby-core:01946]
|
@@ -1266,4 +1266,24 @@ EOY
|
|
1266
1266
|
Psych.load("2000-01-01 00:00:00.#{"0"*1000} +00:00\n")
|
1267
1267
|
# '[ruby-core:13735]'
|
1268
1268
|
end
|
1269
|
+
|
1270
|
+
def test_multiline_string_uses_literal_style
|
1271
|
+
yaml = Psych.dump("multi\nline\nstring")
|
1272
|
+
assert_match("|", yaml)
|
1273
|
+
end
|
1274
|
+
|
1275
|
+
def test_string_starting_with_non_word_character_uses_double_quotes_without_exclamation_mark
|
1276
|
+
yaml = Psych.dump("@123'abc")
|
1277
|
+
refute_match("!", yaml)
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
def test_string_dump_with_colon
|
1281
|
+
yaml = Psych.dump 'x: foo'
|
1282
|
+
refute_match '!', yaml
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
def test_string_dump_starting_with_star
|
1286
|
+
yaml = Psych.dump '*foo'
|
1287
|
+
refute_match '!', yaml
|
1288
|
+
end
|
1269
1289
|
end
|
data/test/psych/test_yamldbm.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: US-ASCII
|
1
2
|
require 'psych/helper'
|
2
3
|
|
3
4
|
module Psych
|
@@ -5,7 +6,7 @@ module Psych
|
|
5
6
|
class TestToRuby < TestCase
|
6
7
|
def setup
|
7
8
|
super
|
8
|
-
@visitor = ToRuby.
|
9
|
+
@visitor = ToRuby.create
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_object
|
@@ -17,8 +18,8 @@ module Psych
|
|
17
18
|
assert_equal 'bar', o.instance_variable_get(:@foo)
|
18
19
|
end
|
19
20
|
|
20
|
-
def
|
21
|
-
Psych.load('1900-01-01T00:00:00+00:00')
|
21
|
+
def test_tz_00_00_loads_without_error
|
22
|
+
assert Psych.load('1900-01-01T00:00:00+00:00')
|
22
23
|
end
|
23
24
|
|
24
25
|
def test_legacy_struct
|
@@ -87,7 +88,7 @@ description:
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def test_exception
|
90
|
-
exc = Exception.new 'hello'
|
91
|
+
exc = ::Exception.new 'hello'
|
91
92
|
|
92
93
|
mapping = Nodes::Mapping.new nil, '!ruby/exception'
|
93
94
|
mapping.children << Nodes::Scalar.new('message')
|
@@ -5,7 +5,25 @@ module Psych
|
|
5
5
|
class TestYAMLTree < TestCase
|
6
6
|
def setup
|
7
7
|
super
|
8
|
-
@v = Visitors::YAMLTree.
|
8
|
+
@v = Visitors::YAMLTree.create
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_tree_can_be_called_twice
|
12
|
+
@v.start
|
13
|
+
@v << Object.new
|
14
|
+
t = @v.tree
|
15
|
+
assert_equal t, @v.tree
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_yaml_tree_can_take_an_emitter
|
19
|
+
io = StringIO.new
|
20
|
+
e = Psych::Emitter.new io
|
21
|
+
v = Visitors::YAMLTree.create({}, e)
|
22
|
+
v.start
|
23
|
+
v << "hello world"
|
24
|
+
v.finish
|
25
|
+
|
26
|
+
assert_match "hello world", io.string
|
9
27
|
end
|
10
28
|
|
11
29
|
def test_binary_formatting
|
metadata
CHANGED
@@ -1,71 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Aaron Patterson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rdoc
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '4.0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '4.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake-compiler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.4.1
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.4.1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: hoe
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '3.
|
47
|
+
version: '3.6'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
62
|
-
description:
|
63
|
-
|
54
|
+
version: '3.6'
|
55
|
+
description: |-
|
56
|
+
Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
|
64
57
|
for its YAML parsing and emitting capabilities. In addition to wrapping
|
65
|
-
|
66
58
|
libyaml, Psych also knows how to serialize and de-serialize most Ruby objects
|
67
|
-
|
68
|
-
to and from the YAML format.'
|
59
|
+
to and from the YAML format.
|
69
60
|
email:
|
70
61
|
- aaron@tenderlovemaking.com
|
71
62
|
executables: []
|
@@ -82,23 +73,39 @@ files:
|
|
82
73
|
- Manifest.txt
|
83
74
|
- README.rdoc
|
84
75
|
- Rakefile
|
85
|
-
- ext/psych/
|
86
|
-
- ext/psych/emitter.h
|
76
|
+
- ext/psych/depend
|
87
77
|
- ext/psych/extconf.rb
|
88
|
-
- ext/psych/parser.c
|
89
|
-
- ext/psych/parser.h
|
90
78
|
- ext/psych/psych.c
|
91
79
|
- ext/psych/psych.h
|
92
|
-
- ext/psych/
|
93
|
-
- ext/psych/
|
94
|
-
- ext/psych/
|
95
|
-
- ext/psych/
|
80
|
+
- ext/psych/psych_emitter.c
|
81
|
+
- ext/psych/psych_emitter.h
|
82
|
+
- ext/psych/psych_parser.c
|
83
|
+
- ext/psych/psych_parser.h
|
84
|
+
- ext/psych/psych_to_ruby.c
|
85
|
+
- ext/psych/psych_to_ruby.h
|
86
|
+
- ext/psych/psych_yaml_tree.c
|
87
|
+
- ext/psych/psych_yaml_tree.h
|
88
|
+
- ext/psych/yaml/LICENSE
|
89
|
+
- ext/psych/yaml/api.c
|
90
|
+
- ext/psych/yaml/config.h
|
91
|
+
- ext/psych/yaml/dumper.c
|
92
|
+
- ext/psych/yaml/emitter.c
|
93
|
+
- ext/psych/yaml/loader.c
|
94
|
+
- ext/psych/yaml/parser.c
|
95
|
+
- ext/psych/yaml/reader.c
|
96
|
+
- ext/psych/yaml/scanner.c
|
97
|
+
- ext/psych/yaml/writer.c
|
98
|
+
- ext/psych/yaml/yaml.h
|
99
|
+
- ext/psych/yaml/yaml_private.h
|
96
100
|
- lib/psych.rb
|
101
|
+
- lib/psych/class_loader.rb
|
97
102
|
- lib/psych/coder.rb
|
98
103
|
- lib/psych/core_ext.rb
|
99
104
|
- lib/psych/deprecated.rb
|
105
|
+
- lib/psych/exception.rb
|
100
106
|
- lib/psych/handler.rb
|
101
107
|
- lib/psych/handlers/document_stream.rb
|
108
|
+
- lib/psych/handlers/recorder.rb
|
102
109
|
- lib/psych/json/ruby_events.rb
|
103
110
|
- lib/psych/json/stream.rb
|
104
111
|
- lib/psych/json/tree_builder.rb
|
@@ -126,6 +133,8 @@ files:
|
|
126
133
|
- lib/psych/visitors/to_ruby.rb
|
127
134
|
- lib/psych/visitors/visitor.rb
|
128
135
|
- lib/psych/visitors/yaml_tree.rb
|
136
|
+
- lib/psych/y.rb
|
137
|
+
- test/psych/handlers/test_recorder.rb
|
129
138
|
- test/psych/helper.rb
|
130
139
|
- test/psych/json/test_stream.rb
|
131
140
|
- test/psych/nodes/test_enumerable.rb
|
@@ -152,6 +161,7 @@ files:
|
|
152
161
|
- test/psych/test_omap.rb
|
153
162
|
- test/psych/test_parser.rb
|
154
163
|
- test/psych/test_psych.rb
|
164
|
+
- test/psych/test_safe_load.rb
|
155
165
|
- test/psych/test_scalar.rb
|
156
166
|
- test/psych/test_scalar_scanner.rb
|
157
167
|
- test/psych/test_serialize_subclasses.rb
|
@@ -173,6 +183,7 @@ files:
|
|
173
183
|
- .gemtest
|
174
184
|
homepage: http://github.com/tenderlove/psych
|
175
185
|
licenses: []
|
186
|
+
metadata: {}
|
176
187
|
post_install_message:
|
177
188
|
rdoc_options:
|
178
189
|
- --main
|
@@ -180,24 +191,23 @@ rdoc_options:
|
|
180
191
|
require_paths:
|
181
192
|
- lib
|
182
193
|
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
-
none: false
|
184
194
|
requirements:
|
185
|
-
- -
|
195
|
+
- - '>='
|
186
196
|
- !ruby/object:Gem::Version
|
187
197
|
version: 1.9.2
|
188
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
-
none: false
|
190
199
|
requirements:
|
191
|
-
- -
|
200
|
+
- - '>='
|
192
201
|
- !ruby/object:Gem::Version
|
193
202
|
version: '0'
|
194
203
|
requirements: []
|
195
204
|
rubyforge_project: psych
|
196
|
-
rubygems_version:
|
205
|
+
rubygems_version: 2.0.2
|
197
206
|
signing_key:
|
198
|
-
specification_version:
|
207
|
+
specification_version: 4
|
199
208
|
summary: Psych is a YAML parser and emitter
|
200
209
|
test_files:
|
210
|
+
- test/psych/handlers/test_recorder.rb
|
201
211
|
- test/psych/json/test_stream.rb
|
202
212
|
- test/psych/nodes/test_enumerable.rb
|
203
213
|
- test/psych/test_alias_and_anchor.rb
|
@@ -223,6 +233,7 @@ test_files:
|
|
223
233
|
- test/psych/test_omap.rb
|
224
234
|
- test/psych/test_parser.rb
|
225
235
|
- test/psych/test_psych.rb
|
236
|
+
- test/psych/test_safe_load.rb
|
226
237
|
- test/psych/test_scalar.rb
|
227
238
|
- test/psych/test_scalar_scanner.rb
|
228
239
|
- test/psych/test_serialize_subclasses.rb
|