xml_col_finder 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ad99ebebeb440fb2a0229c49d2ab7e993ea086375bb4cf48264b07897e4c9cc
4
- data.tar.gz: f4d6ba7b029cbfff03f147ed4c0da760651f34fa5fca46d675435ed1d78226fd
3
+ metadata.gz: 45d703949948a3a22ed318a5297cf621eecd664e842ac1f654c497018e4b9ec1
4
+ data.tar.gz: f46900d22268f63f35e525bdc70156e0cf9bf68da7faf292facbe682c9094bc8
5
5
  SHA512:
6
- metadata.gz: d7daa28d76d6e6f4d1ffc57041cbd4b24b96352bd10b85fe80d65eaa071e8c7e97e77b0ecb877f89e67445ce93aa138a652175da2509a0e853ff13839bfbb48d
7
- data.tar.gz: c689924e6f815fa8f4398fb54b8142b4d1ad135f391d0c2836b4a93395c8a58e31b70f42ae05bf8c1b977fde6cc3d8a1c041ce29a3c86f0ef400720f6684f212
6
+ metadata.gz: c5da937ee341a1b26a587113633c51912c7f61f7409eebd0197c241860c799c266be394ed247009cbb6158cf4ca5f3de45ed4a46380b49736d25cecf86828f52
7
+ data.tar.gz: 2bfc5dee7af91f61327d71fafe91a73ea0e6060e8953dd193e6a9e1b6f839db9a0d33574cc3bb76f2c42824817e47d135edd866b1fb76108496c50d8ce4f7366
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- \47J8���KE��B+N
2
- ������6�`�����^�5��d}Ȧ�� �>�
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裱�e nOD�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��/0 3�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
@@ -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
- n = 0
52
- while n < a.length
54
+ a.each do |path,txt|
53
55
 
54
- path, txt = a[n]
55
56
  stickypath = ''
56
57
 
57
- path.each do |name|
58
+ n = 0
59
+ while n < path.length
58
60
 
59
- if @debug then
60
- puts "h[+ stickypath + '/' + name]: " \
61
- + h[stickypath + '/' + name].inspect
62
- end
61
+ name = path[n]
63
62
 
64
- if h[stickypath + '/' + name] > 1 then
63
+ if h[stickypath + '/' + name] > 1
65
64
 
66
65
  stickypath += '/' + name
67
- next
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
- h2[stickypath] ||= []
72
- h2[stickypath] << [path.join('/'), txt]
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 |key, value|
104
+ records.map do |record|
99
105
 
100
- new_key = key.sub(/^\/+/,'')[offset..-1]
101
- len = new_key.length
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
- new_value = value.map do |k2, v2|
109
+ truncate_xpath(record, offset)
106
110
 
107
- puts 'k2: ' + k2.inspect if @debug
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
- v2b = v2.is_a?(Array) ? truncate_xpath(v2, offset+len+new_len) : v2
113
+ if record.is_a? String then
114
114
 
115
- [new_k2, v2b]
115
+ value = record
116
+ puts 'valuex: ' + value.inspect if @debug
117
+ value
116
118
 
117
- end
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
- [new_key, new_value]
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.0
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-22 00:00:00.000000000 Z
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