rexle 1.0.28 → 1.0.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a1d04a3bbbebe6ac28ecef677f260599677823e
4
- data.tar.gz: 26c280d22625e757fddfa47a8f264790f5244458
3
+ metadata.gz: 093ee31cda01f5cb6bed485d2bc513cf866373cf
4
+ data.tar.gz: e54e0d493cfde0d7411b28f517164fafc1790981
5
5
  SHA512:
6
- metadata.gz: 0e15d380c21d430e9b0c9913f536a2a30a86c2fb2743cb52167a30e38e5967ab948015a804bbaf5f6cdf050727776cc5f6d67c9360e2d8f68e40c92eb369a80c
7
- data.tar.gz: e4fe7b85fc12dc1cfea3eb9a702d6bd20a56431a2ded71a9f385a598f2c931d90dc081c646ab1fa639a0d632cf703ccbaa08c112c11eb0f1042ffb6d2120f635
6
+ metadata.gz: 8bede7d10f4ebe56bf7b05e34a9c8e020a81a4a789a1838f539d9c9508fd501ed8a1ac65bb0737622ccc66543532924e1e0416a23c13edb114ccedaafb32b7b0
7
+ data.tar.gz: 329aab680819126a9f58589aeb18252388edd4320fb8da7fef6c656f6609088abdf234f96e7d252b54af8c12b80962ece05e06d0c896d9c39c3b7feb9fd79aa0
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/rexle.rb CHANGED
@@ -12,6 +12,8 @@ include REXML
12
12
 
13
13
  # modifications:
14
14
 
15
+ # 21-Oct-2014: partial feature: An Xpath containing //preceding-sibling and
16
+ # //following-sibling now works
15
17
  # 19-Oct-2014: feature: An XPath containing the attribute @class is
16
18
  # now treated as a type of CSS selector storage area
17
19
  # feature: Implemented Rexle::Element#previous_element and
@@ -345,6 +347,7 @@ class Rexle
345
347
 
346
348
  def xpath(path, rlist=[], &blk)
347
349
 
350
+ #return if path[/^(?:preceding|following)-sibling/]
348
351
  r = filter_xpath(path, rlist=[], &blk)
349
352
  r.is_a?(Array) ? r.compact : r
350
353
  end
@@ -489,9 +492,35 @@ class Rexle
489
492
  #jr101013 return [self]
490
493
  else
491
494
 
492
- return_elements = @child_lookup.map.with_index.select do |x|
493
- (x[0][0] == element_name || element_name == '.') or \
494
- (element_name == '*' && x[0].is_a?(Array))
495
+ if element_name.is_a? String then
496
+ ename, raw_selector = (element_name.split('::',2)).reverse
497
+
498
+ selector = case raw_selector
499
+ when 'following-sibling' then 1
500
+ when 'preceding-sibling' then -1
501
+ end
502
+
503
+ else
504
+ ename = element_name
505
+ end
506
+
507
+ return_elements = @child_lookup.map.with_index.select do |x|
508
+
509
+ (x[0][0] == ename || ename == '.') or \
510
+ (ename == '*' && x[0].is_a?(Array))
511
+ end
512
+
513
+ if selector then
514
+ ne = return_elements.inject([]) do |r,x|
515
+ i = x.last + selector
516
+ if i >= 0 then
517
+ r << i
518
+ else
519
+ r
520
+ end
521
+ end
522
+
523
+ return_elements = ne.map {|x| [@child_lookup[x], x] if x}
495
524
  end
496
525
 
497
526
  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.0.28
4
+ version: 1.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  UOGKUMV5RApHDnC0ywMYNe0HK7qMSTP5YLKs8JUjNxpc5jl8+o3D3sHkNN4DzbQm
32
32
  jVfzDZ+niKvAUA==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-10-19 00:00:00.000000000 Z
34
+ date: 2014-10-21 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexleparser
metadata.gz.sig CHANGED
Binary file