зеркало из https://github.com/github/ruby.git
* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7b876e65ed
Коммит
5b1c06c74b
|
@ -1,3 +1,11 @@
|
|||
Sat Jan 22 11:33:04 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* 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 <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/parser.c (parse): fixing off-by-one error on line numbers
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Загрузка…
Ссылка в новой задаче