xml_col_finder 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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -3
- data/lib/xml_col_finder.rb +28 -6
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb9968f62dfa167170d225305499a06a3fb07949d22b44cfc5fc7aaff2250e70
|
4
|
+
data.tar.gz: 590549966bf32070036e68f45ff1c61cc5b81b7c11a5237466928e573758eeb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a022f1836170e5628062360a2bef7d4fc26ac1748dd7970fd56eb76ca5fa194f2f61b75bf7f8dfe667191ef194aeb2306a8c5e94e55552aafa105e0d34a7828b
|
7
|
+
data.tar.gz: 2f932bcffe0ace2bfc4fdefb3df0fde1cff61e3095110fb765de6732c096c44066e13046591c8423bb75465e9b981774751c225b9791a72601bac97bb24237a5
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
���u�;����a�v[):����C��ujnz���d���D{9�FX�9�d��lgN��j?@�
|
1
|
+
T�V�c.nf���}�"Ny�S�dVA$�t/�n����F��*�2ay�.�7��"�L�B�ϊ#[����|��R�iQ��L�2���~�T�u��N�6r]�u[��$�4�"����ے��i���jxe8W*%rT�!mf��\�QӪ�+i5�3G�*t�*�ԡ9�;�u��:�u����Aj�IG�8���U*����i�9*��rΥ����d�JG��,
|
2
|
+
�d����D�n��F�*
|
data/lib/xml_col_finder.rb
CHANGED
@@ -33,6 +33,7 @@ class XMLColFinder
|
|
33
33
|
def to_code()
|
34
34
|
|
35
35
|
@tags = {}
|
36
|
+
|
36
37
|
xpath, remaining = @to_a
|
37
38
|
|
38
39
|
eid = getid(xpath)
|
@@ -45,13 +46,13 @@ class XMLColFinder
|
|
45
46
|
|
46
47
|
private
|
47
48
|
|
48
|
-
def formatline(pid, eid=nil, key=nil, tail=nil)
|
49
|
+
def formatline(pid, eid=nil, key=nil, tail=nil, index: nil)
|
49
50
|
|
50
51
|
if eid then
|
51
52
|
line = "%s = %s.element(\"%s\")" % [eid, pid, key]
|
52
53
|
line += '.text' if tail.is_a? String
|
53
54
|
else
|
54
|
-
line = "%s.text" % pid
|
55
|
+
line = index ? ("%s[%d].text" % [pid, index]) : ("%s.text" % pid)
|
55
56
|
end
|
56
57
|
|
57
58
|
return line
|
@@ -119,8 +120,6 @@ class XMLColFinder
|
|
119
120
|
|
120
121
|
else
|
121
122
|
|
122
|
-
puts "path.join('/'): " + path.join('/').inspect
|
123
|
-
puts 'txt:' + txt.inspect
|
124
123
|
|
125
124
|
h2[stickypath.sub(/^\//,'')] ||= []
|
126
125
|
h2[stickypath.sub(/^\//,'')] << [path.join('/'), txt]
|
@@ -147,6 +146,8 @@ class XMLColFinder
|
|
147
146
|
|
148
147
|
def scan(a, eid='doc', pid=eid.clone)
|
149
148
|
|
149
|
+
#puts 'a: ' + a.inspect if @debug
|
150
|
+
|
150
151
|
a.map do |row|
|
151
152
|
|
152
153
|
head, tail = row
|
@@ -160,9 +161,17 @@ class XMLColFinder
|
|
160
161
|
if head[0] == '/' then
|
161
162
|
|
162
163
|
key = head[1..-1]
|
164
|
+
puts 'key: ' + key.inspect if @debug
|
163
165
|
|
164
166
|
eid = getid(key)
|
165
|
-
|
167
|
+
|
168
|
+
hline = if tail.is_a? Array and tail.all? {|x| x.is_a? String } then
|
169
|
+
@prev_xpath = true
|
170
|
+
"%s = %s.xpath(\"%s\")" % [eid, pid, key]
|
171
|
+
else
|
172
|
+
@prev_xpath = false
|
173
|
+
formatline(pid, eid, key, tail)
|
174
|
+
end
|
166
175
|
|
167
176
|
else
|
168
177
|
|
@@ -171,7 +180,20 @@ class XMLColFinder
|
|
171
180
|
end
|
172
181
|
|
173
182
|
if tail.is_a? Array then
|
174
|
-
|
183
|
+
|
184
|
+
if tail.compact[0].is_a? Array then
|
185
|
+
|
186
|
+
puts 'tail: ' + tail.inspect if @debug
|
187
|
+
|
188
|
+
tline = scan(tail, eid)
|
189
|
+
|
190
|
+
elsif tail.all? {|x| x.is_a? String} and tail[0][0] != '/'
|
191
|
+
puts '_tail: ' + tail.inspect if @debug
|
192
|
+
tline = tail.map.with_index do |x,i|
|
193
|
+
formatline(pid=eid, index: i)
|
194
|
+
end.join("\n")
|
195
|
+
|
196
|
+
end
|
175
197
|
end
|
176
198
|
|
177
199
|
[hline, tline]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|