dynarex 0.4.2 → 0.4.3
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/dynarex.rb +14 -0
- metadata +2 -2
data/lib/dynarex.rb
CHANGED
@@ -20,6 +20,10 @@ class Dynarex
|
|
20
20
|
@records
|
21
21
|
end
|
22
22
|
|
23
|
+
def flat_records
|
24
|
+
@flat_records
|
25
|
+
end
|
26
|
+
|
23
27
|
def to_s
|
24
28
|
xsl_buffer =<<EOF
|
25
29
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
@@ -131,6 +135,7 @@ EOF
|
|
131
135
|
|
132
136
|
@summary = summary_to_h
|
133
137
|
@records = records_to_h
|
138
|
+
@flat_records = flat_records_to_h
|
134
139
|
@root_name = @doc.root.name
|
135
140
|
@item_name = XPath.first(@doc.root, 'records/*[1]').name
|
136
141
|
end
|
@@ -139,6 +144,15 @@ EOF
|
|
139
144
|
puts @doc.to_s
|
140
145
|
end
|
141
146
|
|
147
|
+
def flat_records_to_h
|
148
|
+
XPath.match(@doc.root, 'records/*').map do |row|
|
149
|
+
XPath.match(row, '*').inject({}) do |r,node|
|
150
|
+
r[node.name.to_s.to_sym] = node.text.to_s
|
151
|
+
r
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
142
156
|
def records_to_h()
|
143
157
|
i = XPath.match(@doc.root, 'records/*/attribute::id').max_by(&:value).to_s.to_i
|
144
158
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynarex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-05-09 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|