sectionx 0.4.3 → 0.4.4

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: b4e4ca9633bf1b35ddbbc560f96864c6006bdb82a350f5549fb61ab0802834e3
4
- data.tar.gz: eb054954973c84726d483aaf11fa27715b3dc9b741d55f205006cc8371326dc7
3
+ metadata.gz: eeb59887f6e890a97b343d84531c55a534bed6fa8f56cbe4f0b32f905aac1d46
4
+ data.tar.gz: fbec4ce7de357eaeedf2923a20e9d0cd8a1400cd14869014714ea988212de433
5
5
  SHA512:
6
- metadata.gz: 0c5bec2f043a19f857bdae0e75c2abe84724b7588b1bf3e7473c587820f907770a573022c08e86814b3e55ba380fa242671ce9fe4b8d0d9b5ecece93d4a02a7c
7
- data.tar.gz: ce808ee0bd8b3af833821dd2a75f29bc601251e8976b4f01ad29b79d155d79049d8e98459838fe168d1add8072d24372b98cbbaa80d5634cfa51a879a008939c
6
+ metadata.gz: a327cf2d5afbbcc59d653bd6bcde531b8cfdf62b4bc7ba3eb89526cb0487b0703a64fe8f83a4fc5f4e9b24e8f9ba56c366b6e75641b1a03abced96277eeaec3f
7
+ data.tar.gz: 11cd4e1d35c48e61e05afbc70d3841ca43fb70c84e25245f8f8e67b55e02967f6457859e6f437ff6ce277fa194b4a25f5d973aa88f06d5e81e2f74aee7236aeb
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/sectionx.rb CHANGED
@@ -27,6 +27,12 @@ class SectionX
27
27
  @attributes, @summary, @sections = parse_root_node @doc.root
28
28
  end
29
29
  end
30
+
31
+ def fetch(rxpath)
32
+ list = rxpath.split('/').map {|x| x.gsub(/\s+/,'_').downcase.to_sym}
33
+ find_section(list)
34
+ end
35
+
30
36
 
31
37
  def import(raw_s)
32
38
 
@@ -170,6 +176,26 @@ class SectionX
170
176
  v.gsub('&','&amp;').gsub('<','&lt;').gsub('>','&gt;')
171
177
  end
172
178
 
179
+ # Returns the XML element
180
+ #
181
+ def find_section(a)
182
+
183
+ 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
189
+
190
+ return unless found
191
+
192
+ if a.length > 1 then
193
+ found.find_section(a)
194
+ else
195
+ a.length > 0 ? found.element('summary/' + a[0].to_s) : found
196
+ end
197
+ end
198
+
173
199
  def indent_heading(s, heading='#')
174
200
 
175
201
  a = s.split(/(?=^\s*#{heading}\s*[\[\w])/).map do |x|
@@ -223,6 +249,8 @@ class SectionX
223
249
  [attributes, summary, sections]
224
250
  end
225
251
 
252
+
253
+
226
254
  end
227
255
 
228
256
  if __FILE__ == $0 then
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.3
4
+ version: 0.4.4
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-02 00:00:00.000000000 Z
38
+ date: 2018-10-03 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