sectionx 0.4.4 → 0.4.5

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: eeb59887f6e890a97b343d84531c55a534bed6fa8f56cbe4f0b32f905aac1d46
4
- data.tar.gz: fbec4ce7de357eaeedf2923a20e9d0cd8a1400cd14869014714ea988212de433
3
+ metadata.gz: 89e31eed251bc885befe0c29dc999ee79a97771f2c33b77590bd0b4d5a7ba290
4
+ data.tar.gz: 2c8ee33252810ec3b8d5be68a0ad85c98ce3a7063b47e0db2cbc13a5be7fc3f1
5
5
  SHA512:
6
- metadata.gz: a327cf2d5afbbcc59d653bd6bcde531b8cfdf62b4bc7ba3eb89526cb0487b0703a64fe8f83a4fc5f4e9b24e8f9ba56c366b6e75641b1a03abced96277eeaec3f
7
- data.tar.gz: 11cd4e1d35c48e61e05afbc70d3841ca43fb70c84e25245f8f8e67b55e02967f6457859e6f437ff6ce277fa194b4a25f5d973aa88f06d5e81e2f74aee7236aeb
6
+ metadata.gz: 16ba5fc4acb7128bc24f756c66a2d79044fec8eb0610b8241e1b40d92c095bf5a832c21a3b54d99ea66eb30a752b490fa89a50234f60fd198398466ea7ca1fae
7
+ data.tar.gz: 2b88f008195b3dc473f793f08d3bd2a025d1839da3f977a824754e1bd5ff9e984f4b1d6916752bb285eba3abc5ea284ff6d79e8aecd9e18e2bed07c4cad44177
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -9,13 +9,14 @@ require 'recordx'
9
9
 
10
10
 
11
11
  class SectionX
12
+ using ColouredText
12
13
 
13
14
  attr_reader :attributes, :summary, :sections
14
15
 
15
16
  def initialize(x=nil, debug: false)
16
17
 
17
18
  @debug = debug
18
- puts 'initialize() x: ' + x.inspect if @debug
19
+ puts ('initialize() x: ' + x.inspect).debug if @debug
19
20
 
20
21
  @doc = if x.is_a? String then
21
22
  buffer, _ = RXFHelper.read x
@@ -28,6 +29,10 @@ class SectionX
28
29
  end
29
30
  end
30
31
 
32
+ def element(s)
33
+ @doc.root.element(s)
34
+ end
35
+
31
36
  def fetch(rxpath)
32
37
  list = rxpath.split('/').map {|x| x.gsub(/\s+/,'_').downcase.to_sym}
33
38
  find_section(list)
@@ -98,6 +103,10 @@ class SectionX
98
103
  def save(filepath)
99
104
  File.write filepath, @doc.xml(pretty: true)
100
105
  end
106
+
107
+ def text(s)
108
+ @doc.root.element("//%s/text()" % s.to_s).unescape
109
+ end
101
110
 
102
111
  def to_xml(options={})
103
112
  @doc.xml(options)
@@ -143,9 +152,9 @@ class SectionX
143
152
 
144
153
  def build_section(xml, raw_rows)
145
154
 
146
- puts 'raw_rows : ' + raw_rows.inspect
155
+ puts ('raw_rows : ' + raw_rows.inspect).debug if @debug
147
156
  raw_section_name = raw_rows.shift
148
- puts 'section_name : ' + raw_section_name.inspect
157
+ puts ('section_name : ' + raw_section_name.inspect).debug if @debug
149
158
 
150
159
  attr = if raw_section_name then
151
160
  section_name = raw_section_name[/[\w\s]+/]
@@ -181,11 +190,7 @@ class SectionX
181
190
  def find_section(a)
182
191
 
183
192
  section = a.shift
184
-
185
- found = @doc.root.xpath('sections/section').find do |e|
186
- title = e.attributes[:title]
187
- title.gsub(/\s+/,'_').downcase.to_sym == section if title
188
- end
193
+ found = @sections[section]
189
194
 
190
195
  return unless found
191
196
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sectionx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  lPw+nNEEQBBBOO6255zdlyzYtxsHXnEKJYvUjl4/Z/YIa2Y+VgLolw8kPC0Z0Ztw
36
36
  TLvN099jf8wfGlEJ/VkEKkXV
37
37
  -----END CERTIFICATE-----
38
- date: 2018-10-03 00:00:00.000000000 Z
38
+ date: 2018-12-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: line-tree
metadata.gz.sig CHANGED
Binary file