rexle 1.3.6 → 1.3.7
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rexle.rb +37 -8
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: f0db24e5f8ce1011dac3c9524af0c2a01d4923ab
|
4
|
+
data.tar.gz: 0e9124363806ef72b44a09ed758e89cc6b25524c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6cce9a423805620f6acb1c4c9f9f7bc151b6297b93a65126723b8486347bc65e0b7fe3f5fa04640b31805db388795d6f8e7c3feea7d0cd42d5c6566a800bc2a
|
7
|
+
data.tar.gz: 71432178956463b3c60ced324d129f28a35662f69b26088643afe74d42650731eb06a914862422ce282e1962373ab38d350e356d8523bc679cee77b9381421c6
|
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
|
+
# 15-Sep-2015: improvement: When handling the HTML element textarea, it
|
15
|
+
# is no longer printed as a self-closing tag
|
14
16
|
# 25-May-2015: bug fix: If a Polyrex XML string is being parsed then the
|
15
17
|
# XML instructions will also now be read.
|
16
18
|
# 11-May-2015: improvement: when Rexle::Element#delete is passed an XPath it
|
@@ -219,7 +221,8 @@ module XMLhelper
|
|
219
221
|
tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
|
220
222
|
|
221
223
|
if (x.children and x.children.length > 0 \
|
222
|
-
and not x.children.is_an_empty_string?) or
|
224
|
+
and not x.children.is_an_empty_string?) or \
|
225
|
+
x.name == 'script' or x.name == 'textarea' then
|
223
226
|
|
224
227
|
out = ["<%s>" % tag]
|
225
228
|
out << scan_print(x.children)
|
@@ -278,7 +281,8 @@ module XMLhelper
|
|
278
281
|
|
279
282
|
if (x.value and x.value.length > 0) \
|
280
283
|
or (x.children and x.children.length > 0 \
|
281
|
-
and not x.children.is_an_empty_string?) or
|
284
|
+
and not x.children.is_an_empty_string?) or \
|
285
|
+
x.name == 'script' or x.name == 'textarea' then
|
282
286
|
|
283
287
|
ind1 = (x.children and x.children.grep(Rexle::Element).length > 0) ?
|
284
288
|
("\n" + ' ' * indent) : ''
|
@@ -377,6 +381,7 @@ class Rexle
|
|
377
381
|
raise "Element name must not be blank" unless name
|
378
382
|
@child_elements = []
|
379
383
|
self.add_text value if value
|
384
|
+
#@log = Logger.new('rexle.log','daily')
|
380
385
|
|
381
386
|
end
|
382
387
|
|
@@ -389,7 +394,8 @@ class Rexle
|
|
389
394
|
end
|
390
395
|
|
391
396
|
def contains(raw_args)
|
392
|
-
|
397
|
+
#log = Logger.new('rexle.log','daily')
|
398
|
+
#log.debug 'inside contains'
|
393
399
|
path, raw_val = raw_args.split(',',2)
|
394
400
|
val = raw_val.strip[/^["']?.*["']?$/]
|
395
401
|
|
@@ -451,6 +457,16 @@ class Rexle
|
|
451
457
|
|
452
458
|
alias next_sibling next_element
|
453
459
|
|
460
|
+
def notx(bool)
|
461
|
+
#log = Logger.new('rexle.log','daily')
|
462
|
+
#log.debug 'self ' + self.xml.inspect
|
463
|
+
#log.debug 'inside not() ' + bool.inspect
|
464
|
+
r = self.xpath(bool).any?
|
465
|
+
#log.debug 'r: ' + r.inspect
|
466
|
+
#log.debug 'r2: ' + (!r).inspect
|
467
|
+
!r
|
468
|
+
end
|
469
|
+
|
454
470
|
def previous_element()
|
455
471
|
|
456
472
|
id = self.object_id
|
@@ -464,22 +480,26 @@ class Rexle
|
|
464
480
|
alias previous_sibling previous_element
|
465
481
|
|
466
482
|
def xpath(path, rlist=[], &blk)
|
483
|
+
#@log.debug 'inside xpath ' + path.inspect
|
467
484
|
|
468
485
|
r = filter_xpath(path, rlist=[], &blk)
|
486
|
+
#@log.debug 'after filter_xpath : ' + r.inspect
|
469
487
|
r.is_a?(Array) ? r.compact : r
|
470
488
|
end
|
471
489
|
|
472
490
|
def filter_xpath(raw_path, rlist=[], &blk)
|
473
|
-
|
491
|
+
#@log.debug 'inside filter_xpath : ' + raw_path.inspect
|
474
492
|
path = String.new raw_path
|
475
493
|
|
476
494
|
# is it a function
|
477
495
|
fn_match = path.match(/^(\w+)\(["']?([^\)]*)["']?\)(?:\[(.*)\])?$/)
|
496
|
+
#@log.debug 'fn_match : ' + fn_match.inspect
|
478
497
|
end_fn_match = path.slice!(/\[\w+\(\)\]$/)
|
479
498
|
|
480
499
|
if end_fn_match then
|
481
500
|
|
482
501
|
m = end_fn_match[1..-4]
|
502
|
+
#@log.debug 'its a function'
|
483
503
|
[method(m.to_sym).call(xpath path)]
|
484
504
|
|
485
505
|
elsif (fn_match and fn_match.captures.first[/^(attribute|@)/])
|
@@ -547,7 +567,7 @@ class Rexle
|
|
547
567
|
a = texts()
|
548
568
|
return index ? a[index.to_i - 1].to_s : a
|
549
569
|
end
|
550
|
-
|
570
|
+
#@log.debug 'before function call'
|
551
571
|
raw_results = xpath_value.empty? ? method(m.to_sym).call \
|
552
572
|
: method(m.to_sym).call(xpath_value)
|
553
573
|
|
@@ -558,12 +578,16 @@ class Rexle
|
|
558
578
|
end
|
559
579
|
|
560
580
|
def query_xpath(raw_xpath_value, rlist=[], &blk)
|
581
|
+
|
582
|
+
#@log.debug 'query_xpath : ' + raw_xpath_value.inspect
|
583
|
+
#@log.debug '++ ' + self.xml.inspect
|
561
584
|
|
562
585
|
flag_func = false
|
563
586
|
|
564
587
|
xpath_value = raw_xpath_value.sub('child::','./')
|
565
588
|
|
566
|
-
if xpath_value[/^[\w\/]+\s*=.*/] then
|
589
|
+
if xpath_value[/^[\w\/]+\s*=.*/] then
|
590
|
+
#@log.debug 'yah'
|
567
591
|
flag_func = true
|
568
592
|
|
569
593
|
xpath_value.sub!(/^\w+\s*=.*/,'.[\0]')
|
@@ -575,6 +599,7 @@ class Rexle
|
|
575
599
|
.match(/([^\[]+)(\[[^\]]+\])?/).captures
|
576
600
|
|
577
601
|
remaining_path = ($').to_s
|
602
|
+
#@log.debug 'remaining_path: ' + remaining_path.inspect
|
578
603
|
|
579
604
|
if remaining_path[/^contains\(/] then
|
580
605
|
raw_condition = raw_condition ? raw_condition + '/' + remaining_path \
|
@@ -627,6 +652,7 @@ class Rexle
|
|
627
652
|
condition = element_part
|
628
653
|
|
629
654
|
attr_search = format_condition('[' + condition + ']')
|
655
|
+
#@log.debug 'attr_search : ' + attr_search.inspect
|
630
656
|
return [attribute_search(attr_search, \
|
631
657
|
self, self.attributes) != nil]
|
632
658
|
end
|
@@ -640,9 +666,11 @@ class Rexle
|
|
640
666
|
|
641
667
|
attr_search = format_condition(condition) if condition \
|
642
668
|
and condition.length > 0
|
669
|
+
#@log.debug 'attr_search2 : ' + attr_search.inspect
|
643
670
|
attr_search2 = xpath_value[/^\[(.*)\]$/,1]
|
644
671
|
|
645
672
|
if attr_search2 then
|
673
|
+
#@log.debug 'before attribute_Search'
|
646
674
|
r4 = attribute_search(attr_search, self, self.attributes)
|
647
675
|
return r4
|
648
676
|
end
|
@@ -1037,8 +1065,7 @@ class Rexle
|
|
1037
1065
|
def format_condition(condition)
|
1038
1066
|
|
1039
1067
|
raw_items = condition[1..-1].scan(/\'[^\']*\'|\"[^\"]*\"|\
|
1040
|
-
and|or|\d+|[!=<>]+|position\(\)|contains\([^\)]+\)|[@\w\.\/&;]+/)
|
1041
|
-
|
1068
|
+
and|or|\d+|[!=<>]+|position\(\)|contains\([^\)]+\)|notx\([^\)]+\)|[@\w\.\/&;]+/)
|
1042
1069
|
|
1043
1070
|
if raw_items[0][/^\d+$/] then
|
1044
1071
|
return raw_items[0].to_i
|
@@ -1047,6 +1074,8 @@ class Rexle
|
|
1047
1074
|
return rrr
|
1048
1075
|
elsif raw_items[0][/^contains\(/]
|
1049
1076
|
return raw_items[0]
|
1077
|
+
elsif raw_items[0][/^notx\(/]
|
1078
|
+
return raw_items[0]
|
1050
1079
|
else
|
1051
1080
|
|
1052
1081
|
andor_items = raw_items.map.with_index\
|
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.3.
|
4
|
+
version: 1.3.7
|
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-09-15 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexleparser
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.4.
|
183
|
+
rubygems_version: 2.4.8
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Rexle is an XML parser written purely in Ruby
|
metadata.gz.sig
CHANGED
Binary file
|