diff --git a/ChangeLog b/ChangeLog index fd5b181d6a..35085cdd47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Jan 22 11:33:04 2011 Aaron Patterson + + * ext/psych/lib/psych/visitors/to_ruby.rb: merge keys are actually + part of YAML 1.1, so they should be supported. Remove warning and + merge keys to parent. [ruby-core:34679] + + * test/psych/test_merge_keys.rb: test for merge keys + Sat Jan 22 11:21:40 2011 Aaron Patterson * ext/psych/parser.c (parse): fixing off-by-one error on line numbers diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index 745338ad99..b5bec54af5 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -188,13 +188,7 @@ module Psych key = accept(k) if key == '<<' && Nodes::Alias === v - # FIXME: remove this when "<<" syntax is deprecated - if $VERBOSE - where = caller.find { |x| x !~ /psych/ } - warn where - warn "\"<<: *#{v.anchor}\" is no longer supported, please switch to \"*#{v.anchor}\"" - end - return accept(v) + hash.merge! accept(v) else hash[key] = accept(v) end diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb new file mode 100644 index 0000000000..9aadcc85e5 --- /dev/null +++ b/test/psych/test_merge_keys.rb @@ -0,0 +1,21 @@ +require_relative 'helper' + +module Psych + class TestMergeKeys < TestCase + # [ruby-core:34679] + def test_merge_key + yaml = <<-eoyml +foo: &foo + hello: world +bar: + << : *foo + baz: boo + eoyml + + hash = { + "foo" => { "hello" => "world"}, + "bar" => { "hello" => "world", "baz" => "boo" } } + assert_equal hash, Psych.load(yaml) + end + end +end