psych 1.2.0 → 1.2.1
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/CHANGELOG.rdoc +12 -0
- data/Rakefile +2 -2
- data/lib/psych.rb +4 -1
- data/lib/psych/core_ext.rb +1 -0
- data/lib/psych/deprecated.rb +1 -0
- data/lib/psych/nodes/node.rb +1 -1
- data/lib/psych/scalar_scanner.rb +5 -2
- data/lib/psych/visitors/to_ruby.rb +2 -2
- data/test/psych/test_encoding.rb +16 -0
- data/test/psych/test_engine_manager.rb +1 -1
- data/test/psych/test_merge_keys.rb +9 -0
- data/test/psych/test_nil.rb +2 -2
- data/test/psych/test_object.rb +17 -0
- data/test/psych/test_yaml.rb +7 -0
- metadata +68 -44
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
Thu Aug 25 06:11:35 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
|
+
|
3
|
+
* ext/psych/lib/psych/nodes/node.rb: default `to_yaml` encoding to be
|
4
|
+
UTF-8.
|
5
|
+
* test/psych/test_encoding.rb: test yaml dump encoding.
|
6
|
+
|
7
|
+
Wed Jun 22 03:20:52 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
8
|
+
|
9
|
+
* ext/psych/lib/psych/visitors/to_ruby.rb: Fix cyclic references of
|
10
|
+
objects. Thanks to CvX for reporting the bug and a test case.
|
11
|
+
* test/psych/test_object.rb: test for cyclic object references.
|
12
|
+
|
1
13
|
Thu Jun 9 10:57:03 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
14
|
|
3
15
|
* ext/psych/lib/psych/visitors/to_ruby.rb: Hash subclasses can be read
|
data/Rakefile
CHANGED
@@ -11,10 +11,10 @@ end
|
|
11
11
|
gem 'rake-compiler', '>= 0.4.1'
|
12
12
|
require "rake/extensiontask"
|
13
13
|
|
14
|
-
Hoe.plugin :debugging, :doofus, :git
|
14
|
+
Hoe.plugin :debugging, :doofus, :git, :gemspec
|
15
15
|
|
16
16
|
Hoe.spec 'psych' do
|
17
|
-
developer 'Aaron Patterson', '
|
17
|
+
developer 'Aaron Patterson', 'aaron@tenderlovemaking.com'
|
18
18
|
|
19
19
|
self.extra_rdoc_files = Dir['*.rdoc']
|
20
20
|
self.history_file = 'CHANGELOG.rdoc'
|
data/lib/psych.rb
CHANGED
@@ -90,7 +90,7 @@ require 'psych/json'
|
|
90
90
|
|
91
91
|
module Psych
|
92
92
|
# The version is Psych you're using
|
93
|
-
VERSION = '1.2.
|
93
|
+
VERSION = '1.2.1'
|
94
94
|
|
95
95
|
# The version of libyaml Psych is using
|
96
96
|
LIBYAML_VERSION = Psych.libyaml_version.join '.'
|
@@ -98,6 +98,9 @@ module Psych
|
|
98
98
|
class Exception < RuntimeError
|
99
99
|
end
|
100
100
|
|
101
|
+
class BadAlias < Exception
|
102
|
+
end
|
103
|
+
|
101
104
|
autoload :Stream, 'psych/stream'
|
102
105
|
|
103
106
|
###
|
data/lib/psych/core_ext.rb
CHANGED
data/lib/psych/deprecated.rb
CHANGED
data/lib/psych/nodes/node.rb
CHANGED
@@ -41,7 +41,7 @@ module Psych
|
|
41
41
|
#
|
42
42
|
# See also Psych::Visitors::Emitter
|
43
43
|
def to_yaml io = nil, options = {}
|
44
|
-
real_io = io || StringIO.new
|
44
|
+
real_io = io || StringIO.new(''.encode('utf-8'))
|
45
45
|
|
46
46
|
Visitors::Emitter.new(real_io, options).accept self
|
47
47
|
return real_io.string unless io
|
data/lib/psych/scalar_scanner.rb
CHANGED
@@ -68,8 +68,11 @@ module Psych
|
|
68
68
|
end
|
69
69
|
i
|
70
70
|
else
|
71
|
-
|
72
|
-
|
71
|
+
if string.count('.') < 2
|
72
|
+
return Integer(string.gsub(/[,_]/, '')) rescue ArgumentError
|
73
|
+
return Float(string.gsub(/[,_]/, '')) rescue ArgumentError
|
74
|
+
end
|
75
|
+
|
73
76
|
@string_cache[string] = true
|
74
77
|
string
|
75
78
|
end
|
@@ -182,7 +182,6 @@ module Psych
|
|
182
182
|
when /^!ruby\/object:?(.*)?$/
|
183
183
|
name = $1 || 'Object'
|
184
184
|
obj = revive((resolve_class(name) || Object), o)
|
185
|
-
@st[o.anchor] = obj if o.anchor
|
186
185
|
obj
|
187
186
|
|
188
187
|
when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
|
@@ -202,7 +201,7 @@ module Psych
|
|
202
201
|
end
|
203
202
|
|
204
203
|
def visit_Psych_Nodes_Alias o
|
205
|
-
@st
|
204
|
+
@st.fetch(o.anchor) { raise BadAlias, "Unknown alias: #{o.anchor}" }
|
206
205
|
end
|
207
206
|
|
208
207
|
private
|
@@ -233,6 +232,7 @@ module Psych
|
|
233
232
|
|
234
233
|
def revive klass, node
|
235
234
|
s = klass.allocate
|
235
|
+
@st[node.anchor] = s if node.anchor
|
236
236
|
h = Hash[*node.children.map { |c| accept c }]
|
237
237
|
init_with(s, h, node)
|
238
238
|
end
|
data/test/psych/test_encoding.rb
CHANGED
@@ -40,6 +40,22 @@ module Psych
|
|
40
40
|
assert_match(/alias value/, e.message)
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_to_yaml_is_valid
|
44
|
+
ext_before = Encoding.default_external
|
45
|
+
int_before = Encoding.default_internal
|
46
|
+
|
47
|
+
Encoding.default_external = Encoding::US_ASCII
|
48
|
+
Encoding.default_internal = nil
|
49
|
+
|
50
|
+
s = "こんにちは!"
|
51
|
+
# If no encoding is specified, use UTF-8
|
52
|
+
assert_equal Encoding::UTF_8, Psych.dump(s).encoding
|
53
|
+
assert_equal s, Psych.load(Psych.dump(s))
|
54
|
+
ensure
|
55
|
+
Encoding.default_external = ext_before
|
56
|
+
Encoding.default_internal = int_before
|
57
|
+
end
|
58
|
+
|
43
59
|
def test_start_mapping
|
44
60
|
foo = 'foo'
|
45
61
|
bar = 'バー'
|
@@ -2,6 +2,15 @@ require 'psych/helper'
|
|
2
2
|
|
3
3
|
module Psych
|
4
4
|
class TestMergeKeys < TestCase
|
5
|
+
def test_missing_merge_key
|
6
|
+
yaml = <<-eoyml
|
7
|
+
bar:
|
8
|
+
<< : *foo
|
9
|
+
eoyml
|
10
|
+
exp = assert_raises(Psych::BadAlias) { Psych.load yaml }
|
11
|
+
assert_match 'foo', exp.message
|
12
|
+
end
|
13
|
+
|
5
14
|
# [ruby-core:34679]
|
6
15
|
def test_merge_key
|
7
16
|
yaml = <<-eoyml
|
data/test/psych/test_nil.rb
CHANGED
data/test/psych/test_object.rb
CHANGED
@@ -11,6 +11,14 @@ module Psych
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
class Foo
|
15
|
+
attr_accessor :parent
|
16
|
+
|
17
|
+
def initialize parent
|
18
|
+
@parent = parent
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
class TestObject < TestCase
|
15
23
|
def test_dump_with_tag
|
16
24
|
tag = Tagged.new
|
@@ -23,5 +31,14 @@ module Psych
|
|
23
31
|
assert_equal tag.baz, tag2.baz
|
24
32
|
assert_instance_of(Tagged, tag2)
|
25
33
|
end
|
34
|
+
|
35
|
+
def test_cyclic_references
|
36
|
+
foo = Foo.new(nil)
|
37
|
+
foo.parent = foo
|
38
|
+
loaded = Psych.load Psych.dump foo
|
39
|
+
|
40
|
+
assert_instance_of(Foo, loaded)
|
41
|
+
assert_equal loaded, loaded.parent
|
42
|
+
end
|
26
43
|
end
|
27
44
|
end
|
data/test/psych/test_yaml.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# $Id$
|
4
4
|
#
|
5
5
|
require 'psych/helper'
|
6
|
+
require 'ostruct'
|
6
7
|
|
7
8
|
# [ruby-core:01946]
|
8
9
|
module Psych_Tests
|
@@ -14,6 +15,12 @@ class Psych_Unit_Tests < Psych::TestCase
|
|
14
15
|
Psych.domain_types.clear
|
15
16
|
end
|
16
17
|
|
18
|
+
def test_y_method
|
19
|
+
assert_raises(NoMethodError) do
|
20
|
+
OpenStruct.new.y 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
17
24
|
def test_syck_compat
|
18
25
|
time = Time.utc(2010, 10, 10)
|
19
26
|
yaml = Psych.dump time
|
metadata
CHANGED
@@ -1,55 +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
|
+
hash: 29
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Aaron Patterson
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-08-24 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rake-compiler
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 13
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 4
|
32
|
+
- 1
|
21
33
|
version: 0.4.1
|
22
34
|
type: :development
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
26
37
|
name: hoe
|
27
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 27
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 12
|
48
|
+
version: "2.12"
|
33
49
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
50
|
+
version_requirements: *id002
|
51
|
+
description: |-
|
52
|
+
Psych is a YAML parser and emitter. Psych leverages libyaml[http://libyaml.org]
|
38
53
|
for its YAML parsing and emitting capabilities. In addition to wrapping
|
39
|
-
|
40
54
|
libyaml, Psych also knows how to serialize and de-serialize most Ruby objects
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
- aaronp@rubyforge.org
|
55
|
+
to and from the YAML format.
|
56
|
+
email:
|
57
|
+
- aaron@tenderlovemaking.com
|
45
58
|
executables: []
|
46
|
-
|
59
|
+
|
60
|
+
extensions:
|
47
61
|
- ext/psych/extconf.rb
|
48
|
-
extra_rdoc_files:
|
62
|
+
extra_rdoc_files:
|
49
63
|
- Manifest.txt
|
50
64
|
- CHANGELOG.rdoc
|
51
65
|
- README.rdoc
|
52
|
-
files:
|
66
|
+
files:
|
53
67
|
- .autotest
|
54
68
|
- CHANGELOG.rdoc
|
55
69
|
- Manifest.txt
|
@@ -141,31 +155,41 @@ files:
|
|
141
155
|
- .gemtest
|
142
156
|
homepage: http://github.com/tenderlove/psych
|
143
157
|
licenses: []
|
158
|
+
|
144
159
|
post_install_message:
|
145
|
-
rdoc_options:
|
160
|
+
rdoc_options:
|
146
161
|
- --main
|
147
162
|
- README.rdoc
|
148
|
-
require_paths:
|
163
|
+
require_paths:
|
149
164
|
- lib
|
150
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
166
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
hash: 55
|
171
|
+
segments:
|
172
|
+
- 1
|
173
|
+
- 9
|
174
|
+
- 2
|
155
175
|
version: 1.9.2
|
156
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
177
|
none: false
|
158
|
-
requirements:
|
159
|
-
- -
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
hash: 3
|
182
|
+
segments:
|
183
|
+
- 0
|
184
|
+
version: "0"
|
162
185
|
requirements: []
|
186
|
+
|
163
187
|
rubyforge_project: psych
|
164
|
-
rubygems_version: 1.8.
|
188
|
+
rubygems_version: 1.8.8
|
165
189
|
signing_key:
|
166
190
|
specification_version: 3
|
167
191
|
summary: Psych is a YAML parser and emitter
|
168
|
-
test_files:
|
192
|
+
test_files:
|
169
193
|
- test/psych/json/test_stream.rb
|
170
194
|
- test/psych/nodes/test_enumerable.rb
|
171
195
|
- test/psych/test_alias_and_anchor.rb
|