rowx 0.6.1 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rowx.rb +23 -15
- metadata +31 -27
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 117e67e111222ae3340f55869da655ee10e6e94f538cef074d70a977f58f522d
|
4
|
+
data.tar.gz: c89eb4d40e0df4f8aea3dbb7214979365f23fd9dfb146e8b961f391863d36c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e1b9ee7c969e217846bc6d9a1e6c896659915e10ff2aaa631b3db1c28d14def8ed2e138ca1701b86fc8cd3246e9dc0b8c73647bf6f0263a9c4f176934022f5
|
7
|
+
data.tar.gz: f7ac382605f8662528d1e27b2936ac7530dec4e96ef852a51435e70dc48b1327fa064c4d9bd868436057d9deb3ca6edacaadfe53794ec1eac3d60310dbbfe318
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rowx.rb
CHANGED
@@ -31,13 +31,15 @@ end
|
|
31
31
|
class RowX
|
32
32
|
|
33
33
|
using ArrayCollate
|
34
|
+
using ColouredText
|
34
35
|
|
35
36
|
attr_reader :to_a, :to_xml, :to_lines
|
36
37
|
|
37
38
|
def initialize(txt, level: nil, ignore_blank_lines: false,
|
38
|
-
abort_1_row: false, debug:
|
39
|
-
|
40
|
-
|
39
|
+
abort_1_row: false, debug: false, name: 'item',
|
40
|
+
allow_lonely_keyfield: false)
|
41
|
+
|
42
|
+
@name, @debug = name, debug
|
41
43
|
|
42
44
|
# auto indent any multiline values
|
43
45
|
|
@@ -58,20 +60,25 @@ class RowX
|
|
58
60
|
|
59
61
|
a = LineTree.new(lines.join, level: level,
|
60
62
|
ignore_blank_lines: ignore_blank_lines, debug: debug).to_a
|
61
|
-
puts 'a: ' + a.inspect if @debug
|
63
|
+
puts ('a: ' + a.inspect).debug if @debug
|
62
64
|
|
63
65
|
keyfield = a[0][0][/\w+:/]; i = 0
|
66
|
+
puts ('keyfield: ' + keyfield.inspect).debug if @debug
|
64
67
|
|
65
|
-
|
66
|
-
# not a keyfield. Keep searching until all rows have been searched
|
67
|
-
while a.select {|x| x[0][/^#{keyfield}/]}.length <= 1 and \
|
68
|
-
i < a.length and a[i+1]
|
68
|
+
if not allow_lonely_keyfield then
|
69
69
|
|
70
|
-
|
71
|
-
keyfield
|
70
|
+
# find the keyfield. if there's only 1 keyfield in all of the rows it's
|
71
|
+
# not a keyfield. Keep searching until all rows have been searched
|
72
|
+
while a.select {|x| x[0][/^#{keyfield}/]}.length <= 1 and \
|
73
|
+
i < a.length and a[i+1]
|
74
|
+
|
75
|
+
i += 1
|
76
|
+
keyfield = a[i][0][/\w+/]
|
72
77
|
|
78
|
+
end
|
79
|
+
|
73
80
|
end
|
74
|
-
|
81
|
+
|
75
82
|
keyfield = a[0][0][/\w+/] if i == a.length - 1
|
76
83
|
|
77
84
|
if a.flatten(1).grep(/^#{keyfield}/).length == 1 then # only 1 record
|
@@ -100,12 +107,13 @@ class RowX
|
|
100
107
|
def scan_a(row)
|
101
108
|
|
102
109
|
a = row.map do |field|
|
103
|
-
|
110
|
+
|
111
|
+
puts 'field: ' + field.inspect if @debug
|
104
112
|
s = field.is_a?(Array) ? field[0] : field
|
105
113
|
|
106
114
|
return if s.empty?
|
107
|
-
|
108
|
-
found = s.match(/^(\w+)
|
115
|
+
puts 's: ' + s.inspect if @debug
|
116
|
+
found = s.match(/^(\w+)(?:\:$|\:\s+)(.*)/m)
|
109
117
|
|
110
118
|
value, name = found ? found.captures.reverse : s
|
111
119
|
name ||= 'description'
|
@@ -124,7 +132,7 @@ class RowX
|
|
124
132
|
result
|
125
133
|
end
|
126
134
|
|
127
|
-
[
|
135
|
+
[@name, {}, '' ] + a
|
128
136
|
end
|
129
137
|
|
130
138
|
def scan_records(rows, level)
|
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.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
+
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAxMDAyMTcwMzA2WhcN
|
15
|
+
MjExMDAyMTcwMzA2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCxdWYo
|
17
|
+
ZJh+h0r6SSXVW4Bn5epCBXzD5ponWVz4Z1njTRsB0b2gSge1JK3Z4XXMhaFqm5jR
|
18
|
+
8/5PUQNiZUNqklf6qY1vz9yF3UdktAZW2yFbFlh1TypMyx733Vr2v8c9RDYBraXb
|
19
|
+
WQEl2Ux2JhM9w0AOm6a0uTCiXhxj9KOJfa9b5FyvWkL9UXgUSb6oz+vOqFUKjv1M
|
20
|
+
FpKSUgaN2jfbggB7VeceH2xZ10MYLG6WwFp3rIEjMltwbBUsZqaZiHM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3RV+ObACeZ/HSFCxStB23EvqS8umVWDkXA3qr3RB
|
36
|
+
yuZ4lODk6vzJbiDVh0MAHLnZ
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2020-10-04 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: line-tree
|
@@ -38,20 +43,20 @@ dependencies:
|
|
38
43
|
requirements:
|
39
44
|
- - "~>"
|
40
45
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0.
|
46
|
+
version: '0.9'
|
42
47
|
- - ">="
|
43
48
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0.
|
49
|
+
version: 0.9.1
|
45
50
|
type: :runtime
|
46
51
|
prerelease: false
|
47
52
|
version_requirements: !ruby/object:Gem::Requirement
|
48
53
|
requirements:
|
49
54
|
- - "~>"
|
50
55
|
- !ruby/object:Gem::Version
|
51
|
-
version: '0.
|
56
|
+
version: '0.9'
|
52
57
|
- - ">="
|
53
58
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
59
|
+
version: 0.9.1
|
55
60
|
description: Generates XML from rows of labelled text, nested text, and plain text
|
56
61
|
email: james@jamesrobertson.eu
|
57
62
|
executables: []
|
@@ -78,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
83
|
- !ruby/object:Gem::Version
|
79
84
|
version: '0'
|
80
85
|
requirements: []
|
81
|
-
|
82
|
-
rubygems_version: 2.6.13
|
86
|
+
rubygems_version: 3.0.3
|
83
87
|
signing_key:
|
84
88
|
specification_version: 4
|
85
89
|
summary: rowx
|
metadata.gz.sig
CHANGED
Binary file
|