rowx 0.2.0 → 0.2.1

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: f93adb314b0342845b4c07f7bb40bca6149fd2b0
4
- data.tar.gz: a6f91f9b765d5e815cfa31e861dd4afc66fedc1f
3
+ metadata.gz: 32439468aa45edff5931a95a57471a88c4e7d23a
4
+ data.tar.gz: badee3d8c712f222dacd1cc7b2bc445fd8b4efd5
5
5
  SHA512:
6
- metadata.gz: 034941df6ec751a12e7e3a62e28190f978628acb84ad76392085444e4d081f2f3d6f5d9d39868661c1e7162eff39ab3f7e6ec71b1c88d0b74f808da67e0316a7
7
- data.tar.gz: 95d004a9f2f71966a985c417f6d91f8980b5821a22afcef348d85b204a7a2a3a21cdc930e993876778166cc8a2efaa2d0ec33d53a4a80b25283d761998129bd9
6
+ metadata.gz: b3d4d713e6349d784b39dd110b26d848ca648e1deae7e75e07aaaf9243dbafc9b90589ffd121bfee50f41fe4fc30926a0e6ed6d6d0a911851948579cbecabb21
7
+ data.tar.gz: a6325581ebc8ef3df217bab08c94bb8dc751f0087891446a1caad26ef278da8eb86b2d2a31c75b537b2af88769f061aa7f9386d38d9f892b28d451e14fe305a8
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/rowx.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  require 'line-tree'
6
6
  require 'rexle'
7
7
 
8
- class Array
8
+ lass Array
9
9
  def collate(pattern=nil)
10
10
  a = self.inject([[]]) do |r,x|
11
11
  if block_given? then
@@ -24,10 +24,10 @@ class RowX
24
24
 
25
25
  attr_reader :to_a, :to_xml
26
26
 
27
- def initialize(txt)
27
+ def initialize(txt, level: nil)
28
+
29
+ a = LineTree.new(txt.gsub(/^-*$/m,''), level: level).to_a
28
30
 
29
- a = LineTree.new(txt.gsub(/^-*$/m,'')).to_a
30
-
31
31
  keyfield = a[0][0][/\w+/]; i = 0
32
32
 
33
33
  while a.select {|x| x[0][/#{keyfield}/]}.length <= 1 and i < a.length
@@ -40,12 +40,13 @@ class RowX
40
40
  summary = scan_a a.slice!(0,i)
41
41
 
42
42
  summary[0] = 'summary'
43
- @to_a = ['root', '', {}] + [summary] + scan_records(records)
43
+ @to_a = ['root', '', {}] + [summary] + scan_records(records, level)
44
44
  @to_xml = Rexle.new(@to_a).xml pretty: true
45
45
 
46
46
  end
47
47
 
48
48
  private
49
+
49
50
 
50
51
  def scan_a(row)
51
52
 
@@ -67,13 +68,10 @@ class RowX
67
68
  ['item', '', {}] + a
68
69
  end
69
70
 
70
- def scan_records(row)
71
+ def scan_records(row, level)
71
72
 
72
- row.map do |x|
73
-
74
- x.map! {|y| y.length <= 1 ? y : y.join("\n")}
75
- scan_a x
76
- end
73
+ row.map {|x| scan_a x }
74
+
77
75
  end
78
76
 
79
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rowx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  yaP43m5g1gqUfr6ys6w86uiM1Khmw6RXdAZBrQU+jmXYRU0OejB3+MdhPte5gP6n
32
32
  k3UhzyiVjlkLhQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-11-05 00:00:00.000000000 Z
34
+ date: 2014-11-06 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: line-tree
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- 1FAV����fcHσ��R�W[|�7���W}�< 䲑\4K��FNu�� p�<Jh���������O�jq޺3��<��1�����a|��!?naÎcv)���)4抸H?>��ڱ�d��h�D!��{���f���]����tY��� pj�.R�O��p 1�a����(i;�O(�}�K��\�}�ۮY�¥����ܰ35o��Tsi�HY������B��+��nc���e�`�b�
1
+ '��U/촡#p��<��;�����ץ��N��ӫ-y{���oOd�}��'y3���)�y��o��g������;U5�bS�opLQ��%�[������r;q��� +��m&K��3�M�6C,�8yj���������G����$aԝakH�k9
2
+ >�b+l�