rexle 1.0.9 → 1.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0193c4d3705b9f87e437ab977ae9f76a0fed6249
4
- data.tar.gz: 7b5aa4669b9401b1348eb39baa8183b4e095bfc2
3
+ metadata.gz: e786ad00115c83c771c8282bf7578744c8ba32e6
4
+ data.tar.gz: f6727813960207805cd939fd2775319aff07e3a8
5
5
  SHA512:
6
- metadata.gz: 06576cb57a5d8326c3293597c46c67f772b6ce94500f9dfd2187a1c7f2a75b17223342e2e031c2e0f3a51d655c486e85a3e2cda6138abb8c8608586f5c8ae41f
7
- data.tar.gz: 3c49ff78bf4714076a78913714e551e659642841ffd92b07bc65d2285aa65f2433b46980f3e9acc7a12c820869ebb0043d4ea6bd0fb475d5fdb7ebe2e1c125ed
6
+ metadata.gz: 42cda03862eff07537e4f6b2277d44077ff3f22214c98cc8ce4e2fc68d763f23057fb27731a1b48d0ad518c29155c34ef94876f844cd9caed07f1abd01c05891
7
+ data.tar.gz: fef068c36f7bc9369d3ecfb06fb0e75c7c5d6197f6f1a7070e97d0e37dcf119100beac97c30ab4566b7067cbd4b27ca06a5a5b35c8399d366b8a719cee5e8ce0
checksums.yaml.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �����3%�
1
+ X�V�v�7aز����
2
+ ����5>Q&E�R>�?�/^;^�7<�;($�����e����J�>�� �����#>D���y�*0�#ȃ���5ރ��/v܀3��4�V�Wk�Q ���$�:����z�� @���nn 5��i�2�n*\U3F�oV�W�#�������|5&oVP��1.�A��}��2O
data.tar.gz.sig CHANGED
Binary file
data/lib/rexle.rb CHANGED
@@ -11,6 +11,7 @@ include REXML
11
11
 
12
12
  # modifications:
13
13
 
14
+ # 03-Jun-2013: bug fix: Text elements are now nil by default
14
15
  # 01-Jun-2014: bug fix: XPath elements separated by a pipe '|' are now
15
16
  # stripped of white space
16
17
  # 20-May-2014: feature: XPath Descendants after the element (or without
@@ -120,7 +121,10 @@ module XMLhelper
120
121
  a = x.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
121
122
  tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
122
123
 
123
- if x.value.length > 0 or (x.children.length > 0 and not x.children.is_an_empty_string?) then
124
+ if (x.value and x.value.length > 0) \
125
+ or (x.children and x.children.length > 0 \
126
+ and not x.children.is_an_empty_string?) then
127
+
124
128
  out = ["<%s>" % tag]
125
129
  #out << x.value unless x.value.nil? || x.value.empty?
126
130
  out << scan_print(x.children)
@@ -158,6 +162,8 @@ module XMLhelper
158
162
  def pretty_print(nodes, indent='0')
159
163
  indent = indent.to_i
160
164
 
165
+ return '' unless nodes
166
+
161
167
  nodes.select(){|x| x.is_a? Rexle::Element or (x.is_a? String and x.strip.length > 0)}
162
168
  .map.with_index do |x, i|
163
169
 
@@ -174,13 +180,15 @@ module XMLhelper
174
180
  tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
175
181
 
176
182
  start = i > 0 ? ("\n" + ' ' * (indent - 1)) : ''
177
- ind1 = x.children.grep(Rexle::Element).length > 0 ?
183
+
184
+ ind1 = (x.children and x.children.grep(Rexle::Element).length > 0) ?
178
185
  ("\n" + ' ' * indent) : ''
179
- out = ["%s<%s>%s" % [start, tag, ind1]]
180
186
 
181
- out << pretty_print(x.children, (indent + 1).to_s.clone)
182
- ind2 = ind1.length > 0 ? ("\n" + ' ' * (indent - 1)) : ''
187
+ out = ["%s<%s>%s" % [start, tag, ind1]]
188
+ out << pretty_print(x.children, (indent + 1).to_s.clone)
189
+ ind2 = (ind1 and ind1.length > 0) ? ("\n" + ' ' * (indent - 1)) : ''
183
190
  out << "%s</%s>" % [ind2, x.name]
191
+ out
184
192
  end
185
193
  elsif x.is_a? String then
186
194
  x.sub(/^[\n\s]+$/,'')
@@ -241,7 +249,7 @@ class Rexle
241
249
 
242
250
  alias original_clone clone
243
251
 
244
- def initialize(name=nil, value='', attributes={}, rexle=nil)
252
+ def initialize(name=nil, value=nil, attributes={}, rexle=nil)
245
253
 
246
254
  @rexle = rexle
247
255
  super()
@@ -557,8 +565,8 @@ class Rexle
557
565
  def attributes() @attributes end
558
566
 
559
567
  def children()
560
- return unless @value
561
- r = (@value.empty? ? [] : [@value]) + @child_elements
568
+ #return unless @value
569
+ r = (@value.to_s.empty? ? [] : [@value]) + @child_elements
562
570
  def r.is_an_empty_string?()
563
571
  self.length == 1 and self.first == ''
564
572
  end
@@ -760,7 +768,7 @@ class Rexle
760
768
  def scan_match(node, path)
761
769
 
762
770
  if path == '//' then
763
- return [node, !node.text.empty? ? node.text : nil,
771
+ return [node, node.text,
764
772
  node.elements.map {|x| scan_match x, path}]
765
773
  end
766
774
 
@@ -868,7 +876,7 @@ class Rexle
868
876
  else
869
877
  a = yield
870
878
  end
871
- doc_node = ['doc','',{}]
879
+ doc_node = ['doc',nil,{}]
872
880
  @a = procs[x.class.to_s.to_sym].call(x)
873
881
  @doc = scan_element(*(doc_node << @a))
874
882
  self
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.9
4
+ version: 1.0.10
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-06-01 00:00:00.000000000 Z
34
+ date: 2014-06-03 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexleparser
metadata.gz.sig CHANGED
Binary file