line-tree 0.9.2 → 0.9.4
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 +0 -0
- data/lib/line-tree.rb +63 -4
- data.tar.gz.sig +0 -0
- metadata +30 -30
- 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: 9c851dd296720238d1bab5e87773fea3e7443c094113a496cf2f9029063cfb49
|
4
|
+
data.tar.gz: 7f63878999b0b4b6c6bfd7c5cead345caf850d1dcfb5e4130a3e865fbecc1cac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49b75a3091fc00f633ba78a1a0fdb4413e0ee48ceb3b24ac1ba61d6a4f34ceb1927be408fedf4ab48b6db8b8c37eddf8deada81b7a94152909b836e1a5e570a7
|
7
|
+
data.tar.gz: 228e3a7034b8cc7d33a1b09c76b21e4498f4f819760203eb5bbcfa9f95ce63d249c144c4d7f47eaf4708c383661528fbb14a147e796142efa75eb0d8449a94d6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/line-tree.rb
CHANGED
@@ -20,8 +20,6 @@ end
|
|
20
20
|
|
21
21
|
class LineTree
|
22
22
|
using ColouredText
|
23
|
-
|
24
|
-
attr_reader :to_a
|
25
23
|
|
26
24
|
def initialize(raw_s, level: nil, ignore_non_element: true,
|
27
25
|
ignore_blank_lines: true, ignore_label: false,
|
@@ -41,10 +39,14 @@ class LineTree
|
|
41
39
|
|
42
40
|
lines = ignore_blank_lines ? s.gsub(/^ *$\n/,'') : s
|
43
41
|
puts ('lines : ' + lines.inspect).debug if @debug
|
44
|
-
@to_a = scan_shift(lines.
|
42
|
+
@to_a = scan_shift(lines.lstrip, level)
|
45
43
|
|
46
44
|
end
|
47
45
|
|
46
|
+
def to_a(normalize: false)
|
47
|
+
normalize ? norm(@to_a) : @to_a
|
48
|
+
end
|
49
|
+
|
48
50
|
def to_doc(encapsulate: false)
|
49
51
|
|
50
52
|
a = @to_a
|
@@ -79,6 +81,39 @@ class LineTree
|
|
79
81
|
Rexle.new(s).xml declaration: false
|
80
82
|
|
81
83
|
end
|
84
|
+
|
85
|
+
# key–value pair returns Hash object describing a
|
86
|
+
# flat representation of a tree
|
87
|
+
#
|
88
|
+
def to_kv_pair
|
89
|
+
|
90
|
+
def scan2keypair(h, trail=nil)
|
91
|
+
|
92
|
+
h.inject([]) do |r,x|
|
93
|
+
|
94
|
+
if x.last.is_a? String then
|
95
|
+
|
96
|
+
key, val = x
|
97
|
+
|
98
|
+
new_key = if r.last and r.last.first.length > 0 then
|
99
|
+
key.to_s
|
100
|
+
else
|
101
|
+
key.to_s
|
102
|
+
end
|
103
|
+
r << [[trail, new_key].compact.join('/'), val]
|
104
|
+
else
|
105
|
+
new_key = x.first.to_s
|
106
|
+
r << [new_key, x.last.first]
|
107
|
+
r.concat scan2keypair(x.last.last, [trail, new_key].compact.join('/'))
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
scan2keypair(self.to_h).to_h
|
115
|
+
|
116
|
+
end
|
82
117
|
|
83
118
|
def to_tree()
|
84
119
|
|
@@ -194,6 +229,30 @@ class LineTree
|
|
194
229
|
|
195
230
|
end
|
196
231
|
|
232
|
+
# Improves readability by removing unnecessary brackets from an Array row.
|
233
|
+
# Thus making it a String when there are no children.
|
234
|
+
#
|
235
|
+
def norm(a)
|
236
|
+
|
237
|
+
a.map do |x|
|
238
|
+
|
239
|
+
if x.is_a? Array then
|
240
|
+
|
241
|
+
if x.length < 2 then
|
242
|
+
x.first
|
243
|
+
else
|
244
|
+
row = norm(x[1..-1])
|
245
|
+
[x.first, row]
|
246
|
+
end
|
247
|
+
|
248
|
+
else
|
249
|
+
x
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
|
197
256
|
|
198
257
|
def scan_shift(lines, level=nil)
|
199
258
|
|
@@ -208,7 +267,7 @@ class LineTree
|
|
208
267
|
|
209
268
|
puts 'x: ' + x.inspect if @debug
|
210
269
|
|
211
|
-
x.sub!(/ *$/,'')
|
270
|
+
#jr240521 x.sub!(/ *$/,'')
|
212
271
|
|
213
272
|
if @ignore_label == true or not x[/.*/][/^ *\w+:\S+/] then
|
214
273
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,32 +10,33 @@ 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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTIyMDkxOTE4NTAyNFoXDTIzMDkxOTE4NTAyNFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIh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ZH3iUR0C4c+Js3SxETcLtb/Tmm8eIIp/TZJ4DYYRqVlxalL4gUwe6Kx
|
33
|
+
nnnWvZRuC/gLf39DwaGPlOsS5CkdzcDjY0xYzMbnyJ1PakT45P03bQE3vo3uvrp0
|
34
|
+
VAkB38cUXGgk86qi7RozTrJgr8bMkrjdlAgDiiHLMJ0K0oIkf5cadgarYvbmQ1nX
|
35
|
+
iXjhjSXYck8mrCCYrsDy9Cz/WCR/LmuOCn0QwL4VMDyfeaozAFME/rO5jNCPPOvg
|
36
|
+
C5EdQTQBDv+/PxpfNRw9c/rDC44+fVecf9eUtJtfP2oliL7q8SlpE2Bt9D1H/ePQ
|
37
|
+
diGSVRnIxA91BeBOGkt0dmzMPFRHD4+TvtM=
|
37
38
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
39
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
39
40
|
dependencies:
|
40
41
|
- !ruby/object:Gem::Dependency
|
41
42
|
name: rexle
|
@@ -46,7 +47,7 @@ dependencies:
|
|
46
47
|
version: '1.5'
|
47
48
|
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.5.
|
50
|
+
version: 1.5.14
|
50
51
|
type: :runtime
|
51
52
|
prerelease: false
|
52
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,7 +57,7 @@ dependencies:
|
|
56
57
|
version: '1.5'
|
57
58
|
- - ">="
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.5.
|
60
|
+
version: 1.5.14
|
60
61
|
description: Line-tree parses indented lines of text and returns an array representing
|
61
62
|
a tree structure.
|
62
63
|
email: digital.robertson@gmail.com
|
@@ -84,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '0'
|
86
87
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.7.10
|
88
|
+
rubygems_version: 3.3.7
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: line-tree
|
metadata.gz.sig
CHANGED
Binary file
|