rowx 0.5.3 → 0.7.1

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 -10
  5. metadata +32 -29
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2cebc3a1e2f709f929e4ce360b246f963026577a
4
- data.tar.gz: a53a1527e32a11c97a724ddd2a1f00fcf2d728d0
2
+ SHA256:
3
+ metadata.gz: 74037593b0b1eaf8f492f145e001f7f753742f4f424aabb0410642aab03875d5
4
+ data.tar.gz: d38b57838c540f38db32f247ea2ef4e48a89763f84e8b22615cedddbda3fb134
5
5
  SHA512:
6
- metadata.gz: 0ba99a0d6234cf7071c8d4ffac46aff5a8ab778fbb059d16c7b706ab164c099af16470c6c5fcdb3568e028b2963804037e23377d301f1dcfb16f379387ec7f6e
7
- data.tar.gz: c116ab24ed52844d89d8d46a7f90626d2bfb3c5b1644ac373ac6298baf60207554d12fef6b4b7ae77924c96475b739c6e57c5f2e28fb87b07ef3cd90cca38e00
6
+ metadata.gz: 551c5e87c50b589c64b695b864b728f458a88b36c176b0684f0807061a25de0397af42c8ef34f29d9f4bf8ab868589aea35bf1e90d483f195d4ebc16ad9f9958
7
+ data.tar.gz: beb033c4d8c7d3d37f2785890963057c57d3f6d550299d50dc62b24e9fdbc3c8410c96d60389da1c01819bd20ad8ec6fa3b59857ba8d53665e74c7aa51cba2da
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -5,6 +5,9 @@
5
5
  require 'line-tree'
6
6
 
7
7
 
8
+ class RowXException < Exception
9
+ end
10
+
8
11
  # for an example of ArrayCollate
9
12
  # see http://www.jamesrobertson.eu/snippets/2014/jun/08/collating-items-in-an-array.html
10
13
 
@@ -28,10 +31,14 @@ end
28
31
  class RowX
29
32
 
30
33
  using ArrayCollate
34
+ using ColouredText
31
35
 
32
36
  attr_reader :to_a, :to_xml, :to_lines
33
37
 
34
- def initialize(txt, level: nil)
38
+ def initialize(txt, level: nil, ignore_blank_lines: false,
39
+ abort_1_row: false, debug: false, name: 'item')
40
+
41
+ @name, @debug = name, debug
35
42
 
36
43
  # auto indent any multiline values
37
44
 
@@ -39,17 +46,20 @@ class RowX
39
46
 
40
47
  lines = txt.gsub(/^-+$/m,'').lines.map do |line|
41
48
 
42
- if not line[/^\s*\w+:|^\s+/] then
49
+ if not line[/^ *\w+:|^ +/] then
43
50
  indent + ' ' + line
44
51
  else
45
- indent = line[/^\s+/] || ''
52
+ indent = line[/^ +/] || ''
46
53
  line
47
54
  end
48
55
 
49
56
  end
57
+
58
+ puts 'lines: ' + lines.inspect if @debug
50
59
 
51
- a = LineTree.new(lines.join, level: level, ignore_blank_lines: false).to_a
52
-
60
+ a = LineTree.new(lines.join, level: level,
61
+ ignore_blank_lines: ignore_blank_lines, debug: debug).to_a
62
+ puts ('a: ' + a.inspect).debug if @debug
53
63
 
54
64
  keyfield = a[0][0][/\w+:/]; i = 0
55
65
 
@@ -65,11 +75,14 @@ class RowX
65
75
 
66
76
  keyfield = a[0][0][/\w+/] if i == a.length - 1
67
77
 
68
- i = 0 if a.flatten(1).grep(/^#{keyfield}/).length == 1 # only 1 record
78
+ if a.flatten(1).grep(/^#{keyfield}/).length == 1 then # only 1 record
79
+ i = 0
80
+ raise RowXException, 'Expected more than 1 row' if abort_1_row
81
+ end
82
+
69
83
  records = a[i..-1].collate { |x| x.first =~ /^#{keyfield }/ }
70
84
 
71
85
  summary = scan_a a.slice!(0,i)
72
-
73
86
  summary[0] = 'summary'
74
87
 
75
88
  @rexle_a = scan_records(records, level)
@@ -93,7 +106,7 @@ class RowX
93
106
 
94
107
  return if s.empty?
95
108
 
96
- found = s.match(/^(\w+):\s*(.*)/m)
109
+ found = s.match(/^(\w+):\s+(.*)/m)
97
110
 
98
111
  value, name = found ? found.captures.reverse : s
99
112
  name ||= 'description'
@@ -112,7 +125,7 @@ class RowX
112
125
  result
113
126
  end
114
127
 
115
- ['item', {}, '' ] + a
128
+ [@name, {}, '' ] + a
116
129
  end
117
130
 
118
131
  def scan_records(rows, level)
@@ -121,4 +134,4 @@ class RowX
121
134
 
122
135
  end
123
136
 
124
- end
137
+ 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.5.3
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MDEwODE3MTM0MloXDTE4MDEwODE3MTM0MlowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAOVxinGj0hGcz+aRrzfEAWWVV94OJrhxzgqNoaqLkmdMp7O4oS/taHFNF4h3
19
- m8cyuKxdXQvksf/1VcR5oyWAnNKzB6LPrSyAB9nr/b6+6iOCaJ/PlyDZnxHZioTl
20
- Ea+43PE1FR28l+Z0q9YOW85xN4XnC+QwhwG/F9g47IFU5lXb0AtJekMKfyfT5ykP
21
- Zs1gVSOm8hHuUpXnBQRh8mCATOzAZshqUKGDDi3CuS9kJaCbszKxvU72RWeh+3sL
22
- FDFsP0fBIndSWvu/2xoiY8PjqtKWxcLZYsnhZ5S1XTPB0vXwaZdUnWQHOakQwEhC
23
- yMskyxOo5eS0qwfquKn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h2vzyXZNb
35
+ 800/1OqpheFJ2kxsgvkGfxh/3RV+ObACeZ/HSFCxStB23EvqS8umVWDkXA3qr3RB
36
+ yuZ4lODk6vzJbiDVh0MAHLnZ
33
37
  -----END CERTIFICATE-----
34
- date: 2017-03-05 00:00:00.000000000 Z
38
+ date: 2020-10-02 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: line-tree
@@ -39,21 +43,21 @@ dependencies:
39
43
  requirements:
40
44
  - - "~>"
41
45
  - !ruby/object:Gem::Version
42
- version: '0.5'
46
+ version: '0.9'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 0.5.6
49
+ version: 0.9.1
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
49
53
  requirements:
50
54
  - - "~>"
51
55
  - !ruby/object:Gem::Version
52
- version: '0.5'
56
+ version: '0.9'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 0.5.6
56
- description: Generates XML from rows of labelled text, nested text, and plain text
59
+ version: 0.9.1
60
+ description: Generates XML from rows of labelled text, nested text, and plain text
57
61
  email: james@jamesrobertson.eu
58
62
  executables: []
59
63
  extensions: []
@@ -79,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
83
  - !ruby/object:Gem::Version
80
84
  version: '0'
81
85
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.6.8
86
+ rubygems_version: 3.0.3
84
87
  signing_key:
85
88
  specification_version: 4
86
89
  summary: rowx
metadata.gz.sig CHANGED
Binary file