rexle 1.2.14 → 1.2.15
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.tar.gz.sig +0 -0
- data/lib/rexle.rb +20 -11
- 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: 5559b87ef79c7f4b80c53c9ecc947faef841ec67
|
4
|
+
data.tar.gz: 298dc92004f7beabcba9d80409336ff7562c636d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70308f9ba7e23e4fe57d2de7b74aa5f64d40628f0783a022ba953400ee914a6748260770cae80d765e576fc18c251fcbcb0c9adbb5d2e3ab53df2d3a7a4ab687
|
7
|
+
data.tar.gz: 48ae9f24a21f16d3fcfd549cb87e38fd3701680c594bc80fef63eb4d2c9cd4c5f107190c79b0f0e1a29fca32b6320f4fa6a49ca380adfcb035f8885e1c6124b1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rexle.rb
CHANGED
@@ -11,6 +11,8 @@ require 'cgi'
|
|
11
11
|
|
12
12
|
# modifications:
|
13
13
|
|
14
|
+
# 16-Feb-2015: bug fix: Rexle::Element#value assignment is now made by
|
15
|
+
# value instead of reference
|
14
16
|
# 11-Feb-2015: bug fix: add_text now adds a String to @child_elements.
|
15
17
|
# All references to @child_lookup have now been removed.
|
16
18
|
# 08-Feb-2015: bug fix: Within method filter_xpath(), a new String is created
|
@@ -129,11 +131,11 @@ require 'cgi'
|
|
129
131
|
module XMLhelper
|
130
132
|
|
131
133
|
def doc_print(children, declaration=true)
|
132
|
-
|
134
|
+
|
133
135
|
body = (children.nil? or children.empty? or children.is_an_empty_string? ) ? '' : scan_print(children).join
|
134
136
|
|
135
137
|
a = self.root.attributes.to_a.map do |k,v|
|
136
|
-
"%s='%s'" % [k,(v.is_a?(Array) ? v.join(' ') : v)]
|
138
|
+
"%s='%s'" % [k,(v.is_a?(Array) ? v.join(' ') : v.to_s)]
|
137
139
|
end
|
138
140
|
|
139
141
|
xml = "<%s%s>%s</%s>" % [self.root.name, a.empty? ? '' : \
|
@@ -176,7 +178,7 @@ module XMLhelper
|
|
176
178
|
nodes.map do |x|
|
177
179
|
|
178
180
|
if x.is_a? Rexle::Element then
|
179
|
-
|
181
|
+
|
180
182
|
a = x.attributes.to_a.map do |k,v|
|
181
183
|
"%s='%s'" % [k,(v.is_a?(Array) ? v.join(' ') : v)]
|
182
184
|
end
|
@@ -232,18 +234,19 @@ module XMLhelper
|
|
232
234
|
.map.with_index do |x, i|
|
233
235
|
|
234
236
|
if x.is_a? Rexle::Element then
|
235
|
-
|
237
|
+
|
236
238
|
a = x.attributes.to_a.map do |k,v|
|
237
239
|
"%s='%s'" % [k,(v.is_a?(Array) ? v.join(' ') : v)]
|
238
240
|
end
|
239
|
-
a ||= []
|
241
|
+
a ||= []
|
242
|
+
|
240
243
|
tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
|
241
244
|
start = i > 0 ? ("\n" + ' ' * (indent - 1)) : ''
|
242
|
-
|
245
|
+
|
243
246
|
if (x.value and x.value.length > 0) \
|
244
247
|
or (x.children and x.children.length > 0 \
|
245
248
|
and not x.children.is_an_empty_string?) or x.name == 'script' then
|
246
|
-
|
249
|
+
|
247
250
|
ind1 = (x.children and x.children.grep(Rexle::Element).length > 0) ?
|
248
251
|
("\n" + ' ' * indent) : ''
|
249
252
|
|
@@ -252,6 +255,7 @@ module XMLhelper
|
|
252
255
|
ind2 = (ind1 and ind1.length > 0) ? ("\n" + ' ' * (indent - 1)) : ''
|
253
256
|
out << "%s</%s>" % [ind2, x.name]
|
254
257
|
else
|
258
|
+
|
255
259
|
out = ["%s<%s/>" % [start, tag]]
|
256
260
|
end
|
257
261
|
|
@@ -259,6 +263,7 @@ module XMLhelper
|
|
259
263
|
elsif x.is_a? String then x.sub(/^[\n\s]+$/,'')
|
260
264
|
elsif x.is_a? Rexle::CData then x.print
|
261
265
|
elsif x.is_a? Rexle::Comment then x.print
|
266
|
+
|
262
267
|
end
|
263
268
|
end
|
264
269
|
|
@@ -289,7 +294,9 @@ class Rexle
|
|
289
294
|
doc_node = ['doc',{}]
|
290
295
|
|
291
296
|
@a = procs[x.class.to_s.to_sym].call(x)
|
297
|
+
#@log.debug 'rexle: before scan_element a: ' + @a.inspect
|
292
298
|
@doc = scan_element(*(doc_node << @a))
|
299
|
+
#@log.debug 'rexle: after scan_element' + self.to_a.inspect
|
293
300
|
|
294
301
|
# fetch the namespaces
|
295
302
|
@prefixes = []
|
@@ -647,7 +654,6 @@ class Rexle
|
|
647
654
|
rtn_element
|
648
655
|
end
|
649
656
|
end
|
650
|
-
#
|
651
657
|
|
652
658
|
rlist = rlist.flatten(1) unless rlist.length > 1 and rlist[0].is_a? Array
|
653
659
|
|
@@ -674,7 +680,7 @@ class Rexle
|
|
674
680
|
def add_element(item)
|
675
681
|
|
676
682
|
if item.is_a? String then
|
677
|
-
@child_elements << item
|
683
|
+
@child_elements << String.new(item)
|
678
684
|
|
679
685
|
elsif item.is_a? Rexle::CData then
|
680
686
|
@child_elements << item
|
@@ -846,7 +852,7 @@ class Rexle
|
|
846
852
|
end
|
847
853
|
|
848
854
|
def value()
|
849
|
-
|
855
|
+
|
850
856
|
r = @child_elements.first
|
851
857
|
return nil unless r.is_a? String
|
852
858
|
|
@@ -882,6 +888,7 @@ class Rexle
|
|
882
888
|
Hash: lambda {|x|
|
883
889
|
o = {pretty: false}.merge(x)
|
884
890
|
msg = o[:pretty] == false ? :doc_print : :doc_pretty_print
|
891
|
+
|
885
892
|
method(msg).call(self.children)
|
886
893
|
},
|
887
894
|
String: lambda {|x|
|
@@ -1214,7 +1221,9 @@ class Rexle
|
|
1214
1221
|
end
|
1215
1222
|
|
1216
1223
|
def text(xpath) @doc.text(xpath) end
|
1217
|
-
def root()
|
1224
|
+
def root()
|
1225
|
+
@doc.elements.first
|
1226
|
+
end
|
1218
1227
|
|
1219
1228
|
def write(f)
|
1220
1229
|
f.write xml
|
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.2.
|
4
|
+
version: 1.2.15
|
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: 2015-02-
|
34
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexleparser
|
metadata.gz.sig
CHANGED
Binary file
|