polyrex 1.0.14 → 1.0.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/polyrex.rb +25 -17
- metadata +1 -1
- 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: 972596a01d30af3f37c3e941ed4f0032ec504af7
|
4
|
+
data.tar.gz: d442512d6460ae5130ec8d902d16a7d3455e3a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f91bbd86e5562604e6387f5b975a3805fb3c52d726ade138809f5c2bdd5eb48200632e6d73f733e96c45246f3bc7caecfd0695aa18f99b9fcdddd048f1a947
|
7
|
+
data.tar.gz: a9393a80decff4fdc5b3abd846847ad5cadb01e254a6e8d2ac1b652bdb94c64e02c3148c28faa8f66ed48885785ae1e7c41d3257e43633d4249a96b0c2d73533
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/polyrex.rb
CHANGED
@@ -80,10 +80,13 @@ class Polyrex
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def create(id: nil)
|
83
|
-
|
83
|
+
|
84
|
+
# @create is a PolyrexCreateObject,
|
85
|
+
# @parent_node is a Rexle::Element pointing to the current record
|
84
86
|
|
85
87
|
@create.id = id || @id_counter
|
86
|
-
@create.record = @parent_node.name == 'records' ?
|
88
|
+
@create.record = @parent_node.name == 'records' ? \
|
89
|
+
@parent_node.root : @parent_node.root.element('records')
|
87
90
|
@create
|
88
91
|
end
|
89
92
|
|
@@ -205,7 +208,8 @@ class Polyrex
|
|
205
208
|
|
206
209
|
openx(s)
|
207
210
|
|
208
|
-
summary_h = Hash[*@doc.root.xpath("summary/*")
|
211
|
+
summary_h = Hash[*@doc.root.xpath("summary/*").\
|
212
|
+
map {|x| [x.name, x.text.to_s]}.flatten]
|
209
213
|
|
210
214
|
@summary = RecordX.new summary_h
|
211
215
|
@summary_fields = summary_h.keys.map(&:to_sym)
|
@@ -245,7 +249,10 @@ class Polyrex
|
|
245
249
|
line = format_mask.gsub(/\[![^\]]+\]/){|x| summary.text(x[2..-2]).to_s}
|
246
250
|
|
247
251
|
records = item.element('records').elements.to_a
|
248
|
-
|
252
|
+
|
253
|
+
if records.length > 0 then
|
254
|
+
line = line + "\n" + build(records, indent + 1).join("\n")
|
255
|
+
end
|
249
256
|
(' ' * indent) + line
|
250
257
|
end
|
251
258
|
end
|
@@ -378,7 +385,8 @@ EOF
|
|
378
385
|
summary = ''
|
379
386
|
if @format_masks.length == @recordx.length then
|
380
387
|
root_format_mask = @format_masks.shift
|
381
|
-
field_names = root_format_mask.to_s.scan(/\[!(\w+)\]/)
|
388
|
+
field_names = root_format_mask.to_s.scan(/\[!(\w+)\]/).\
|
389
|
+
flatten.map(&:to_sym)
|
382
390
|
summary = field_names.map {|x| "<%s/>" % x}.join
|
383
391
|
end
|
384
392
|
|
@@ -389,27 +397,26 @@ EOF
|
|
389
397
|
@id_counter = '0'
|
390
398
|
|
391
399
|
root_name = @recordx.shift
|
392
|
-
("<%s><summary>%s</summary><records/></%s>" %
|
400
|
+
("<%s><summary>%s</summary><records/></%s>" % \
|
401
|
+
[root_name, (summary || '') , root_name])
|
393
402
|
|
394
403
|
end
|
395
404
|
|
396
405
|
def recordx_map(node)
|
406
|
+
|
397
407
|
# get the summary
|
398
|
-
|
399
|
-
|
400
|
-
# get the fields
|
401
|
-
fields = summary.elements.map do |x|
|
408
|
+
fields = node.xpath('summary/*').map do |x|
|
402
409
|
next if %w(schema format_mask recordx_type).include? x.name
|
403
|
-
r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text.to_s :
|
404
|
-
|
410
|
+
r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text.to_s : \
|
411
|
+
x.cdatas.join.strip
|
412
|
+
r
|
405
413
|
end
|
406
414
|
|
407
415
|
# get the records
|
408
|
-
|
409
|
-
a = records.elements.map {|x| recordx_map x}
|
416
|
+
a = node.xpath('records/*').map {|x| recordx_map x}
|
410
417
|
|
411
|
-
[fields, a]
|
412
|
-
end
|
418
|
+
[fields.compact, a]
|
419
|
+
end
|
413
420
|
|
414
421
|
def string_parse(buffer, options={})
|
415
422
|
|
@@ -686,7 +693,8 @@ EOF
|
|
686
693
|
methodx = a.map do |class_name, methods|
|
687
694
|
class_name.downcase!
|
688
695
|
methods.map do |method_name|
|
689
|
-
xpath = %Q(@doc.root.element("//%s[summary/%s='\#\{val\}']")) %
|
696
|
+
xpath = %Q(@doc.root.element("//%s[summary/%s='\#\{val\}']")) % \
|
697
|
+
[class_name, method_name]
|
690
698
|
"def find_by_#{class_name}_#{method_name}(val)
|
691
699
|
|
692
700
|
node = #{xpath}
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|