dynarex 1.2.11 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dynarex.rb +20 -7
- metadata +1 -1
data/lib/dynarex.rb
CHANGED
@@ -18,7 +18,7 @@ class Dynarex
|
|
18
18
|
|
19
19
|
attr_accessor :format_mask, :delimiter, :xslt_schema, :schema, :order
|
20
20
|
|
21
|
-
def self.gem_url() 'http://www.jamesrobertson.eu/ruby/dynarex#1.2
|
21
|
+
def self.gem_url() 'http://www.jamesrobertson.eu/ruby/dynarex#1.2,12' end
|
22
22
|
|
23
23
|
#Create a new dynarex document from 1 of the following options:
|
24
24
|
#* a local file path
|
@@ -427,12 +427,25 @@ EOF
|
|
427
427
|
i = @doc.root.xpath('max(records/*/attribute::id)').to_i
|
428
428
|
|
429
429
|
raw_summary = schema[/\[([^\]]+)/,1]
|
430
|
-
|
431
|
-
buffer = r if r
|
432
|
-
raw_lines = buffer[/(--\+)?(.*)/m,2].gsub(/^\s*#[^\n]+/,'').gsub(/\n\n/,"\n")\
|
433
|
-
.strip.split(/\r?\n|\r(?!\n)/)
|
430
|
+
rowx = buffer[/--\+.*/m]
|
434
431
|
|
435
|
-
|
432
|
+
buffer = rowx if rowx
|
433
|
+
|
434
|
+
raw_lines = buffer.gsub(/^\s*#[^\n]+/,'').gsub(/\n\n/,"\n")\
|
435
|
+
.strip.split(/\r?\n|\r(?!\n)/)
|
436
|
+
|
437
|
+
if @order == 'descending' then
|
438
|
+
rl = raw_lines
|
439
|
+
|
440
|
+
if rowx then
|
441
|
+
raw_lines = [rl[0]] + rl[1..-1].each_slice(@fields.count).inject([])\
|
442
|
+
{|r,x| r += x.reverse }.reverse
|
443
|
+
else
|
444
|
+
raw_lines = rl.each_slice(@fields.count).inject([])\
|
445
|
+
{|r,x| r += x.reverse }.reverse
|
446
|
+
end
|
447
|
+
|
448
|
+
end
|
436
449
|
|
437
450
|
if raw_summary then
|
438
451
|
a_summary = raw_summary.split(',').map(&:strip)
|
@@ -490,7 +503,7 @@ EOF
|
|
490
503
|
end
|
491
504
|
|
492
505
|
end
|
493
|
-
|
506
|
+
|
494
507
|
a = lines.map do|x|
|
495
508
|
created = Time.now.to_s
|
496
509
|
h = Hash[@fields.zip(x.map{|t| t.to_s[/^---/] ? YAML.load(t) : t})]
|