xml_col_finder 0.2.1 → 0.2.2

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: fb9968f62dfa167170d225305499a06a3fb07949d22b44cfc5fc7aaff2250e70
4
- data.tar.gz: 590549966bf32070036e68f45ff1c61cc5b81b7c11a5237466928e573758eeb5
3
+ metadata.gz: b98fdd5a28880c8560256ae8a01f5e0a64a3067f2c0974f5c0e668243ce7ad92
4
+ data.tar.gz: c1177f458579fb3fd7a9d975512d14f5b0e2395ea4cbaa21dc40253b564b78f3
5
5
  SHA512:
6
- metadata.gz: a022f1836170e5628062360a2bef7d4fc26ac1748dd7970fd56eb76ca5fa194f2f61b75bf7f8dfe667191ef194aeb2306a8c5e94e55552aafa105e0d34a7828b
7
- data.tar.gz: 2f932bcffe0ace2bfc4fdefb3df0fde1cff61e3095110fb765de6732c096c44066e13046591c8423bb75465e9b981774751c225b9791a72601bac97bb24237a5
6
+ metadata.gz: 73daefd3b3bb3873e21848aad39fd7d9bb570229c8369bb71920bce81474d312b6eb83a9647cf03d66bc4b095788a72dee9925a68d8de8e78554f82155afbdea
7
+ data.tar.gz: be011c43afe08767e860c436024c65d8b86e507f610ffd7caad367f034cd76dfbfaf5c39882eef9ee6524cc2f90d1de9c564db297f4899df01f3e40e42840885
checksums.yaml.gz.sig CHANGED
Binary file
@@ -30,8 +30,9 @@ class XMLColFinder
30
30
 
31
31
  end
32
32
 
33
- def to_code()
33
+ def to_code(nametip: true)
34
34
 
35
+ @nametip = nametip
35
36
  @tags = {}
36
37
 
37
38
  xpath, remaining = @to_a
@@ -40,7 +41,9 @@ class XMLColFinder
40
41
  linex = formatline('doc', eid, xpath)
41
42
  a = scan(remaining, eid)
42
43
 
43
- a.flatten.compact.prepend linex
44
+ lines = a.flatten.compact.prepend linex
45
+ lines.join("\n").lines\
46
+ .map {|line| line =~ /.text$/ ? 'puts ' + line : line }.join
44
47
 
45
48
  end
46
49
 
@@ -49,8 +52,24 @@ class XMLColFinder
49
52
  def formatline(pid, eid=nil, key=nil, tail=nil, index: nil)
50
53
 
51
54
  if eid then
52
- line = "%s = %s.element(\"%s\")" % [eid, pid, key]
53
- line += '.text' if tail.is_a? String
55
+
56
+ nametip = @nametip && tail.is_a?(String)
57
+ klass = nametip ? key.scan(/@class=['"]([^'"]+)/).last : nil
58
+
59
+ line = if klass then
60
+ desc = klass[0][/^[^\-]+/].gsub(/(?=[A-Z])/,' ').downcase
61
+ desc += " (e.g. %s)" % [tail.length < 50 ? tail : tail[0..46] + '...']
62
+ "\n# " + desc + "\n"
63
+ else
64
+ ''
65
+ end
66
+
67
+ line += "%s = %s.element(\"%s\")" % [eid, pid, key]
68
+ if tail.is_a? String
69
+ line += '.text'
70
+ #line += "\n" if nametip
71
+ end
72
+
54
73
  else
55
74
  line = index ? ("%s[%d].text" % [pid, index]) : ("%s.text" % pid)
56
75
  end
@@ -191,7 +210,7 @@ class XMLColFinder
191
210
  puts '_tail: ' + tail.inspect if @debug
192
211
  tline = tail.map.with_index do |x,i|
193
212
  formatline(pid=eid, index: i)
194
- end.join("\n")
213
+ end
195
214
 
196
215
  end
197
216
  end
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.2.1
4
+ version: 0.2.2
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-23 00:00:00.000000000 Z
38
+ date: 2022-01-24 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
metadata.gz.sig CHANGED
Binary file