rexle 1.3.3 → 1.3.4

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: a389009f9a67e4e7ed9d8f714666e6d13ea0eb94
4
- data.tar.gz: ed36b12ea939166a12c0c5733c2dd5e2f5e2a2cd
3
+ metadata.gz: bb6ba948d31a6a7581097f7dd2c1ec329b774982
4
+ data.tar.gz: 27bd29c7458f62738ac32c760e7bd83cb09d9afa
5
5
  SHA512:
6
- metadata.gz: 9de30e22a09d097ebbdc1adeb5cba3aa5e35cb48ad7ebe403663485ba8be0ed27883ab7dce94d37680f59ea786d2a64fb8a59b832e549b29dc75313ffcd0187a
7
- data.tar.gz: 1d7cfe89491c0129a94dc232df66f60672f0beb3870018da9c1e0f6b43fd01856ad888e9f323121f90fa18d02f4f31753977f45c0291e22a111c858429d334cb
6
+ metadata.gz: 486bdb0b6ae7583ee126eb93058a8ae86e08f6455c2ad14f1bf58f5242a0f69d3aa3a24fbebbc442c4adcb7612e62ad71426f9eb9277499b9ab4ca25802852e3
7
+ data.tar.gz: d2b8eb4d21ba2f9344e9333e9f1367ffa1a2d42008406d6916ccb7d6c10b5f345200f43be0ce6d9ff9a2bf613f065a1a6bd29ef889b0f95624a8b9876f4224b9
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1 @@
1
- Y��h��)s��,�^��&�Pf�./�J`�+K�՛�7\��/M��
2
- O�����҉����>�x_�k%�-'�Z��9�����)��$�Xg;G��Ƅ�W�r��ei�SH�S.n��cq(LGLG����"B}�@0�?e�>��
3
- �&`� ��)��^V��@��OEf��g��QdK����H��r���A�Ҿ�J&.R>*(?�Zk�6����X��`��B 9�+��b���2I��+𸛲�Ȯ���� �Wۉmk� ��
1
+ ]�Vf��$&:��Y��8]�$G�2���gh�g
@@ -12,6 +12,7 @@ require 'cgi'
12
12
  # modifications:
13
13
 
14
14
  # 10-May-2015: bug fix: Rexle::Element#to_a now correctly returns an array
15
+ # Corrected method scan_to_a() which is used by to_a()
15
16
  # 02-May-2015: improvement: Rexle::Element#xpath function contains() can
16
17
  # now be used as a condition .e.g. b[contains(c,'10')]
17
18
  # 30-Apr-2015: improvement: Rexle::Element#xpath function contains() can
@@ -155,7 +156,8 @@ module XMLhelper
155
156
 
156
157
  def doc_print(children, declaration=true)
157
158
 
158
- body = (children.nil? or children.empty? or children.is_an_empty_string? ) ? '' : scan_print(children).join
159
+ body = (children.nil? or children.empty? \
160
+ or children.is_an_empty_string? ) ? '' : scan_print(children).join
159
161
 
160
162
  a = self.root.attributes.to_a.map do |k,v|
161
163
  "%s='%s'" % [k,(v.is_a?(Array) ? v.join(' ') : v.to_s)]
@@ -237,7 +239,7 @@ module XMLhelper
237
239
 
238
240
  if x.is_a? Rexle::Element then
239
241
 
240
- a = Array.new(String.new(x.name), Hash.new(x.attributes), String.new(x.value))
242
+ a = [String.new(x.name), Hash.new(x.attributes), x.value.to_s]
241
243
 
242
244
  (a.concat(scan_to_a(x.children))) if x.children.length > 1
243
245
  r << a
@@ -417,12 +419,19 @@ class Rexle
417
419
  end
418
420
 
419
421
  def name()
422
+
420
423
  if @rexle then
421
- prefix = @rexle.prefixes.find {|x| x == @name[/^(\w+):/,1] } if @rexle.prefixes.is_a? Array
424
+
425
+ if @rexle.prefixes.is_a? Array then
426
+ prefix = @rexle.prefixes.find {|x| x == @name[/^(\w+):/,1] }
427
+ end
428
+
422
429
  prefix ? @name.sub(prefix + ':', '') : @name
430
+
423
431
  else
424
432
  @name
425
433
  end
434
+
426
435
  end
427
436
 
428
437
  def next_element()
@@ -534,7 +543,8 @@ class Rexle
534
543
  return index ? a[index.to_i - 1].to_s : a
535
544
  end
536
545
 
537
- raw_results = xpath_value.empty? ? method(m.to_sym).call : method(m.to_sym).call(xpath_value)
546
+ raw_results = xpath_value.empty? ? method(m.to_sym).call \
547
+ : method(m.to_sym).call(xpath_value)
538
548
 
539
549
  raw_results
540
550
 
@@ -562,7 +572,8 @@ class Rexle
562
572
  remaining_path = ($').to_s
563
573
 
564
574
  if remaining_path[/^contains\(/] then
565
- raw_condition = raw_condition ? raw_condition + '/' + remaining_path : remaining_path
575
+ raw_condition = raw_condition ? raw_condition + '/' + remaining_path \
576
+ : remaining_path
566
577
  remaining_path = ''
567
578
  end
568
579
 
@@ -588,7 +599,8 @@ class Rexle
588
599
  attribute = xpath_value[/^(attribute::|@)(.*)/,2]
589
600
 
590
601
  return @attributes if attribute == '*'
591
- return [@attributes[attribute.to_sym]] if attribute and @attributes and @attributes.has_key?(attribute.to_sym)
602
+ return [@attributes[attribute.to_sym]] if attribute \
603
+ and @attributes and @attributes.has_key?(attribute.to_sym)
592
604
  s = a_path.shift
593
605
  end
594
606
 
@@ -610,7 +622,8 @@ class Rexle
610
622
  condition = element_part
611
623
 
612
624
  attr_search = format_condition('[' + condition + ']')
613
- return [attribute_search(attr_search, self, self.attributes) != nil]
625
+ return [attribute_search(attr_search, \
626
+ self, self.attributes) != nil]
614
627
  end
615
628
 
616
629
  end
@@ -620,7 +633,8 @@ class Rexle
620
633
  #element_name ||= '*'
621
634
  raw_condition = '' if condition
622
635
 
623
- attr_search = format_condition(condition) if condition and condition.length > 0
636
+ attr_search = format_condition(condition) if condition \
637
+ and condition.length > 0
624
638
  attr_search2 = xpath_value[/^\[(.*)\]$/,1]
625
639
 
626
640
  if attr_search2 then
@@ -710,18 +724,21 @@ class Rexle
710
724
  r = e.xpath(a_path.join('/') + raw_condition.to_s \
711
725
  + remaining_path, &blk)
712
726
 
713
- r = e if r.is_a?(Array) and r.first and r.first == true and a_path.empty?
727
+ r = e if r.is_a?(Array) and r.first and r.first == true \
728
+ and a_path.empty?
714
729
 
715
730
  r
716
731
  end
717
732
 
718
- next if rtn_element.nil? or (rtn_element.is_a? Array and rtn_element.empty?)
733
+ next if rtn_element.nil? or (rtn_element.is_a? Array \
734
+ and rtn_element.empty?)
719
735
 
720
736
  if rtn_element.is_a? Hash then
721
737
  rtn_element
722
738
  elsif rtn_element.is_a? Array then
723
739
  rtn_element
724
- elsif (rtn_element.is_a? String) || (rtn_element.is_a?(Array) and not(rtn_element[0].is_a? String))
740
+ elsif (rtn_element.is_a? String) || (rtn_element.is_a?(Array) \
741
+ and not(rtn_element[0].is_a? String))
725
742
  rtn_element
726
743
  elsif rtn_element.is_a? Rexle::Element
727
744
  rtn_element
@@ -730,7 +747,8 @@ class Rexle
730
747
  end
731
748
  end
732
749
 
733
- rlist = rlist.flatten(1) unless rlist.length > 1 and rlist[0].is_a? Array
750
+ rlist = rlist.flatten(1) unless rlist.length > 1 \
751
+ and rlist[0].is_a? Array
734
752
 
735
753
  end
736
754
 
@@ -742,11 +760,13 @@ class Rexle
742
760
  new_xpath = xpath_value[/^\/\/[\w:\-]+\/(.*)/,1]
743
761
 
744
762
  if new_xpath then
745
- self.xpath(new_xpath + raw_condition.to_s + remaining_path, rlist,&blk)
763
+ self.xpath(new_xpath + raw_condition.to_s + remaining_path, \
764
+ rlist,&blk)
746
765
  end
747
766
  end
748
767
 
749
- rlist = rlist.flatten(1) unless not(rlist.is_a? Array) or (rlist.length > 1 and rlist[0].is_a? Array)
768
+ rlist = rlist.flatten(1) unless not(rlist.is_a? Array) \
769
+ or (rlist.length > 1 and rlist[0].is_a? Array)
750
770
  rlist = [rlist] if rlist.is_a? Rexle::Element
751
771
  rlist = (rlist.length > 0 ? true : false) if flag_func == true
752
772
 
@@ -885,7 +905,8 @@ class Rexle
885
905
 
886
906
  def elements(s=nil)
887
907
  procs = {
888
- NilClass: proc {Elements.new(@child_elements.select{|x| x.kind_of? Rexle::Element })},
908
+ NilClass: proc {Elements.new(@child_elements\
909
+ .select{|x| x.kind_of? Rexle::Element })},
889
910
  String: proc {|x| @child_elements[x]}
890
911
  }
891
912
 
@@ -957,7 +978,7 @@ class Rexle
957
978
  alias text= value=
958
979
 
959
980
  def to_a()
960
- e = [String.new(self.name), Hash.new(self.attributes), String.new(self.value)]
981
+ e = [String.new(self.name), Hash.new(self.attributes), self.value.to_s]
961
982
  [*e, *scan_to_a(self.children)]
962
983
  end
963
984
 
@@ -1022,7 +1043,10 @@ class Rexle
1022
1043
  return raw_items[0]
1023
1044
  else
1024
1045
 
1025
- andor_items = raw_items.map.with_index.select{|x,i| x[/\band\b|\bor\b/]}.map{|x| [x.last, x.last + 1]}.flatten
1046
+ andor_items = raw_items.map.with_index\
1047
+ .select{|x,i| x[/\band\b|\bor\b/]}\
1048
+ .map{|x| [x.last, x.last + 1]}.flatten
1049
+
1026
1050
  indices = [0] + andor_items + [raw_items.length]
1027
1051
 
1028
1052
  if raw_items[0][0] == '@' then
@@ -1066,7 +1090,8 @@ class Rexle
1066
1090
  "r = e.xpath('#{path}').first; r and r.value == #{value}"
1067
1091
  end
1068
1092
  else
1069
- "(name == '%s' and value %s '%s')" % [x[0], x[1], x[2].sub(/^['"](.*)['"]$/,'\1')]
1093
+ "(name == '%s' and value %s '%s')" % [x[0], x[1], \
1094
+ x[2].sub(/^['"](.*)['"]$/,'\1')]
1070
1095
  end
1071
1096
  else
1072
1097
  "e.value %s %s" % [x[1], x[2]]
@@ -1098,7 +1123,8 @@ class Rexle
1098
1123
 
1099
1124
 
1100
1125
  r << node.xpath(xpath2)
1101
- r << node.elements.map {|n| scan_match(n, path) if n.is_a? Rexle::Element}
1126
+ r << node.elements.map {|n| scan_match(n, path) if n\
1127
+ .is_a? Rexle::Element}
1102
1128
  r
1103
1129
  end
1104
1130
 
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.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file