rexle 1.3.21 → 1.3.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rexle.rb +35 -2
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5859ab26778f60354c699ca00884fe003b8701ba
|
4
|
+
data.tar.gz: d937cbc44b7760eb192d7dbf600eca832f8f6be1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c86d4f2cda3b03ef41ea38aac2784df50332aae2e6195e5af09f275850c022835f6ff73b0ca4a95ed963b9af6ab83936df7998db5d8848e6cbf8f444dda9e80
|
7
|
+
data.tar.gz: dedcbd5c2afd5eae4381ff8dfceb3d16accd784adea2596233a2fdd6a30331bc5017c32b453c8f7ae9ba507f24f27e74881ff87ebfbdf1154a94f5ad3330fff3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rexle.rb
CHANGED
@@ -12,7 +12,9 @@ require 'backtrack-xpath'
|
|
12
12
|
|
13
13
|
# modifications:
|
14
14
|
|
15
|
-
# 21-Apr-2016: feature: The
|
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
|
-
|
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
metadata.gz.sig
CHANGED
Binary file
|