xml_col_finder 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -3
- data/lib/xml_col_finder.rb +53 -31
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 45d703949948a3a22ed318a5297cf621eecd664e842ac1f654c497018e4b9ec1
|
4
|
+
data.tar.gz: f46900d22268f63f35e525bdc70156e0cf9bf68da7faf292facbe682c9094bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5da937ee341a1b26a587113633c51912c7f61f7409eebd0197c241860c799c266be394ed247009cbb6158cf4ca5f3de45ed4a46380b49736d25cecf86828f52
|
7
|
+
data.tar.gz: 2bfc5dee7af91f61327d71fafe91a73ea0e6060e8953dd193e6a9e1b6f839db9a0d33574cc3bb76f2c42824817e47d135edd866b1fb76108496c50d8ce4f7366
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
��د3�)"t"k�b������_n���0�"NCH��9�Ɍ3������,�L������(��k��/����$�p�q���,yfZBBC���".���/���Y��5�� k��
|
1
|
+
^}f�{�\�|ؽ$ �X8���,Pz��Ǧ�!�H��W���Og �6��)�1,��|Ԃ�D�B��Sl裱�enOD�o��D|���,�ɶd��M�q��9�S_�$��ah��b�mt�6NR3b҈T)��ӏOCQ%���pHS��$�:�l�C��U*Ư�OT�! n,4��߇�<�)�һ)��~ˇ<Us��O B��ƫ'�`��u ��B��/03�w���8���%=����{�Q����
|
2
|
+
f�G�U��:R�x�qA�^q ��gP��)&�:��b�L�Q����0��"=cYݐ]v��biwS���ظ�:�e�-�s�Z� ���5w�s1�SV������̥х�Z�4ۯ�Ͱ�L
|
data/lib/xml_col_finder.rb
CHANGED
@@ -24,11 +24,14 @@ class XMLColFinder
|
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
+
#@to_a = a
|
27
28
|
h = group_by_xpath(a)
|
28
29
|
@to_a = truncate_xpath(h).flatten(1)
|
29
30
|
|
30
31
|
end
|
31
32
|
|
33
|
+
private
|
34
|
+
|
32
35
|
# Groups xpath by matching branches
|
33
36
|
#
|
34
37
|
def group_by_xpath(a)
|
@@ -48,39 +51,41 @@ class XMLColFinder
|
|
48
51
|
|
49
52
|
h2 = {}
|
50
53
|
|
51
|
-
|
52
|
-
while n < a.length
|
54
|
+
a.each do |path,txt|
|
53
55
|
|
54
|
-
path, txt = a[n]
|
55
56
|
stickypath = ''
|
56
57
|
|
57
|
-
|
58
|
+
n = 0
|
59
|
+
while n < path.length
|
58
60
|
|
59
|
-
|
60
|
-
puts "h[+ stickypath + '/' + name]: " \
|
61
|
-
+ h[stickypath + '/' + name].inspect
|
62
|
-
end
|
61
|
+
name = path[n]
|
63
62
|
|
64
|
-
if h[stickypath + '/' + name] > 1
|
63
|
+
if h[stickypath + '/' + name] > 1
|
65
64
|
|
66
65
|
stickypath += '/' + name
|
67
|
-
|
66
|
+
|
67
|
+
if (n == path.length - 1) then
|
68
|
+
|
69
|
+
h2[stickypath.sub(/^\//,'')] ||= []
|
70
|
+
h2[stickypath.sub(/^\//,'')] << txt
|
71
|
+
|
72
|
+
end
|
68
73
|
|
69
74
|
else
|
70
75
|
|
71
|
-
|
72
|
-
|
76
|
+
puts "path.join('/'): " + path.join('/').inspect
|
77
|
+
puts 'txt:' + txt.inspect
|
78
|
+
|
79
|
+
h2[stickypath.sub(/^\//,'')] ||= []
|
80
|
+
h2[stickypath.sub(/^\//,'')] << [path.join('/'), txt]
|
73
81
|
break
|
74
82
|
|
75
83
|
end
|
76
|
-
|
84
|
+
n += 1
|
77
85
|
end
|
78
86
|
|
79
|
-
n += 1
|
80
|
-
|
81
87
|
end
|
82
88
|
|
83
|
-
|
84
89
|
if h2.length > 1 then
|
85
90
|
|
86
91
|
a2 = h2.map {|k,v| [k.split('/'), v]}
|
@@ -91,32 +96,49 @@ class XMLColFinder
|
|
91
96
|
return h2
|
92
97
|
|
93
98
|
end
|
99
|
+
|
94
100
|
end
|
95
101
|
|
96
102
|
def truncate_xpath(records, offset=0)
|
97
103
|
|
98
|
-
records.map do |
|
104
|
+
records.map do |record|
|
99
105
|
|
100
|
-
|
101
|
-
|
102
|
-
#puts len.inspect
|
103
|
-
puts 'new_key: ' + new_key.inspect if @debug
|
106
|
+
next unless record
|
107
|
+
if record.is_a? Array and (record[0].is_a? Array or record.length > 2) then
|
104
108
|
|
105
|
-
|
109
|
+
truncate_xpath(record, offset)
|
106
110
|
|
107
|
-
|
108
|
-
new_k2 = k2.sub(/^\/+/,'')[offset+len..-1]
|
109
|
-
new_len = new_k2.length
|
110
|
-
puts 'new_k2: ' + new_k2.inspect if @debug
|
111
|
-
puts 'v2: ' + v2.inspect if @debug
|
111
|
+
else
|
112
112
|
|
113
|
-
|
113
|
+
if record.is_a? String then
|
114
114
|
|
115
|
-
|
115
|
+
value = record
|
116
|
+
puts 'valuex: ' + value.inspect if @debug
|
117
|
+
value
|
116
118
|
|
117
|
-
|
119
|
+
else
|
120
|
+
|
121
|
+
key, value = record
|
122
|
+
puts 'key: ' + key.inspect if @debug
|
123
|
+
|
124
|
+
new_key = key[offset..-1]
|
125
|
+
puts 'new_key: ' + new_key.inspect if @debug
|
126
|
+
|
127
|
+
next unless new_key
|
128
|
+
len = new_key.length
|
129
|
+
|
130
|
+
if value.is_a? Array then
|
118
131
|
|
119
|
-
|
132
|
+
[new_key, truncate_xpath(value, offset+len)]
|
133
|
+
|
134
|
+
else
|
135
|
+
|
136
|
+
puts 'value: ' + value.inspect if @debug
|
137
|
+
[new_key, value]
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
120
142
|
|
121
143
|
end
|
122
144
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xml_col_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
GSlZ9ilAfm8srTjbZ2cWQyNGGxH+zHQ3Z02c4ZEtgPv/wHjptd1VeBm0P1aemsRA
|
36
36
|
ShsxXxzmzIrRENmpBp3tyR3k
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-01-
|
38
|
+
date: 2022-01-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rexle
|
metadata.gz.sig
CHANGED
Binary file
|