aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-05 18:41:46 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-05 18:41:46 +0000
commit0b392535df8ef68c969a2900e146d8b91f020706 (patch)
tree06bf621edbd8509b75ddfea3319a482f4ab1c05d
parent9670542af57f632460519add916f8e1fd43df5a8 (diff)
downloadruby-0b392535df8ef68c969a2900e146d8b91f020706.tar.gz
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb2
-rw-r--r--test/psych/test_hash.rb5
3 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dd84e307a4..bfda8be1af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Aug 6 03:41:21 2014 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_invoke): skip VariantClear when
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 2f84b100d2..234cabc7f9 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -201,6 +201,8 @@ module Psych
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
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index dac7f8d7d8..264a4719e2 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -10,6 +10,11 @@ module Psych
@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