diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-01-28 09:38:04 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-01-28 09:38:04 -0800 |
commit | 8cacb47218ff693cbcf69b485b49e6dbe0927a66 (patch) | |
tree | 650b9369de89acf7f4be5d4deb622eab0da817f2 | |
parent | a3f506c1edd0d1c98e75bc055506b419b0eb3a9b (diff) | |
download | psych-8cacb47218ff693cbcf69b485b49e6dbe0927a66.tar.gz |
* ext/psych/lib/psych/visitors/to_ruby.rb: fix parsing hashes withv2.0.12
instance variables when it is referenced multiple times.
* ext/psych/lib/psych.rb: bump version
* ext/psych/psych.gemspec: bump version
* test/psych/test_hash.rb: test for fix
-rw-r--r-- | CHANGELOG.rdoc | 8 | ||||
-rw-r--r-- | lib/psych.rb | 2 | ||||
-rw-r--r-- | lib/psych/visitors/to_ruby.rb | 1 | ||||
-rw-r--r-- | test/psych/test_hash.rb | 7 |
4 files changed, 17 insertions, 1 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 4c04f1a..0172b4b 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,3 +1,11 @@ +Thu Jan 29 02:34:27 2015 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/visitors/to_ruby.rb: fix parsing hashes with + instance variables when it is referenced multiple times. + * ext/psych/lib/psych.rb: bump version + * ext/psych/psych.gemspec: bump version + * test/psych/test_hash.rb: test for fix + Fri Jan 9 07:13:55 2015 Aaron Patterson <aaron@tenderlovemaking.com> * ext/psych/lib/psych/visitors/to_ruby.rb: call `allocate` on hash diff --git a/lib/psych.rb b/lib/psych.rb index 4c80a43..3e9b7aa 100644 --- a/lib/psych.rb +++ b/lib/psych.rb @@ -217,7 +217,7 @@ require 'psych/class_loader' module Psych # The version is Psych you're using - VERSION = '2.0.11' + VERSION = '2.0.12' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb index f353e9c..5bd33b4 100644 --- a/lib/psych/visitors/to_ruby.rb +++ b/lib/psych/visitors/to_ruby.rb @@ -263,6 +263,7 @@ module Psych when /^!ruby\/hash-with-ivars(?::(.*))?$/ hash = $1 ? resolve_class($1).allocate : {} + register o, hash o.children.each_slice(2) do |key, value| case key.value when 'elements' diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index e658984..e2a3129 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -23,6 +23,13 @@ module Psych @hash = { :a => 'b' } end + def test_referenced_hash_with_ivar + a = [1,2,3,4,5] + t1 = [HashWithCustomInit.new(a)] + t1 << t1.first + assert_cycle t1 + end + def test_custom_initialized a = [1,2,3,4,5] t1 = HashWithCustomInit.new(a) |