Skip to content

Commit 3b4e354

Browse files
committed
* ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash
should merge the hash in to the parent. * test/psych/test_merge_keys.rb: test for change. Fixes GH ruby#202 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 3edca57 commit 3b4e354

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat Aug 30 06:10:39 2014 Aaron Patterson <aaron@tenderlovemaking.com>
2+
3+
* ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash
4+
should merge the hash in to the parent.
5+
* test/psych/test_merge_keys.rb: test for change. Fixes GH #202
6+
17
Sat Aug 30 06:00:26 2014 Aaron Patterson <aaron@tenderlovemaking.com>
28

39
* ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings

ext/psych/lib/psych/visitors/to_ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def revive_hash hash, o
307307

308308
if key == '<<' && k.tag != "tag:yaml.org,2002:str"
309309
case v
310-
when Nodes::Alias
310+
when Nodes::Alias, Nodes::Mapping
311311
begin
312312
hash.merge! val
313313
rescue TypeError

test/psych/test_merge_keys.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ class Product
66
attr_reader :bar
77
end
88

9+
def test_merge_key_with_bare_hash
10+
doc = Psych.load <<-eodoc
11+
map:
12+
<<:
13+
hello: world
14+
eodoc
15+
hash = { "map" => { "hello" => "world" } }
16+
assert_equal hash, doc
17+
end
18+
919
def test_roundtrip_with_chevron_key
1020
h = {}
1121
v = { 'a' => h, '<<' => h }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy