rowx 0.6.1 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/rowx.rb +23 -15
  5. metadata +31 -27
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d6559de84d94fde4feb2822a5a105dec56fadb50
4
- data.tar.gz: f2cb9d31779c117cd31531b87cc14155b04152cf
2
+ SHA256:
3
+ metadata.gz: 117e67e111222ae3340f55869da655ee10e6e94f538cef074d70a977f58f522d
4
+ data.tar.gz: c89eb4d40e0df4f8aea3dbb7214979365f23fd9dfb146e8b961f391863d36c17
5
5
  SHA512:
6
- metadata.gz: e5ae79e85b8563c27029fd29db84fde20eb93dda5c1afa3cd287e9a3605a4f90413beb1f64e8c19885a0dd800d3eb8d9999fc2a94b7f5a0fa190d570174a764b
7
- data.tar.gz: 37203ff377d20ecfa77eab61b4e86585d2a2f1cf063f2cf258bd430400086df63a4f406d4196cdea9fc444ff0b4ea9ab35a7b718c9b9362290107c9b5a3f5832
6
+ metadata.gz: d4e1b9ee7c969e217846bc6d9a1e6c896659915e10ff2aaa631b3db1c28d14def8ed2e138ca1701b86fc8cd3246e9dc0b8c73647bf6f0263a9c4f176934022f5
7
+ data.tar.gz: f7ac382605f8662528d1e27b2936ac7530dec4e96ef852a51435e70dc48b1327fa064c4d9bd868436057d9deb3ca6edacaadfe53794ec1eac3d60310dbbfe318
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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: true)
39
-
40
- @debug = debug
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
- # find the keyfield. if there's only 1 keyfield in all of the rows it's
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
- i += 1
71
- keyfield = a[i][0][/\w+/]
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+):\s*(.*)/m)
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
- ['item', {}, '' ] + a
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.6.1
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
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwODAxMTk0NTAzWhcN
15
- MTkwODAxMTk0NTAzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQZ1fv
17
- UYGzw3Of4/QX27BNJ3jayY5CMqoR+UyYKFyfqVTmRxHFJ3g2npuJkqcLvSWGpQSB
18
- dkbOuUZHb7wsxa/HRC3UoX9nNQ8V5GtoVkMLtyriBRbCQkx8n4ShbbB+Fh0sbO5r
19
- +SbGABrrzQcMuiazmoAPqEp0MsUrK7OcVc3wDJCIw4Hx1TSU5AiFg5jaVcLdN5fo
20
- OG/eS+c4qelHDJJ9YnHVNTtUNmRkdepoDfyaSbpdG8Lm4WIf5s7ifnA3KXRhppeg
21
- Z4WTad5AFx/u2A5e8/gCuXuNItqM6K6XCAcsMDVdKWkEAIv8Ywl+hmBe5cH2vfBI
22
- psJBpE9DeIlzhLxpAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
- HQYDVR0OBBYEFANcDiEA6+Q+A4X6HmY2LIdpcjxQMCYGA1UdEQQfMB2BG2dlbW1h
24
- c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0Z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b4S7o5AhOErZWY/D0DupIv/IasgYtPSCQ92JihIjx4WSn3ID
23
+ iW4GIUjEyOL0PJBYA3yn4NjcVw2sBrduX1kdS/aewIjsBMRpifdSE448tX1bnAWb
24
+ vcb/8eW2FCuuTBTXCVegl5JbpXcqT1ekEIEQ/y9f5vo3ZQ7QZFq0cICL8jMCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU769EL4hV
26
+ j15lovTy15PCT9yowcAwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEAamu6TUzgQljUfB2b/5AQ4uSX9hLSuABIaaOCp7dC
29
+ 6+50s7KPGO8OnFMg4dNh9owERjwy05ad5UditqQssYn4v3i7rAgGFMpajgV85fIu
30
+ Yk4HeZpwGT0Rh0puJX+lVcY4H+/0v/ilv6PQN1mnB+wdHp/wh4DcAbKoVntrVMKY
31
+ uSD00z/OGvu8Wt8cDoKKsvRx/M8+BA8Jh0d9rAbbD1wJxdO3dhr+xPe69rpzVQ0k
32
+ hHrQ2eQ6j5QceP2EbQAME42Sd+CIP8xT4HeAsUJWTqHGs0kiJvomHUTGe+JzBfke
33
+ CiKEYV1eq9T4rPX7hh9g+fvj66W5e/gJ6O+3fskNhzvP/lrnXPVs8ourOYI7Uoml
34
+ rP6fc4AahiTW5g9Yd93IIwivGQ1oRMfU15qn8AbxqV8hfbg8l8TqvJlh2vzyXZNb
35
+ 800/1OqpheFJ2kxsgvkGfxh/3RV+ObACeZ/HSFCxStB23EvqS8umVWDkXA3qr3RB
36
+ yuZ4lODk6vzJbiDVh0MAHLnZ
32
37
  -----END CERTIFICATE-----
33
- date: 2018-08-01 00:00:00.000000000 Z
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.6'
46
+ version: '0.9'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 0.6.10
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.6'
56
+ version: '0.9'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 0.6.10
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
- rubyforge_project:
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