rexle 1.2.24 → 1.3.0
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/lib/rexle.rb +46 -15
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 8af7ff3ce7ef696fa24a906caa25c32381c11458
|
4
|
+
data.tar.gz: 756dc93d3d000174f6e7d44230092ab827498ccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0af0430e0dc89eb284320748b95421cdeb69da273fb268dddc981724aba5a5c32dcfccf7fab01519aea4a4a7108da10932921c61faf361ef34dbb9dd84e1296e
|
7
|
+
data.tar.gz: 9de8aac2472905c73183f64063ef5e1218e18694ca40e0ead0cec3ac247898b8da2f017cfd716b7885abf8a43638f3caa72bcbe5bc6d8fcf04625db10b45e5df
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rexle.rb
CHANGED
@@ -11,6 +11,8 @@ require 'cgi'
|
|
11
11
|
|
12
12
|
# modifications:
|
13
13
|
|
14
|
+
# 30-Apr-2015: improvement: Rexle::Element#xpath function contains() can
|
15
|
+
# now handle string values
|
14
16
|
# 24-Mar-2015: bug fix: Rexle::Elements no longer allows indexes less than 1
|
15
17
|
# 20-Mar-2015: bug fix: Dynarex documents which fail to parse properly with the
|
16
18
|
# Dynarex parser are now parsed by by the Rexle parser
|
@@ -304,7 +306,7 @@ class Rexle
|
|
304
306
|
@instructions = [["xml", "version='1.0' encoding='UTF-8'"]]
|
305
307
|
@doctype = :xml
|
306
308
|
|
307
|
-
# what type of input is it? Is it a string, array
|
309
|
+
# what type of input is it? Is it a string, array
|
308
310
|
if x then
|
309
311
|
procs = {
|
310
312
|
String: proc {|x| parse_string(x)},
|
@@ -314,9 +316,7 @@ class Rexle
|
|
314
316
|
doc_node = ['doc',Attributes.new]
|
315
317
|
|
316
318
|
@a = procs[x.class.to_s.to_sym].call(x)
|
317
|
-
#@log.debug 'rexle: before scan_element a: ' + @a.inspect
|
318
319
|
@doc = scan_element(*(doc_node << @a))
|
319
|
-
#@log.debug 'rexle: after scan_element' + self.to_a.inspect
|
320
320
|
|
321
321
|
# fetch the namespaces
|
322
322
|
@prefixes = []
|
@@ -438,7 +438,6 @@ class Rexle
|
|
438
438
|
|
439
439
|
def xpath(path, rlist=[], &blk)
|
440
440
|
|
441
|
-
#return if path[/^(?:preceding|following)-sibling/]
|
442
441
|
r = filter_xpath(path, rlist=[], &blk)
|
443
442
|
r.is_a?(Array) ? r.compact : r
|
444
443
|
end
|
@@ -456,7 +455,7 @@ class Rexle
|
|
456
455
|
m = end_fn_match[1..-4]
|
457
456
|
[method(m.to_sym).call(xpath path)]
|
458
457
|
|
459
|
-
elsif (fn_match and fn_match.captures.first[/^(attribute|@)/])
|
458
|
+
elsif (fn_match and fn_match.captures.first[/^(attribute|@)/])
|
460
459
|
|
461
460
|
procs = {
|
462
461
|
|
@@ -479,33 +478,63 @@ class Rexle
|
|
479
478
|
|
480
479
|
query_xpath(xp.strip, bucket, &blk)
|
481
480
|
end
|
482
|
-
|
481
|
+
|
483
482
|
results = raw_results
|
484
483
|
|
485
484
|
procs[results.class.to_s.to_sym].call(results) if results
|
486
485
|
|
487
|
-
|
486
|
+
elsif fn_match.nil?
|
487
|
+
|
488
|
+
procs = {
|
488
489
|
|
489
|
-
|
490
|
+
Array: proc { |x|
|
491
|
+
if block_given? then
|
492
|
+
x.flatten(1)
|
493
|
+
else
|
494
|
+
rs = x.flatten
|
495
|
+
rs.any?{|x| x == true or x == false} ? rs : rs.uniq(&:object_id)
|
496
|
+
end
|
497
|
+
},
|
498
|
+
String: proc {|x| x},
|
499
|
+
Hash: proc {|x| x},
|
500
|
+
TrueClass: proc{|x| x},
|
501
|
+
FalseClass: proc{|x| x},
|
502
|
+
:"Rexle::Element" => proc {|x| [x]}
|
503
|
+
}
|
504
|
+
bucket = []
|
505
|
+
raw_results = path.split('|').map do |xp|
|
506
|
+
|
507
|
+
query_xpath(xp.strip, bucket, &blk)
|
508
|
+
end
|
509
|
+
|
510
|
+
return [true] if !path[/[><]/] and raw_results.flatten.index(true)
|
511
|
+
results = raw_results # .flatten.select {|x| x}
|
512
|
+
|
513
|
+
procs[results.class.to_s.to_sym].call(results) if results
|
490
514
|
|
515
|
+
else
|
516
|
+
|
517
|
+
m, xpath_value, index = fn_match.captures
|
518
|
+
|
491
519
|
if m == 'text' then
|
492
520
|
a = texts()
|
493
521
|
return index ? a[index.to_i - 1].to_s : a
|
494
522
|
end
|
495
523
|
|
496
|
-
xpath_value.empty? ? method(m.to_sym).call : method(m.to_sym).call(xpath_value)
|
524
|
+
raw_results = xpath_value.empty? ? method(m.to_sym).call : method(m.to_sym).call(xpath_value)
|
525
|
+
|
526
|
+
raw_results
|
527
|
+
|
497
528
|
end
|
498
529
|
|
499
530
|
end
|
500
531
|
|
501
532
|
def query_xpath(raw_xpath_value, rlist=[], &blk)
|
502
533
|
|
503
|
-
|
504
|
-
#@rexle.prefixes.each {|x| xpath_value.sub!(x + ':','') }
|
534
|
+
|
505
535
|
flag_func = false
|
506
536
|
|
507
537
|
xpath_value = raw_xpath_value.sub('child::','./')
|
508
|
-
#xpath_value.sub!(/\.\/(?=[\/])/,'')
|
509
538
|
|
510
539
|
if xpath_value[/^[\w\/]+\s*=.*/] then
|
511
540
|
flag_func = true
|
@@ -513,11 +542,8 @@ class Rexle
|
|
513
542
|
xpath_value.sub!(/^\w+\s*=.*/,'.[\0]')
|
514
543
|
xpath_value.sub!(/\/([\w]+\s*=.*)/,'[\1]')
|
515
544
|
|
516
|
-
#result = self.element xpath_value
|
517
|
-
#return [(result.is_a?(Rexle::Element) ? true : false)]
|
518
545
|
end
|
519
546
|
|
520
|
-
#xpath_value.sub!(/^attribute::/,'*/attribute::')
|
521
547
|
raw_path, raw_condition = xpath_value.sub(/^\.?\/(?!\/)/,'')\
|
522
548
|
.match(/([^\[]+)(\[[^\]]+\])?/).captures
|
523
549
|
|
@@ -659,6 +685,9 @@ class Rexle
|
|
659
685
|
|
660
686
|
r = e.xpath(a_path.join('/') + raw_condition.to_s \
|
661
687
|
+ remaining_path, &blk)
|
688
|
+
|
689
|
+
r = e if r.is_a?(Array) and r.first and r.first == true and a_path.empty?
|
690
|
+
|
662
691
|
r
|
663
692
|
end
|
664
693
|
|
@@ -672,6 +701,8 @@ class Rexle
|
|
672
701
|
rtn_element
|
673
702
|
elsif rtn_element.is_a? Rexle::Element
|
674
703
|
rtn_element
|
704
|
+
elsif rtn_element == true
|
705
|
+
true
|
675
706
|
end
|
676
707
|
end
|
677
708
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
Tkua07gB3/nVO3aPg7C3vEbDZCxT3WAMli2uZisYT6ozmdAlDsixLjipgFN4If3z
|
32
32
|
Ej0QR3kvGcAvFQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-
|
34
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexleparser
|
metadata.gz.sig
CHANGED
Binary file
|