[前][次][番号順一覧][スレッド一覧]

ruby-changes:18605

From: tenderlove <ko1@a...>
Date: Sat, 22 Jan 2011 11:35:10 +0900 (JST)
Subject: [ruby-changes:18605] Ruby:r30629 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: merge keys are actually

tenderlove	2011-01-22 11:34:50 +0900 (Sat, 22 Jan 2011)

  New Revision: 30629

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30629

  Log:
    * 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

  Added files:
    trunk/test/psych/test_merge_keys.rb
  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30628)
+++ ChangeLog	(revision 30629)
@@ -1,3 +1,11 @@
+Sat Jan 22 11:33:04 2011  Aaron Patterson <aaron@t...>
+
+	* 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@t...>
 
 	* ext/psych/parser.c (parse): fixing off-by-one error on line numbers
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 30628)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 30629)
@@ -188,13 +188,7 @@
             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
Index: test/psych/test_merge_keys.rb
===================================================================
--- test/psych/test_merge_keys.rb	(revision 0)
+++ test/psych/test_merge_keys.rb	(revision 30629)
@@ -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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]