oxmlk 0.2.0 → 0.2.1
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/VERSION +1 -1
- data/lib/oxmlk/description.rb +4 -9
- data/lib/oxmlk/xml.rb +2 -0
- data/oxmlk.gemspec +1 -1
- data/spec/xml_spec.rb +10 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/oxmlk/description.rb
CHANGED
@@ -2,14 +2,9 @@ module OxMlk
|
|
2
2
|
|
3
3
|
class Description
|
4
4
|
PROCESSORS = {
|
5
|
-
:
|
6
|
-
|
7
|
-
|
8
|
-
Float => proc {|x| x.content.to_f rescue nil}
|
9
|
-
},
|
10
|
-
:attribute => {
|
11
|
-
:value => proc {|x| x.value rescue nil}
|
12
|
-
}
|
5
|
+
:value => proc {|x| x.value rescue nil},
|
6
|
+
Integer => proc {|x| x.value.to_i rescue nil},
|
7
|
+
Float => proc {|x| x.value.to_f rescue nil}
|
13
8
|
}
|
14
9
|
|
15
10
|
attr_reader :xpath
|
@@ -139,7 +134,7 @@ module OxMlk
|
|
139
134
|
def coputed_processor
|
140
135
|
return proc {|x| Hash[*@as.map{|o| [o.ox_tag,o]}.flatten][x.name].from_xml(x) } if collection? && ox_object?
|
141
136
|
processor = [*@as].first || :value
|
142
|
-
PROCESSORS[
|
137
|
+
PROCESSORS[processor] || processor
|
143
138
|
end
|
144
139
|
|
145
140
|
def wrap(xpath=nil)
|
data/lib/oxmlk/xml.rb
CHANGED
data/oxmlk.gemspec
CHANGED
data/spec/xml_spec.rb
CHANGED
@@ -61,4 +61,14 @@ describe OxMlk::XML::Node, '#build' do
|
|
61
61
|
it 'should set its attributes to the third argument' do
|
62
62
|
@node.build(*@args).should be_attributes
|
63
63
|
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe OxMlk::XML::Node, '#value' do
|
67
|
+
before(:all) do
|
68
|
+
@node = OxMlk::XML::Node.new('test')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should be the same as content' do
|
72
|
+
@node.value.should == @node.content
|
73
|
+
end
|
64
74
|
end
|