rowx 0.7.4 → 0.8.0
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/lib/rowx.rb +32 -32
- data.tar.gz.sig +0 -0
- metadata +29 -28
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5b5fb10f2dfdaa035102203287878692974d8e49d7eb58b3e2ca23ef3c48771
|
4
|
+
data.tar.gz: b01ecf96d3d126ac886af1bf9f66ec41244654740039ed8060aaa59c43f989bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1dd96cc15cf5efb1c43cb15f976f553fa6f1f5bd28fcc3e17d215c805be54a629abe99632735158f05521071fa12aeb1c5dfb49c095dbc4c38ad6c78c1990db
|
7
|
+
data.tar.gz: a28b1a65c3188502e5ee8395aabcc18de2f342d3558ff126a5ac2d2814b9b089e0f6498da914ee1989147d392cc4f65c39ec57df06fd865fba33ae25329e2c94
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rowx.rb
CHANGED
@@ -8,15 +8,15 @@ require 'line-tree'
|
|
8
8
|
class RowXException < Exception
|
9
9
|
end
|
10
10
|
|
11
|
-
# for an example of ArrayCollate
|
11
|
+
# for an example of ArrayCollate
|
12
12
|
# see http://www.jamesrobertson.eu/snippets/2014/jun/08/collating-items-in-an-array.html
|
13
13
|
|
14
14
|
module ArrayCollate
|
15
15
|
refine Array do
|
16
16
|
def collate(pattern=nil)
|
17
17
|
a = self.inject([[]]) do |r,x|
|
18
|
-
if block_given? then
|
19
|
-
yield(x) ? r << [x] : r[-1] << x
|
18
|
+
if block_given? then
|
19
|
+
yield(x) ? r << [x] : r[-1] << x
|
20
20
|
else
|
21
21
|
x =~ pattern ? r << [x] : r[-1] << x
|
22
22
|
end # block
|
@@ -24,25 +24,25 @@ module ArrayCollate
|
|
24
24
|
end
|
25
25
|
a.shift if a.first.empty?
|
26
26
|
a
|
27
|
-
end
|
27
|
+
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
class RowX
|
32
|
-
|
32
|
+
|
33
33
|
using ArrayCollate
|
34
|
-
using ColouredText
|
34
|
+
using ColouredText
|
35
35
|
|
36
36
|
attr_reader :to_a, :to_xml, :to_lines
|
37
37
|
|
38
|
-
def initialize(txt, level: nil, ignore_blank_lines: false,
|
39
|
-
abort_1_row: false, debug: false, name: 'item',
|
38
|
+
def initialize(txt, level: nil, ignore_blank_lines: false,
|
39
|
+
abort_1_row: false, debug: false, name: 'item',
|
40
40
|
allow_lonely_keyfield: false)
|
41
|
-
|
41
|
+
|
42
42
|
@name, @debug = name, debug
|
43
|
-
|
44
|
-
# auto indent any multiline values
|
45
|
-
|
43
|
+
|
44
|
+
# auto indent any multiline values
|
45
|
+
|
46
46
|
indent = ''
|
47
47
|
|
48
48
|
lines = txt.gsub(/^-+$/m,'').lines.map do |line|
|
@@ -55,10 +55,10 @@ class RowX
|
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
puts 'lines: ' + lines.inspect if @debug
|
60
60
|
|
61
|
-
a = LineTree.new(lines.join, level: level,
|
61
|
+
a = LineTree.new(lines.join, level: level,
|
62
62
|
ignore_blank_lines: ignore_blank_lines, debug: debug).to_a
|
63
63
|
puts ('a: ' + a.inspect).debug if @debug
|
64
64
|
|
@@ -66,23 +66,23 @@ class RowX
|
|
66
66
|
puts ('keyfield: ' + keyfield.inspect).debug if @debug
|
67
67
|
|
68
68
|
if not allow_lonely_keyfield then
|
69
|
-
|
70
|
-
# find the keyfield. if there's only 1 keyfield in all of the rows it's
|
69
|
+
|
70
|
+
# find the keyfield. if there's only 1 keyfield in all of the rows it's
|
71
71
|
# not a keyfield. Keep searching until all rows have been searched
|
72
72
|
while a.select {|x| x[0][/^#{keyfield}/]}.length <= 1 and \
|
73
73
|
i < a.length and a[i+1]
|
74
|
-
|
74
|
+
|
75
75
|
i += 1
|
76
76
|
keyfield = a[i][0][/\w+/]
|
77
77
|
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
keyfield = a[0][0][/\w+/] if i == a.length - 1
|
83
83
|
|
84
84
|
if a.flatten(1).grep(/^#{keyfield}/).length == 1 then # only 1 record
|
85
|
-
i = 0
|
85
|
+
i = 0
|
86
86
|
raise RowXException, 'Expected more than 1 row' if abort_1_row
|
87
87
|
end
|
88
88
|
|
@@ -90,43 +90,43 @@ class RowX
|
|
90
90
|
|
91
91
|
summary = scan_a a.slice!(0,i)
|
92
92
|
summary[0] = 'summary'
|
93
|
-
|
93
|
+
|
94
94
|
@rexle_a = scan_records(records, level)
|
95
95
|
@to_a = ['root', {}] + [summary] + @rexle_a
|
96
96
|
@to_xml = Rexle.new(@to_a).xml pretty: true
|
97
97
|
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
def to_lines(delimiter: ' # ')
|
101
101
|
@rexle_a.map {|x| x[3..-1].map {|y| y[2]}.join(delimiter)}.join("\n").lines
|
102
102
|
end
|
103
103
|
|
104
104
|
private
|
105
|
-
|
105
|
+
|
106
106
|
|
107
107
|
def scan_a(row)
|
108
108
|
|
109
109
|
a = row.map do |field|
|
110
|
-
|
110
|
+
|
111
111
|
puts 'field: ' + field.inspect if @debug
|
112
112
|
s = field.is_a?(Array) ? field[0] : field
|
113
113
|
|
114
114
|
return if s.empty?
|
115
115
|
puts 's: ' + s.inspect if @debug
|
116
|
-
found = s.match(/^(\w+)(?:\:$|\:\s
|
116
|
+
found = s.match(/^(\w+)(?:\:$|\:\s*)(.*)/m)
|
117
117
|
|
118
|
-
value, name = found ? found.captures.reverse : s
|
118
|
+
value, name = found ? found.captures.reverse : s
|
119
119
|
name ||= 'description'
|
120
|
-
|
121
|
-
children = scan_a(field[1..-1]) if field[-1] .is_a?(Array)
|
122
|
-
value = value.to_s.strip.gsub('<','<').gsub('>','>')
|
120
|
+
|
121
|
+
children = scan_a(field[1..-1]) if field[-1] .is_a?(Array)
|
122
|
+
value = value.to_s.strip.gsub('<','<').gsub('>','>')
|
123
123
|
|
124
124
|
# it's a line which has been commented out?
|
125
125
|
if name[0] == '#' then
|
126
126
|
value = name[1..-1] + ': ' + value
|
127
|
-
name = '!-'
|
127
|
+
name = '!-'
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
result = [name, {}, value]
|
131
131
|
result << children if children
|
132
132
|
result
|
@@ -136,7 +136,7 @@ class RowX
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def scan_records(rows, level)
|
139
|
-
|
139
|
+
|
140
140
|
rows.map {|x| scan_a x }
|
141
141
|
|
142
142
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjAxMjA1NTM4WhcN
|
15
|
+
MjMwMjAxMjA1NTM4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amF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8XMkNtS1Vc4dBm/z8njoAR0FSuE77Br4N5m9VZqiE1
|
30
|
+
8M0Mhd19q3vhnRs/5Jw1sR1Ct+F1FHPTZAF1SJfPepUnlbnR+sClQENs7R7GXEuu
|
31
|
+
KEdbSo9fKidw/ZSPpqb7RZ2ptfEAVsJkuF0Lf/bhpuLvxwdNvC2YpbQwLiEeOAbL
|
32
|
+
pKRxInKqWnabRZHVg59Oxvw6WRBzfS4lF793ut6w05JX7f+9X/4g5/NwKlHh7vbx
|
33
|
+
wusUvr5gPBCocxOnqPbKdOLOWGuHoVe6pKaUFFxVBj2R1dC/ErqNMdj0AxQoSgTi
|
34
|
+
aDvs3bDHPgW1IHO4PWdeXr8KBfTIr1n0qrZ1IF4rNeTiTf4Pqo7x8VrpvNN3sG6/
|
35
|
+
kfXR2KNu3kHN0g9PsBdrL79ctMBurBHn/ATYdhoOG4ebjY2ubJz5nR9sOONJUroJ
|
36
|
+
AB0aDh+E6dzxvdb+vmfSBHJb
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: line-tree
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.9'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.9.
|
49
|
+
version: 0.9.3
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,9 +56,9 @@ dependencies:
|
|
56
56
|
version: '0.9'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.9.
|
59
|
+
version: 0.9.3
|
60
60
|
description: Generates XML from rows of labelled text, nested text, and plain text
|
61
|
-
email:
|
61
|
+
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
@@ -83,7 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.7.10
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: rowx
|
metadata.gz.sig
CHANGED
Binary file
|