* 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
This commit is contained in:
parent
f6b75e30d8
commit
510cde74a6
@ -1,3 +1,12 @@
|
|||||||
|
Fri Feb 5 02:06:57 2010 Aaron Patterson <tenderlove@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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 <mame@tsg.ne.jp>
|
Fri Feb 5 00:34:24 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* bignum.c (big_gt, big_ge, big_lt, big_ge): added Bignum#>, >=, < and
|
* bignum.c (big_gt, big_ge, big_lt, big_ge): added Bignum#>, >=, < and
|
||||||
|
@ -72,7 +72,7 @@ class Struct
|
|||||||
#
|
#
|
||||||
st = YAML::object_maker( struct_type, {} )
|
st = YAML::object_maker( struct_type, {} )
|
||||||
st.members.each do |m|
|
st.members.each do |m|
|
||||||
st.send( "#{m}=", val[m] )
|
st.send( "#{m}=", val[m.to_s] )
|
||||||
end
|
end
|
||||||
props.each do |k,v|
|
props.each do |k,v|
|
||||||
st.instance_variable_set(k, v)
|
st.instance_variable_set(k, v)
|
||||||
@ -89,7 +89,7 @@ class Struct
|
|||||||
#
|
#
|
||||||
out.map( taguri, to_yaml_style ) do |map|
|
out.map( taguri, to_yaml_style ) do |map|
|
||||||
self.members.each do |m|
|
self.members.each do |m|
|
||||||
map.add( m, self[m] )
|
map.add( m.to_s, self[m.to_s] )
|
||||||
end
|
end
|
||||||
self.to_yaml_properties.each do |m|
|
self.to_yaml_properties.each do |m|
|
||||||
map.add( m, instance_variable_get( m ) )
|
map.add( m, instance_variable_get( m ) )
|
||||||
|
@ -22,8 +22,8 @@ module YAML
|
|||||||
def test_load
|
def test_load
|
||||||
obj = YAML.load(<<-eoyml)
|
obj = YAML.load(<<-eoyml)
|
||||||
--- !ruby/struct:StructWithIvar
|
--- !ruby/struct:StructWithIvar
|
||||||
:foo: bar
|
foo: bar
|
||||||
:@bar: hello
|
@bar: hello
|
||||||
eoyml
|
eoyml
|
||||||
|
|
||||||
assert_equal 'hello', obj.bar
|
assert_equal 'hello', obj.bar
|
||||||
|
@ -1082,27 +1082,27 @@ EOY
|
|||||||
book_struct.new( "This should be the ISBN", "but I have another struct here", 2002, "None" )
|
book_struct.new( "This should be the ISBN", "but I have another struct here", 2002, "None" )
|
||||||
) ], <<EOY
|
) ], <<EOY
|
||||||
- !ruby/struct:BookStruct
|
- !ruby/struct:BookStruct
|
||||||
:author: Yukihiro Matsumoto
|
author: Yukihiro Matsumoto
|
||||||
:title: Ruby in a Nutshell
|
title: Ruby in a Nutshell
|
||||||
:year: 2002
|
year: 2002
|
||||||
:isbn: 0-596-00214-9
|
isbn: 0-596-00214-9
|
||||||
- !ruby/struct:BookStruct
|
- !ruby/struct:BookStruct
|
||||||
:author:
|
author:
|
||||||
- Dave Thomas
|
- Dave Thomas
|
||||||
- Andy Hunt
|
- Andy Hunt
|
||||||
:title: The Pickaxe
|
title: The Pickaxe
|
||||||
:year: 2002
|
year: 2002
|
||||||
:isbn: !ruby/struct:BookStruct
|
isbn: !ruby/struct:BookStruct
|
||||||
:author: This should be the ISBN
|
author: This should be the ISBN
|
||||||
:title: but I have another struct here
|
title: but I have another struct here
|
||||||
:year: 2002
|
year: 2002
|
||||||
:isbn: None
|
isbn: None
|
||||||
EOY
|
EOY
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_to_yaml( YAML_Tests::StructTest.new( 123 ), <<EOY )
|
assert_to_yaml( YAML_Tests::StructTest.new( 123 ), <<EOY )
|
||||||
--- !ruby/struct:YAML_Tests::StructTest
|
--- !ruby/struct:YAML_Tests::StructTest
|
||||||
:c: 123
|
c: 123
|
||||||
EOY
|
EOY
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user