summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb2
-rw-r--r--test/psych/test_merge_keys.rb10
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 99f8c92..29aa26f 100644
--- a/ChangeLog
+++ b/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
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 984bc84..e74d5d4 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -307,7 +307,7 @@ module Psych
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
diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb
index 8b263e5..1620a6a 100644
--- a/test/psych/test_merge_keys.rb
+++ b/test/psych/test_merge_keys.rb
@@ -6,6 +6,16 @@ module Psych
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 }