Skip to content

Commit

Permalink
* ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
tenderlove committed Aug 29, 2014
1 parent 3edca57 commit 3b4e354
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
Sat Aug 30 06:10:39 2014 Aaron Patterson <aaron@tenderlovemaking.com>

* 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 #202

Sat Aug 30 06:00:26 2014 Aaron Patterson <aaron@tenderlovemaking.com>

* ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings
Expand Down
2 changes: 1 addition & 1 deletion ext/psych/lib/psych/visitors/to_ruby.rb
Expand Up @@ -307,7 +307,7 @@ def revive_hash hash, o

if key == '<<' && k.tag != "tag:yaml.org,2002:str"
case v
when Nodes::Alias
when Nodes::Alias, Nodes::Mapping
begin
hash.merge! val
rescue TypeError
Expand Down
10 changes: 10 additions & 0 deletions test/psych/test_merge_keys.rb
Expand Up @@ -6,6 +6,16 @@ class Product
attr_reader :bar
end

def test_merge_key_with_bare_hash
doc = Psych.load <<-eodoc
map:
<<:
hello: world
eodoc
hash = { "map" => { "hello" => "world" } }
assert_equal hash, doc
end

def test_roundtrip_with_chevron_key
h = {}
v = { 'a' => h, '<<' => h }
Expand Down

0 comments on commit 3b4e354

Please sign in to comment.