psych 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +40 -0
- data/Rakefile +1 -0
- data/ext/psych/yaml/yaml.h +1 -1
- data/lib/psych/scalar_scanner.rb +2 -2
- data/lib/psych/visitors/to_ruby.rb +5 -9
- data/lib/psych/visitors/yaml_tree.rb +18 -9
- data/lib/psych.rb +1 -1
- data/test/psych/test_date_time.rb +13 -0
- data/test/psych/test_merge_keys.rb +18 -0
- data/test/psych/test_string.rb +5 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe34c7fff6c7f07684a5412a451321413187345f
|
4
|
+
data.tar.gz: 5945ad3ed259b7e40a6a29768582499ba7b28f70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0630bc4eec665fed10bae438834a519ccb23d0a2ea0a85fb889f3115859b3805f6480829c184d0a3cdd813db6b94bbbff7083772dca74b5243693912181bbd8e
|
7
|
+
data.tar.gz: c16d08618c06280e848a535f669f182a145ede5c6f1e1377f13159d33cf352ff49825667b292cbf21fbbef92bd15374f370afddff41bd0f2c144d14ce59bb76e
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
Wed Nov 27 06:40:18 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
|
+
|
3
|
+
* ext/psych/lib/psych/scalar_scanner.rb: fix support for negative
|
4
|
+
years.
|
5
|
+
* ext/psych/lib/psych/visitors/yaml_tree.rb: ditto
|
6
|
+
* test/psych/test_date_time.rb: test for change.
|
7
|
+
Fixes: https://github.com/tenderlove/psych/issues/168
|
8
|
+
|
9
|
+
Wed Nov 27 04:46:55 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
10
|
+
|
11
|
+
* ext/psych/lib/psych/scalar_scanner.rb: fix regexp for matching TIME
|
12
|
+
strings.
|
13
|
+
* test/psych/test_date_time.rb: test for change.
|
14
|
+
Fixes: https://github.com/tenderlove/psych/issues/171
|
15
|
+
|
16
|
+
Wed Nov 6 04:14:25 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
17
|
+
|
18
|
+
* ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before
|
19
|
+
reviving objects. Fixes GH psych #168
|
20
|
+
* test/psych/test_merge_keys.rb: test for change
|
21
|
+
https://github.com/tenderlove/psych/issues/168
|
22
|
+
|
23
|
+
Wed Oct 30 03:25:10 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
24
|
+
|
25
|
+
* ext/psych/lib/psych/visitors/yaml_tree.rb: make less garbage when
|
26
|
+
testing if a string is binary.
|
27
|
+
|
28
|
+
Wed Oct 30 03:08:24 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
29
|
+
|
30
|
+
* ext/psych/lib/psych/visitors/yaml_tree.rb: string subclasses should
|
31
|
+
not be considered to be binary. Fixes Psych / GH 166
|
32
|
+
https://github.com/tenderlove/psych/issues/166
|
33
|
+
|
34
|
+
* test/psych/test_string.rb: test for fix
|
35
|
+
|
36
|
+
Fri Sep 20 23:44:07 2013 Zachary Scott <e@zzak.io>
|
37
|
+
|
38
|
+
* ext/psych/yaml/yaml.h: [DOC] fix typo by @GreenGeorge [Fixes GH-161]
|
39
|
+
https://github.com/tenderlove/psych/pull/161
|
40
|
+
|
1
41
|
Fri Sep 6 02:37:22 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
42
|
|
3
43
|
* ext/psych/lib/psych/visitors/yaml_tree.rb: use double quotes when
|
data/Rakefile
CHANGED
data/ext/psych/yaml/yaml.h
CHANGED
@@ -1851,7 +1851,7 @@ YAML_DECLARE(void)
|
|
1851
1851
|
yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
|
1852
1852
|
|
1853
1853
|
/**
|
1854
|
-
* Set the
|
1854
|
+
* Set the indentation increment.
|
1855
1855
|
*
|
1856
1856
|
* @param[in,out] emitter An emitter object.
|
1857
1857
|
* @param[in] indent The indentation increment (1 < . < 10).
|
data/lib/psych/scalar_scanner.rb
CHANGED
@@ -5,7 +5,7 @@ module Psych
|
|
5
5
|
# Scan scalars for built in types
|
6
6
|
class ScalarScanner
|
7
7
|
# Taken from http://yaml.org/type/timestamp.html
|
8
|
-
TIME =
|
8
|
+
TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
|
9
9
|
|
10
10
|
# Taken from http://yaml.org/type/float.html
|
11
11
|
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
|
@@ -123,7 +123,7 @@ module Psych
|
|
123
123
|
klass = class_loader.load 'Time'
|
124
124
|
|
125
125
|
date, time = *(string.split(/[ tT]/, 2))
|
126
|
-
(yy, m, dd) = date.
|
126
|
+
(yy, m, dd) = date.match(/^(-?\d{4})-(\d{1,2})-(\d{1,2})/).captures.map { |x| x.to_i }
|
127
127
|
md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)
|
128
128
|
|
129
129
|
(hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
|
@@ -156,7 +156,7 @@ module Psych
|
|
156
156
|
if Psych.load_tags[o.tag]
|
157
157
|
return revive(resolve_class(Psych.load_tags[o.tag]), o)
|
158
158
|
end
|
159
|
-
return revive_hash({}, o) unless o.tag
|
159
|
+
return revive_hash(register(o, {}), o) unless o.tag
|
160
160
|
|
161
161
|
case o.tag
|
162
162
|
when /^!ruby\/struct:?(.*)?$/
|
@@ -256,7 +256,7 @@ module Psych
|
|
256
256
|
set
|
257
257
|
|
258
258
|
when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
|
259
|
-
revive_hash resolve_class($1).new, o
|
259
|
+
revive_hash register(o, resolve_class($1).new), o
|
260
260
|
|
261
261
|
when '!omap', 'tag:yaml.org,2002:omap'
|
262
262
|
map = register(o, class_loader.psych_omap.new)
|
@@ -266,7 +266,7 @@ module Psych
|
|
266
266
|
map
|
267
267
|
|
268
268
|
else
|
269
|
-
revive_hash({}, o)
|
269
|
+
revive_hash(register(o, {}), o)
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
@@ -295,8 +295,6 @@ module Psych
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def revive_hash hash, o
|
298
|
-
@st[o.anchor] = hash if o.anchor
|
299
|
-
|
300
298
|
o.children.each_slice(2) { |k,v|
|
301
299
|
key = accept(k)
|
302
300
|
val = accept(v)
|
@@ -334,10 +332,8 @@ module Psych
|
|
334
332
|
end
|
335
333
|
|
336
334
|
def revive klass, node
|
337
|
-
s = klass.allocate
|
338
|
-
|
339
|
-
h = Hash[*node.children.map { |c| accept c }]
|
340
|
-
init_with(s, h, node)
|
335
|
+
s = register(node, klass.allocate)
|
336
|
+
init_with(s, revive_hash({}, node), node)
|
341
337
|
end
|
342
338
|
|
343
339
|
def init_with o, h, node
|
@@ -209,7 +209,11 @@ module Psych
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def visit_DateTime o
|
212
|
-
formatted =
|
212
|
+
formatted = if o.offset.zero?
|
213
|
+
o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
|
214
|
+
else
|
215
|
+
o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
|
216
|
+
end
|
213
217
|
tag = '!ruby/object:DateTime'
|
214
218
|
register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
|
215
219
|
end
|
@@ -264,14 +268,6 @@ module Psych
|
|
264
268
|
@emitter.scalar o._dump, nil, '!ruby/object:BigDecimal', false, false, Nodes::Scalar::ANY
|
265
269
|
end
|
266
270
|
|
267
|
-
def binary? string
|
268
|
-
(string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
|
269
|
-
string.index("\x00") ||
|
270
|
-
string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3 ||
|
271
|
-
string.class != String
|
272
|
-
end
|
273
|
-
private :binary?
|
274
|
-
|
275
271
|
def visit_String o
|
276
272
|
plain = true
|
277
273
|
quote = true
|
@@ -301,6 +297,8 @@ module Psych
|
|
301
297
|
if ivars.empty?
|
302
298
|
unless o.class == ::String
|
303
299
|
tag = "!ruby/string:#{o.class}"
|
300
|
+
plain = false
|
301
|
+
quote = false
|
304
302
|
end
|
305
303
|
@emitter.scalar str, nil, tag, plain, quote, style
|
306
304
|
else
|
@@ -379,6 +377,17 @@ module Psych
|
|
379
377
|
end
|
380
378
|
|
381
379
|
private
|
380
|
+
# FIXME: Remove the index and count checks in Psych 3.0
|
381
|
+
NULL = "\x00"
|
382
|
+
BINARY_RANGE = "\x00-\x7F"
|
383
|
+
WS_RANGE = "^ -~\t\r\n"
|
384
|
+
|
385
|
+
def binary? string
|
386
|
+
(string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
|
387
|
+
string.index(NULL) ||
|
388
|
+
string.count(BINARY_RANGE, WS_RANGE).fdiv(string.length) > 0.3
|
389
|
+
end
|
390
|
+
|
382
391
|
def visit_array_subclass o
|
383
392
|
tag = "!ruby/array:#{o.class}"
|
384
393
|
if o.instance_variables.empty?
|
data/lib/psych.rb
CHANGED
@@ -3,6 +3,19 @@ require 'date'
|
|
3
3
|
|
4
4
|
module Psych
|
5
5
|
class TestDateTime < TestCase
|
6
|
+
def test_negative_year
|
7
|
+
time = Time.utc -1, 12, 16
|
8
|
+
assert_cycle time
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_new_datetime
|
12
|
+
assert_cycle DateTime.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_invalid_date
|
16
|
+
assert_cycle "2013-10-31T10:40:07-000000000000033"
|
17
|
+
end
|
18
|
+
|
6
19
|
def test_string_tag
|
7
20
|
dt = DateTime.now
|
8
21
|
yaml = Psych.dump dt
|
@@ -2,6 +2,24 @@ require_relative 'helper'
|
|
2
2
|
|
3
3
|
module Psych
|
4
4
|
class TestMergeKeys < TestCase
|
5
|
+
class Product
|
6
|
+
attr_reader :bar
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_mergekey_with_object
|
10
|
+
s = <<-eoyml
|
11
|
+
foo: &foo
|
12
|
+
bar: 10
|
13
|
+
product:
|
14
|
+
!ruby/object:#{Product.name}
|
15
|
+
<<: *foo
|
16
|
+
eoyml
|
17
|
+
hash = Psych.load s
|
18
|
+
assert_equal({"bar" => 10}, hash["foo"])
|
19
|
+
product = hash["product"]
|
20
|
+
assert_equal 10, product.bar
|
21
|
+
end
|
22
|
+
|
5
23
|
def test_merge_nil
|
6
24
|
yaml = <<-eoyml
|
7
25
|
defaults: &defaults
|
data/test/psych/test_string.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -182,7 +182,8 @@ files:
|
|
182
182
|
- test/psych/visitors/test_yaml_tree.rb
|
183
183
|
- ".gemtest"
|
184
184
|
homepage: http://github.com/tenderlove/psych
|
185
|
-
licenses:
|
185
|
+
licenses:
|
186
|
+
- MIT
|
186
187
|
metadata: {}
|
187
188
|
post_install_message:
|
188
189
|
rdoc_options:
|