From 510cde74a6c5c810fb96980ac0d1a9d806d562c3 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Thu, 4 Feb 2010 17:11:00 +0000 Subject: [PATCH] * lib/yaml/rubytypes.rb: Struct members are emitted without a leading colon. Thanks Yusuke Endoh! [ruby-core:28052] * test/yaml/test_struct.rb: fixed tests to go with Struct changes * test/yaml/test_yaml.rb: fixed tests to go with Struct changes git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ lib/yaml/rubytypes.rb | 4 ++-- test/yaml/test_struct.rb | 4 ++-- test/yaml/test_yaml.rb | 26 +++++++++++++------------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0eba7f7229..e888e91f87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Feb 5 02:06:57 2010 Aaron Patterson + + * lib/yaml/rubytypes.rb: Struct members are emitted without a leading + colon. Thanks Yusuke Endoh! [ruby-core:28052] + + * test/yaml/test_struct.rb: fixed tests to go with Struct changes + + * test/yaml/test_yaml.rb: fixed tests to go with Struct changes + Fri Feb 5 00:34:24 2010 Yusuke Endoh * bignum.c (big_gt, big_ge, big_lt, big_ge): added Bignum#>, >=, < and diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index e8c0c89f2c..71f911a738 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -72,7 +72,7 @@ class Struct # st = YAML::object_maker( struct_type, {} ) st.members.each do |m| - st.send( "#{m}=", val[m] ) + st.send( "#{m}=", val[m.to_s] ) end props.each do |k,v| st.instance_variable_set(k, v) @@ -89,7 +89,7 @@ class Struct # out.map( taguri, to_yaml_style ) do |map| self.members.each do |m| - map.add( m, self[m] ) + map.add( m.to_s, self[m.to_s] ) end self.to_yaml_properties.each do |m| map.add( m, instance_variable_get( m ) ) diff --git a/test/yaml/test_struct.rb b/test/yaml/test_struct.rb index c14218e933..b5f944c788 100644 --- a/test/yaml/test_struct.rb +++ b/test/yaml/test_struct.rb @@ -22,8 +22,8 @@ module YAML def test_load obj = YAML.load(<<-eoyml) --- !ruby/struct:StructWithIvar -:foo: bar -:@bar: hello +foo: bar +@bar: hello eoyml assert_equal 'hello', obj.bar diff --git a/test/yaml/test_yaml.rb b/test/yaml/test_yaml.rb index 8c7aef3dcd..7274b602af 100644 --- a/test/yaml/test_yaml.rb +++ b/test/yaml/test_yaml.rb @@ -1082,27 +1082,27 @@ EOY book_struct.new( "This should be the ISBN", "but I have another struct here", 2002, "None" ) ) ], <