psych 1.2.2 → 1.3.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.
- data/.travis.yml +6 -0
- data/CHANGELOG.rdoc +126 -0
- data/Manifest.txt +3 -2
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/ext/psych/emitter.c +1 -1
- data/ext/psych/parser.c +241 -62
- data/lib/psych.rb +86 -21
- data/lib/psych/core_ext.rb +2 -0
- data/lib/psych/handlers/document_stream.rb +22 -0
- data/lib/psych/parser.rb +4 -0
- data/lib/psych/scalar_scanner.rb +15 -5
- data/lib/psych/syntax_error.rb +19 -0
- data/lib/psych/tree_builder.rb +3 -1
- data/lib/psych/visitors/to_ruby.rb +51 -15
- data/lib/psych/visitors/yaml_tree.rb +58 -11
- data/test/psych/test_array.rb +28 -0
- data/test/psych/test_encoding.rb +73 -0
- data/test/psych/test_exception.rb +91 -0
- data/test/psych/test_numeric.rb +11 -0
- data/test/psych/test_object_references.rb +67 -0
- data/test/psych/test_parser.rb +44 -9
- data/test/psych/test_scalar_scanner.rb +22 -0
- data/test/psych/test_stream.rb +44 -0
- data/test/psych/test_string.rb +31 -0
- data/test/psych/test_struct.rb +1 -3
- data/test/psych/test_tainted.rb +3 -1
- data/test/psych/test_yamldbm.rb +16 -9
- data/test/psych/test_yamlstore.rb +6 -6
- metadata +57 -68
- data/Gemfile +0 -11
- data/lib/psych/json.rb +0 -6
data/test/psych/test_string.rb
CHANGED
@@ -2,6 +2,37 @@ require 'psych/helper'
|
|
2
2
|
|
3
3
|
module Psych
|
4
4
|
class TestString < TestCase
|
5
|
+
class X < String
|
6
|
+
end
|
7
|
+
|
8
|
+
class Y < String
|
9
|
+
attr_accessor :val
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_backwards_with_syck
|
13
|
+
x = Psych.load "--- !str:#{X.name} foo\n\n"
|
14
|
+
assert_equal X, x.class
|
15
|
+
assert_equal 'foo', x
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_empty_subclass
|
19
|
+
assert_match "!ruby/string:#{X}", Psych.dump(X.new)
|
20
|
+
x = Psych.load Psych.dump X.new
|
21
|
+
assert_equal X, x.class
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_subclass_with_attributes
|
25
|
+
y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1}
|
26
|
+
assert_equal Y, y.class
|
27
|
+
assert_equal 1, y.val
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_string_with_base_60
|
31
|
+
yaml = Psych.dump '01:03:05'
|
32
|
+
assert_match "'01:03:05'", yaml
|
33
|
+
assert_equal '01:03:05', Psych.load(yaml)
|
34
|
+
end
|
35
|
+
|
5
36
|
def test_tagged_binary_should_be_dumped_as_binary
|
6
37
|
string = "hello world!"
|
7
38
|
string.force_encoding 'ascii-8bit'
|
data/test/psych/test_struct.rb
CHANGED
@@ -24,9 +24,7 @@ module Psych
|
|
24
24
|
loaded = Psych.load(Psych.dump(ss))
|
25
25
|
assert_instance_of(StructSubclass, loaded.foo)
|
26
26
|
|
27
|
-
|
28
|
-
# in ruby.
|
29
|
-
# assert_equal(ss, loaded)
|
27
|
+
assert_equal(ss, loaded)
|
30
28
|
end
|
31
29
|
|
32
30
|
def test_roundtrip
|
data/test/psych/test_tainted.rb
CHANGED
data/test/psych/test_yamldbm.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
2
|
-
|
3
|
-
require '
|
2
|
+
|
3
|
+
require 'psych/helper'
|
4
4
|
require 'tmpdir'
|
5
|
-
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'yaml/dbm'
|
8
|
+
rescue LoadError
|
9
|
+
end
|
6
10
|
|
7
11
|
module Psych
|
8
|
-
|
12
|
+
::Psych::DBM = ::YAML::DBM unless defined?(::Psych::DBM)
|
13
|
+
|
14
|
+
class YAMLDBMTest < TestCase
|
9
15
|
def setup
|
10
16
|
@engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
|
11
17
|
@dir = Dir.mktmpdir("rubytest-file")
|
@@ -44,7 +50,7 @@ module Psych
|
|
44
50
|
def test_to_a
|
45
51
|
@yamldbm['a'] = 'b'
|
46
52
|
@yamldbm['c'] = 'd'
|
47
|
-
assert_equal([['a','b'],['c','d']], @yamldbm.to_a)
|
53
|
+
assert_equal([['a','b'],['c','d']], @yamldbm.to_a.sort)
|
48
54
|
end
|
49
55
|
|
50
56
|
def test_to_hash
|
@@ -75,6 +81,7 @@ module Psych
|
|
75
81
|
# end
|
76
82
|
|
77
83
|
def test_key
|
84
|
+
skip 'only on ruby 2.0.0' if RUBY_VERSION < '2.0.0'
|
78
85
|
@yamldbm['a'] = 'b'
|
79
86
|
@yamldbm['c'] = 'd'
|
80
87
|
assert_equal 'a', @yamldbm.key('b')
|
@@ -93,8 +100,8 @@ module Psych
|
|
93
100
|
def test_shift
|
94
101
|
@yamldbm['a'] = 'b'
|
95
102
|
@yamldbm['c'] = 'd'
|
96
|
-
assert_equal(['a','b'],
|
97
|
-
|
103
|
+
assert_equal([['a','b'], ['c','d']],
|
104
|
+
[@yamldbm.shift, @yamldbm.shift].sort)
|
98
105
|
assert_nil @yamldbm.shift
|
99
106
|
end
|
100
107
|
|
@@ -162,7 +169,7 @@ module Psych
|
|
162
169
|
assert_equal [], @yamldbm.values
|
163
170
|
@yamldbm['a'] = 'b'
|
164
171
|
@yamldbm['c'] = 'd'
|
165
|
-
assert_equal ['b','d'], @yamldbm.values
|
172
|
+
assert_equal ['b','d'], @yamldbm.values.sort
|
166
173
|
end
|
167
174
|
|
168
175
|
def test_values_at
|
@@ -187,4 +194,4 @@ module Psych
|
|
187
194
|
assert_equal([], @yamldbm.select {false})
|
188
195
|
end
|
189
196
|
end
|
190
|
-
end
|
197
|
+
end if defined?(YAML::DBM) && defined?(Psych)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'psych/helper'
|
2
2
|
require 'yaml/store'
|
3
3
|
require 'tmpdir'
|
4
4
|
|
5
|
-
Psych::Store = YAML::Store unless defined?(Psych::Store)
|
6
|
-
|
7
5
|
module Psych
|
8
|
-
|
6
|
+
Psych::Store = YAML::Store unless defined?(Psych::Store)
|
7
|
+
|
8
|
+
class YAMLStoreTest < TestCase
|
9
9
|
def setup
|
10
10
|
@engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
|
11
11
|
@dir = Dir.mktmpdir("rubytest-file")
|
@@ -77,11 +77,11 @@ module Psych
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_writing_inside_readonly_transaction_raises_error
|
80
|
-
|
80
|
+
assert_raises(PStore::Error) do
|
81
81
|
@yamlstore.transaction(true) do
|
82
82
|
@yamlstore[:foo] = "bar"
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
87
|
+
end if defined?(Psych)
|
metadata
CHANGED
@@ -1,73 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 2
|
10
|
-
version: 1.2.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Aaron Patterson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rake-compiler
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70343314971360 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 13
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 4
|
32
|
-
- 1
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 0.4.1
|
34
22
|
type: :development
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: hoe
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *70343314971360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rdoc
|
27
|
+
requirement: &70343314970560 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.10'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70343314970560
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: hoe
|
38
|
+
requirement: &70343314969460 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
|
-
requirements:
|
40
|
+
requirements:
|
42
41
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 12
|
48
|
-
version: "2.12"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.13'
|
49
44
|
type: :development
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70343314969460
|
47
|
+
description: ! 'Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
|
48
|
+
|
53
49
|
for its YAML parsing and emitting capabilities. In addition to wrapping
|
50
|
+
|
54
51
|
libyaml, Psych also knows how to serialize and de-serialize most Ruby objects
|
55
|
-
|
56
|
-
|
52
|
+
|
53
|
+
to and from the YAML format.'
|
54
|
+
email:
|
57
55
|
- aaron@tenderlovemaking.com
|
58
56
|
executables: []
|
59
|
-
|
60
|
-
extensions:
|
57
|
+
extensions:
|
61
58
|
- ext/psych/extconf.rb
|
62
|
-
extra_rdoc_files:
|
59
|
+
extra_rdoc_files:
|
63
60
|
- Manifest.txt
|
64
61
|
- CHANGELOG.rdoc
|
65
62
|
- README.rdoc
|
66
|
-
files:
|
63
|
+
files:
|
67
64
|
- .autotest
|
68
65
|
- .travis.yml
|
69
66
|
- CHANGELOG.rdoc
|
70
|
-
- Gemfile
|
71
67
|
- Manifest.txt
|
72
68
|
- README.rdoc
|
73
69
|
- Rakefile
|
@@ -87,7 +83,7 @@ files:
|
|
87
83
|
- lib/psych/core_ext.rb
|
88
84
|
- lib/psych/deprecated.rb
|
89
85
|
- lib/psych/handler.rb
|
90
|
-
- lib/psych/
|
86
|
+
- lib/psych/handlers/document_stream.rb
|
91
87
|
- lib/psych/json/ruby_events.rb
|
92
88
|
- lib/psych/json/stream.rb
|
93
89
|
- lib/psych/json/tree_builder.rb
|
@@ -106,6 +102,7 @@ files:
|
|
106
102
|
- lib/psych/set.rb
|
107
103
|
- lib/psych/stream.rb
|
108
104
|
- lib/psych/streaming.rb
|
105
|
+
- lib/psych/syntax_error.rb
|
109
106
|
- lib/psych/tree_builder.rb
|
110
107
|
- lib/psych/visitors.rb
|
111
108
|
- lib/psych/visitors/depth_first.rb
|
@@ -136,6 +133,7 @@ files:
|
|
136
133
|
- test/psych/test_null.rb
|
137
134
|
- test/psych/test_numeric.rb
|
138
135
|
- test/psych/test_object.rb
|
136
|
+
- test/psych/test_object_references.rb
|
139
137
|
- test/psych/test_omap.rb
|
140
138
|
- test/psych/test_parser.rb
|
141
139
|
- test/psych/test_psych.rb
|
@@ -160,41 +158,31 @@ files:
|
|
160
158
|
- .gemtest
|
161
159
|
homepage: http://github.com/tenderlove/psych
|
162
160
|
licenses: []
|
163
|
-
|
164
161
|
post_install_message:
|
165
|
-
rdoc_options:
|
162
|
+
rdoc_options:
|
166
163
|
- --main
|
167
164
|
- README.rdoc
|
168
|
-
require_paths:
|
165
|
+
require_paths:
|
169
166
|
- lib
|
170
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
168
|
none: false
|
172
|
-
requirements:
|
173
|
-
- -
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
hash: 55
|
176
|
-
segments:
|
177
|
-
- 1
|
178
|
-
- 9
|
179
|
-
- 2
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
180
172
|
version: 1.9.2
|
181
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
174
|
none: false
|
183
|
-
requirements:
|
184
|
-
- -
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
|
187
|
-
segments:
|
188
|
-
- 0
|
189
|
-
version: "0"
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
190
179
|
requirements: []
|
191
|
-
|
192
180
|
rubyforge_project: psych
|
193
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.17
|
194
182
|
signing_key:
|
195
183
|
specification_version: 3
|
196
184
|
summary: Psych is a YAML parser and emitter
|
197
|
-
test_files:
|
185
|
+
test_files:
|
198
186
|
- test/psych/json/test_stream.rb
|
199
187
|
- test/psych/nodes/test_enumerable.rb
|
200
188
|
- test/psych/test_alias_and_anchor.rb
|
@@ -216,6 +204,7 @@ test_files:
|
|
216
204
|
- test/psych/test_null.rb
|
217
205
|
- test/psych/test_numeric.rb
|
218
206
|
- test/psych/test_object.rb
|
207
|
+
- test/psych/test_object_references.rb
|
219
208
|
- test/psych/test_omap.rb
|
220
209
|
- test/psych/test_parser.rb
|
221
210
|
- test/psych/test_psych.rb
|
data/Gemfile
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
|
4
|
-
|
5
|
-
source :gemcutter
|
6
|
-
|
7
|
-
|
8
|
-
gem "rake-compiler", ">=0.4.1", :group => [:development, :test]
|
9
|
-
gem "hoe", "~>2.10", :group => [:development, :test]
|
10
|
-
|
11
|
-
# vim: syntax=ruby
|