line-tree 0.8.0 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -5
- data.tar.gz.sig +0 -0
- data/lib/line-tree.rb +84 -17
- metadata +29 -29
- 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: a4941d5015036d351165b5d40866904d2808511e2aff6ae5fbfbc4d05f960ac9
|
4
|
+
data.tar.gz: 8169bc61faade352e4e7541e8edc4acf8e06a0f7cebc9fc833390a9106596faf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 759dce7b2018ea6e914d94b3d3478b2d02e80cb62405d6624e6a3fa5cc81fa28feb2132d9f7e7c59bf85ec0efa66461f88a69980577ef4c02dcf807ff5b67517
|
7
|
+
data.tar.gz: 0d405fb0a21d367f6bd01fde12543f8ed163e54565c03845ba5751647eaeb536d989caa80d0f40e291ed47d9a6ac3cab42797bb506574a2fa3010852a1da868c
|
checksums.yaml.gz.sig
CHANGED
@@ -1,5 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�������2U�����b'sF:б��r�Ie�HE�bEh>R� V=ǿ�[�֓�\�Z� ������3�*��0r�K|��=�[��o���{�D�-�F ��k'�Q���~N�r��
|
4
|
-
���)BH��z=�;��F�*�{~Ǵ����`��},S��09�R��5e��n�6�e���[XqU���<H���j�q/�
|
5
|
-
Xf|SNgm�PR�w
|
1
|
+
��RY�
|
2
|
+
G���"�ΐh{��M���g��Ǫ8��+��ܠP�ˮƨ?�:�������<�uz��������O �����E��Š-�������/QN�eOi��y�L���r6Q��;�� ��?l�����f�V#�b
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/line-tree.rb
CHANGED
@@ -5,6 +5,19 @@
|
|
5
5
|
require 'rexle'
|
6
6
|
|
7
7
|
|
8
|
+
module HashDigx
|
9
|
+
refine Hash do
|
10
|
+
|
11
|
+
def digx( a)
|
12
|
+
|
13
|
+
self.dig a[0], *a[1..-1].flat_map {|x| [:body, x]}
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
8
21
|
class LineTree
|
9
22
|
using ColouredText
|
10
23
|
|
@@ -28,7 +41,7 @@ class LineTree
|
|
28
41
|
|
29
42
|
lines = ignore_blank_lines ? s.gsub(/^ *$\n/,'') : s
|
30
43
|
puts ('lines : ' + lines.inspect).debug if @debug
|
31
|
-
@to_a = scan_shift(lines.
|
44
|
+
@to_a = scan_shift(lines.lstrip, level)
|
32
45
|
|
33
46
|
end
|
34
47
|
|
@@ -53,6 +66,10 @@ class LineTree
|
|
53
66
|
|
54
67
|
end
|
55
68
|
|
69
|
+
def to_h()
|
70
|
+
build_h(@to_a)
|
71
|
+
end
|
72
|
+
|
56
73
|
def to_html(numbered: false)
|
57
74
|
|
58
75
|
@numbered = numbered
|
@@ -62,6 +79,27 @@ class LineTree
|
|
62
79
|
Rexle.new(s).xml declaration: false
|
63
80
|
|
64
81
|
end
|
82
|
+
|
83
|
+
def to_tree()
|
84
|
+
|
85
|
+
def make_tree_list(a)
|
86
|
+
|
87
|
+
items = a.inject([]) do |r,x|
|
88
|
+
|
89
|
+
if x.is_a? Array then
|
90
|
+
r << make_tree_list(x)
|
91
|
+
else
|
92
|
+
r + ['item', {title: x}]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
a = make_tree_list(@to_a)
|
99
|
+
doc = Rexle.new(['tree', {}, *a])
|
100
|
+
doc.xml
|
101
|
+
|
102
|
+
end
|
65
103
|
|
66
104
|
def to_xml(options={})
|
67
105
|
to_doc.xml(options)
|
@@ -69,6 +107,24 @@ class LineTree
|
|
69
107
|
|
70
108
|
private
|
71
109
|
|
110
|
+
def build_h(a)
|
111
|
+
|
112
|
+
a.inject({}) do |r,x|
|
113
|
+
|
114
|
+
h2 = if x.is_a? Array and x.length > 1 then
|
115
|
+
|
116
|
+
{x[0] => {summary: {}, body: build_h(x[1..-1]) } }
|
117
|
+
|
118
|
+
else
|
119
|
+
|
120
|
+
{x[0] => {summary: {}}}
|
121
|
+
end
|
122
|
+
|
123
|
+
r.merge(h2)
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
72
128
|
def encap(a)
|
73
129
|
|
74
130
|
a.each do |node|
|
@@ -152,7 +208,7 @@ class LineTree
|
|
152
208
|
|
153
209
|
puts 'x: ' + x.inspect if @debug
|
154
210
|
|
155
|
-
x.sub!(/ *$/,'')
|
211
|
+
#jr240521 x.sub!(/ *$/,'')
|
156
212
|
|
157
213
|
if @ignore_label == true or not x[/.*/][/^ *\w+:\S+/] then
|
158
214
|
|
@@ -204,17 +260,31 @@ class LineTree
|
|
204
260
|
|
205
261
|
def scan_a(a)
|
206
262
|
|
207
|
-
puts 'a: ' + a.inspect if @debug
|
263
|
+
puts 'a: ' + a.inspect if @debug
|
208
264
|
|
209
265
|
a.each do |node|
|
210
|
-
|
211
|
-
scan_a node[1..-1] if node[1..-1].is_a? Array
|
212
266
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
267
|
+
puts 'node: ' + node.inspect if @debug
|
268
|
+
|
269
|
+
if node.is_a? Array then
|
270
|
+
if node[1].is_a?(Array) and node[1][0] =~ /^<\w+/ then
|
271
|
+
|
272
|
+
r = parse_node(node[0])
|
273
|
+
node[0] = r[0]
|
274
|
+
node[2] = node[1][0]
|
275
|
+
node[1] = r[1]
|
276
|
+
|
277
|
+
else
|
278
|
+
|
279
|
+
scan_a node[1..-1] if node[1..-1].is_a?(Array)
|
280
|
+
|
281
|
+
puts 'node2: ' + node.inspect if @debug
|
282
|
+
|
283
|
+
r = parse_node(node[0])
|
284
|
+
node[0] = r[0]; node.insert 1, r[1], r[2]
|
217
285
|
|
286
|
+
end
|
287
|
+
end
|
218
288
|
end
|
219
289
|
|
220
290
|
if a.first.is_a? String then
|
@@ -226,8 +296,8 @@ class LineTree
|
|
226
296
|
return [nil,non_element] if non_element
|
227
297
|
end
|
228
298
|
|
229
|
-
|
230
|
-
|
299
|
+
r = parse_node(s)
|
300
|
+
a[0] = r[0]; a.insert 1, r[1], r[2]
|
231
301
|
end
|
232
302
|
|
233
303
|
a
|
@@ -237,12 +307,9 @@ class LineTree
|
|
237
307
|
|
238
308
|
def get_attributes(s)
|
239
309
|
|
240
|
-
a = s.
|
241
|
-
|
242
|
-
|
243
|
-
([a-zA-Z0-9\(\);\-\/:\.,\s"'_\{\}\$]*)/).captures
|
244
|
-
[name, val.sub(/['"]$/,'')]
|
245
|
-
end
|
310
|
+
a = s[1..-2].split(/(\w+:)/)[1..-1].each_slice(2).map do |label, val|
|
311
|
+
[label[0..-2], val.strip.sub(/^['"]/,'').sub(/['"]$/,'')]
|
312
|
+
end
|
246
313
|
|
247
314
|
Hash[*a.flatten]
|
248
315
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: line-tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.3
|
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
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwNTI0MTI0ODIxWhcN
|
15
|
+
MjIwNTI0MTI0ODIxWj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E45
|
29
|
+
5he18IG1hbnUQbUiIMxGN336YsLceDdr9sWlOYeD/j0mhu/fWsaOXOrMQOrdLclk
|
30
|
+
62EcS9R419xSjf0PRz4h6hWbNnHcIHXsmZYB72YLe7RkfSf7zNc2Y6/Bl8LToyjd
|
31
|
+
OHZsUhAyWXauitBNWspm+aj75uUeX0YWEcFySnBw2/MavkkrQmy3sslZBjBP3pf5
|
32
|
+
3wcSl64k20wvtigCsFB6TYIMAI2+HBMkobSNSJajZP1TPt48HmcYDMsYfdQzzF72
|
33
|
+
wgaSGvXwxq3FIPeFXk2yfUq7IOTIxHBH3q6ULVtW8NKnc5DckqUtfKbgflitRTd+
|
34
|
+
RtFCP/+DTXiYybQMXhdI3G/0MimLvIoEa7ytR5PvX86J+3abWenqiJ9+KXEqIroz
|
35
|
+
PR3ZcZkDNVXMAWJRegTgs3bTj/TOBz/9wA/ltrJjqU6xHPnNoEe/W5oSQtUywvAh
|
36
|
+
hWGDTAfEg/j8AdkfGnhBG1OK
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2021-05-24 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rexle
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '1.5'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.5.
|
49
|
+
version: 1.5.11
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
version: '1.5'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.5.
|
59
|
+
version: 1.5.11
|
60
60
|
description: Line-tree parses indented lines of text and returns an array representing
|
61
61
|
a tree structure.
|
62
|
-
email:
|
62
|
+
email: digital.robertson@gmail.com
|
63
63
|
executables: []
|
64
64
|
extensions: []
|
65
65
|
extra_rdoc_files: []
|
66
66
|
files:
|
67
67
|
- lib/line-tree.rb
|
68
|
-
homepage:
|
68
|
+
homepage: http://github.com/jrobertson/line-tree
|
69
69
|
licenses:
|
70
70
|
- MIT
|
71
71
|
metadata: {}
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.1.2
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: line-tree
|
metadata.gz.sig
CHANGED
Binary file
|