oxm 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +3 -0
- data/VERSION +1 -1
- data/lib/oxm/object.rb +4 -10
- data/lib/oxm/sax_handler.rb +10 -2
- data/test/test_oxm.rb +19 -0
- metadata +13 -13
data/CHANGELOG.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/oxm/object.rb
CHANGED
@@ -12,14 +12,14 @@ module OXM
|
|
12
12
|
# @return [String]
|
13
13
|
def content= val
|
14
14
|
@cdata = false
|
15
|
-
|
15
|
+
@data = val
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param [String] val CDATA content
|
19
19
|
# @return [String]
|
20
20
|
def cdata= val
|
21
21
|
@cdata = true
|
22
|
-
|
22
|
+
@data = val
|
23
23
|
end
|
24
24
|
|
25
25
|
# @return [Boolean]
|
@@ -43,9 +43,9 @@ module OXM
|
|
43
43
|
end
|
44
44
|
if node.content
|
45
45
|
if node.cdata?
|
46
|
-
builder.cdata! node.
|
46
|
+
builder.cdata! node.to_s
|
47
47
|
else
|
48
|
-
builder.text! node.
|
48
|
+
builder.text! node.to_s
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -143,12 +143,6 @@ module OXM
|
|
143
143
|
raise NoMethodError.new("undefined method or attribute `#{symb}'")
|
144
144
|
end
|
145
145
|
end
|
146
|
-
|
147
|
-
def process str
|
148
|
-
str = str.to_s.strip
|
149
|
-
@data = str
|
150
|
-
end
|
151
|
-
|
152
146
|
end#Object
|
153
147
|
end#OXM
|
154
148
|
|
data/lib/oxm/sax_handler.rb
CHANGED
@@ -34,8 +34,17 @@ module OXM
|
|
34
34
|
|
35
35
|
def end_element tag
|
36
36
|
unless @objects.empty?
|
37
|
+
obj = @objects.pop
|
38
|
+
|
39
|
+
# Strip content
|
40
|
+
if obj.cdata?
|
41
|
+
obj.cdata = obj.to_s.strip
|
42
|
+
else
|
43
|
+
obj.content = obj.to_s.strip
|
44
|
+
end
|
45
|
+
obj.content = nil if obj.to_s.empty?
|
46
|
+
|
37
47
|
if match?
|
38
|
-
obj = @objects.pop
|
39
48
|
if @block
|
40
49
|
@block.call obj
|
41
50
|
else
|
@@ -43,7 +52,6 @@ module OXM
|
|
43
52
|
end
|
44
53
|
@object = nil
|
45
54
|
else
|
46
|
-
@objects.pop
|
47
55
|
@object = @objects.last
|
48
56
|
end
|
49
57
|
end
|
data/test/test_oxm.rb
CHANGED
@@ -109,6 +109,25 @@ class TestOxm < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
def test_nil
|
113
|
+
str = <<-EOF
|
114
|
+
<container>
|
115
|
+
<item></item>
|
116
|
+
<item> </item>
|
117
|
+
<item>
|
118
|
+
</item>
|
119
|
+
<item>
|
120
|
+
|
121
|
+
</item>
|
122
|
+
</container>
|
123
|
+
EOF
|
124
|
+
|
125
|
+
OXM.from_xml(str, 'container/item') do |item|
|
126
|
+
assert_nil item.content
|
127
|
+
assert_equal "<item></item>", item.to_xml
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
112
131
|
def test_compaction
|
113
132
|
str = <<-EOF
|
114
133
|
<container attr1="1" attr2="2">
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oxm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152490720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152490720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152489620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.5.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152489620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152488420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152488420
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152485060 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152485060
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152483840 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152483840
|
69
69
|
description: A tiny Object-XML-Mapper using Nokogiri SAX parser
|
70
70
|
email: junegunn.c@gmail.com
|
71
71
|
executables: []
|
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash:
|
105
|
+
hash: 3232406390729243010
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|