ya2yaml 0.25 → 0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ya2yaml.rb +2 -2
- data/test/test.rb +11 -1
- metadata +2 -2
data/lib/ya2yaml.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# $Id: ya2yaml.rb,v 0.
|
3
|
+
# $Id: ya2yaml.rb,v 0.26 2007-01-19 20:42:42+09 funai Exp funai $
|
4
4
|
#
|
5
5
|
# Author:: Akira FUNAI
|
6
6
|
# Copyright:: Copyright (c) 2006 Akira FUNAI
|
@@ -99,7 +99,7 @@ class Ya2YAML
|
|
99
99
|
when obj.is_a?(Struct)
|
100
100
|
struct_members = {}
|
101
101
|
obj.each_pair{|k,v| struct_members[k.to_s] = v }
|
102
|
-
'!ruby/struct:' + obj.class.to_s.sub(/^Struct
|
102
|
+
'!ruby/struct:' + obj.class.to_s.sub(/^(Struct::(.+)|.*)$/,'\2') + ' ' +
|
103
103
|
emit(struct_members,level + 1)
|
104
104
|
else
|
105
105
|
# serialized as a generic object
|
data/test/test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# $Id: test.rb,v 1.
|
3
|
+
# $Id: test.rb,v 1.4 2007-01-19 20:41:37+09 funai Exp funai $
|
4
4
|
|
5
5
|
$: << (File.dirname(__FILE__) + '/../lib')
|
6
6
|
|
@@ -134,6 +134,16 @@ class TC_Ya2YAML < Test::Unit::TestCase
|
|
134
134
|
}
|
135
135
|
end
|
136
136
|
|
137
|
+
def test_structs
|
138
|
+
[
|
139
|
+
[Struct.new('Hoge',:foo).new(123),"--- !ruby/struct:Hoge \n foo: 123\n",],
|
140
|
+
[Struct.new(:foo).new(123), "--- !ruby/struct: \n foo: 123\n",],
|
141
|
+
].each {|src,yaml|
|
142
|
+
y = src.ya2yaml()
|
143
|
+
assert_equal(y,yaml)
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
137
147
|
def test_roundtrip_single_byte_char
|
138
148
|
("\x00".."\x7f").each {|c|
|
139
149
|
y = c.ya2yaml()
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ya2yaml
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-01-
|
6
|
+
version: "0.26"
|
7
|
+
date: 2007-01-19 00:00:00 +09:00
|
8
8
|
summary: An UTF8 safe YAML dumper.
|
9
9
|
require_paths:
|
10
10
|
- lib
|