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

ruby-changes:34987

From: tenderlove <ko1@a...>
Date: Wed, 6 Aug 2014 03:42:03 +0900 (JST)
Subject: [ruby-changes:34987] tenderlove:r47069 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for

tenderlove	2014-08-06 03:41:46 +0900 (Wed, 06 Aug 2014)

  New Revision: 47069

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

  Log:
    * ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
      hashes emitted by Syck. Github #198
    * test/psych/test_hash.rb: test for change.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb
    trunk/test/psych/test_hash.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47068)
+++ ChangeLog	(revision 47069)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Aug  6 03:41:21 2014  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
+	  hashes emitted by Syck. Github #198
+	* test/psych/test_hash.rb: test for change.
+
 Tue Aug  5 19:27:59 2014  Masaki Suketa <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c (ole_invoke): skip VariantClear when
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 47068)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 47069)
@@ -201,6 +201,8 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L201
             class_loader.rational
             h = Hash[*o.children.map { |c| accept c }]
             register o, Rational(h['numerator'], h['denominator'])
+          elsif name == 'Hash'
+            revive_hash(register(o, {}), o)
           else
             obj = revive((resolve_class(name) || class_loader.object), o)
             obj
Index: test/psych/test_hash.rb
===================================================================
--- test/psych/test_hash.rb	(revision 47068)
+++ test/psych/test_hash.rb	(revision 47069)
@@ -10,6 +10,11 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_hash.rb#L10
       @hash = { :a => 'b' }
     end
 
+    def test_load_with_class_syck_compatibility
+      hash = Psych.load "--- !ruby/object:Hash\n:user_id: 7\n:username: Lucas\n"
+      assert_equal({ user_id: 7, username: 'Lucas'}, hash)
+    end
+
     def test_empty_subclass
       assert_match "!ruby/hash:#{X}", Psych.dump(X.new)
       x = Psych.load Psych.dump X.new

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

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