rexle 1.3.21 → 1.3.22

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
  SHA1:
3
- metadata.gz: 4dbefefe2ee7e079624cf397cd956515d26fcb47
4
- data.tar.gz: 55f6a9d18b0e0b2c547d585dbb117705978b5991
3
+ metadata.gz: 5859ab26778f60354c699ca00884fe003b8701ba
4
+ data.tar.gz: d937cbc44b7760eb192d7dbf600eca832f8f6be1
5
5
  SHA512:
6
- metadata.gz: 74c97ba08e685e66b599de477e99ca56af1c250362310dbb0e6e3f01294819c3accaf4b790eb88f04f81c1768f293d9f175d7045fbe5e196bfb15cd3d3ee1f83
7
- data.tar.gz: 2d9ad02d1e4cea5cbd320909df7840049e1402b241a0445814bd2dfab3298f400d47d52b14c858d62ba067f9c5ac59e140421f707f16fb06404dd0996dbb4f1c
6
+ metadata.gz: 9c86d4f2cda3b03ef41ea38aac2784df50332aae2e6195e5af09f275850c022835f6ff73b0ca4a95ed963b9af6ab83936df7998db5d8848e6cbf8f444dda9e80
7
+ data.tar.gz: dedcbd5c2afd5eae4381ff8dfceb3d16accd784adea2596233a2fdd6a30331bc5017c32b453c8f7ae9ba507f24f27e74881ff87ebfbdf1154a94f5ad3330fff3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,7 +12,9 @@ require 'backtrack-xpath'
12
12
 
13
13
  # modifications:
14
14
 
15
- # 21-Apr-2016: feature: The element index can now be used through an
15
+ # 21-Apr-2016: feature: The xpath() method now returns a Rexle::Recordset object
16
+ # which itself can be treat as a Rexle document
17
+ # feature: The element index can now be used through an
16
18
  # xpath block parameter
17
19
  # An xpath predicate can now contain the mod operator as well as
18
20
  # containing nested logic e.g. [(position() mod 2) == 1]
@@ -415,7 +417,15 @@ class Rexle
415
417
 
416
418
  r = filter_xpath(path, rlist=[], &blk)
417
419
  #@log.debug 'after filter_xpath : ' + r.inspect
418
- r.is_a?(Array) ? r.compact : r
420
+
421
+ if r.is_a?(Array) then
422
+
423
+ Recordset.new(r.compact)
424
+
425
+ else
426
+ r
427
+ end
428
+
419
429
  end
420
430
 
421
431
  def filter_xpath(raw_path, rlist=[], &blk)
@@ -1455,5 +1465,28 @@ class Rexle
1455
1465
  attributes = node.attributes.inject({}){|r,x| r.merge(Hash[*x])}
1456
1466
  [node.name, node.text.to_s, attributes, *children]
1457
1467
  end
1468
+
1469
+ class Recordset < Array
1470
+
1471
+ def initialize(a)
1472
+ super(a)
1473
+ end
1474
+
1475
+ def to_doc()
1476
+
1477
+ recordset = self.map(&:to_a)
1478
+ Rexle.new(['root',{}, *recordset])
1479
+
1480
+ end
1481
+
1482
+ def xpath(xpath)
1483
+ self.to_doc.root.xpath(xpath)
1484
+ end
1485
+
1486
+ def element(xpath)
1487
+ self.to_doc.root.element(xpath)
1488
+ end
1489
+
1490
+ end
1458
1491
 
1459
1492
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.21
4
+ version: 1.3.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file