rowx 0.5.4 → 0.7.2

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 +2 -5
  3. data.tar.gz.sig +0 -0
  4. data/lib/rowx.rb +21 -8
  5. metadata +32 -29
  6. metadata.gz.sig +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fb0bb50bccd3eaa034e7167d59d0fc239ec688ee
4
- data.tar.gz: 73d3b1d51b278d60a8d0f80e1da9033951b9a96e
2
+ SHA256:
3
+ metadata.gz: 1517ea490ea6a6051ccd5bc0cecf01b07bfd0d20fbc5656f566bdaf7ef8005aa
4
+ data.tar.gz: bab6c43c96dd8baf5d28c941827eb68f65f850dee95143276d8eaddc1b63cb39
5
5
  SHA512:
6
- metadata.gz: c543a16cd5a8b2b7662f8488fc2b36ae603644540e2d875f69147d04389cb7038132fd8dedecba1e9f51f850e54e24ffe29e54566eb60c9b8da9a640bfe90688
7
- data.tar.gz: 6bfa79d8da64b6d64d415f76dec9160f3687b00c3f1131b03863f880b63f7079656363b0db91ddcaebe7a18e9232b5534975e4146affe25647a04d1596f65ae7
6
+ metadata.gz: 2098a609dc4edd3dbb7a0f234bd8cb0a93b75848545b53e587d1e7ede4940b3b72aff3d9215becbc4b83658652f1210c649167fe3534d963ed9da8811b741979
7
+ data.tar.gz: 5c5fb7a7d562c9c90ce6062eb411599e694193d8e3a231d142561912fdebebf92963192a9a3d1fd16d38311d87d4e114e5378786ef8f7abb3da2a33c5a3718b6
@@ -1,5 +1,2 @@
1
- ��_��y.�
2
- l1 `L��/�+F;�u��(��WVL��q�]���̳)H
3
- ��*�ǫJ��׺��;�]tM�Vi�l���D2�A5w� =��{Ϣ��ocv�����#�G
4
- �o������n]+��b�RS�ƫ UT���ߘ����b2�WJ zuCo� "�^�j��֤�1�,��YxX��B���ptu��� ��ș����Ԛ���z��P��P��/C��q�hN��_IP��X�Gh��.z���|����
5
- ��0
1
+ O��Վ��21J��:&ב�򦌢�7-���{����6���)�L�!���`ز��q�H>��!) ������sw�gah.�<�z�U�W��$
2
+ �����l���scI˓�9��$�6:���,��ѻ��q����(��I ��y�b`Pl��G3!�?G������B5��]���N���e���t�;�J$i`�)l����ϾS t�%F�U�Tm��&WB�1�3����t� H��ް��X:Z����5�y �=ͦ�1���KHިX��0Z2�=�0�bH����U.��V��e}��Z�q�z'9����}�����r�<Pr7�k��ՓH+�3�~�+�|�l��q�ڪe����E���g (n��$ζ$F�>�
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
 
@@ -47,9 +54,12 @@ class RowX
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*|\n)(.*)/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.4
4
+ version: 0.7.2
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
- ggEBAOVxinGj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85fIu
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
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
@@ -1,4 +1,5 @@
1
- ��V�hc
2
-
3
- �:�^֚srT��9��b�ώ��5���Vb�Rb��f��h�IH��Q�F�$C[-�<f
4
- ]P!,$�#@s=pv����Sb�����]/�Y1
1
+ �["n�����~ ���
2
+ ��/�z�W>�W�������A�Z�*�iED&�x-���w8�c�D�_��� ���Z���U}�.��c~^��"#%���ƌ��o���3����k���ߋ� ����ct�#'�c���m!�ձv���dsT.�=�_��Q[��y
3
+ ZR
4
+ c�];�׋"��*��[2Iz����-jy�憇#JFRW�M��LH��O���R��H�l� 2(U%�$�5��y�Q��6��U^i��q�ku�E���a*��%�n��lB�
5
+ }�Z�\�b�$VY�{nu�q͂��,P�-�X�#}�ũ����u�$�ǻ��ޛ�+{�'={u!��3��q�.�H%/