line-tree 0.3.22 → 0.4.0
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 +18 -3
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ab54108743428550e162b237c57d3f5f3ebd04
|
4
|
+
data.tar.gz: e24bd36af28eac887fcfe7bf2d13c7eaa8e546ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb799969d60bfbebeb2e7b36e731db81334960d3e87ab3a5cf273091740c3f8d9ec2167ca6f5cb4ec0ed5498651ecac9cf2f485e3f04086d3b1dd939a19a9fe4
|
7
|
+
data.tar.gz: 95f8c929e6b1e53f0c98427a5d3e7e001cf567afcd810c6b02e610e90d623dc29ac7cfee6129362872e08a5e6ef819eb799d217daee13095f79260947685d882
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/line-tree.rb
CHANGED
@@ -8,12 +8,14 @@ class LineTree
|
|
8
8
|
|
9
9
|
attr_reader :to_a
|
10
10
|
|
11
|
-
def initialize(lines) @to_a = scan_shift(lines.strip) end
|
11
|
+
def initialize(lines, level: nil) @to_a = scan_shift(lines.strip, level) end
|
12
12
|
def to_xml(options={}) Rexle.new(scan_a(*@to_a)).xml(options) end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def scan_shift(lines)
|
16
|
+
def scan_shift(lines, level=nil)
|
17
|
+
|
18
|
+
level -= 1 if level
|
17
19
|
|
18
20
|
a = lines.split(/(?=^\S+)/)
|
19
21
|
|
@@ -25,7 +27,19 @@ class LineTree
|
|
25
27
|
new_lines = rlines.map{|x| x[2..-1]}
|
26
28
|
|
27
29
|
if new_lines.length > 1 then
|
28
|
-
|
30
|
+
|
31
|
+
if level then
|
32
|
+
|
33
|
+
if level < 1 then
|
34
|
+
|
35
|
+
[(label + new_lines).join("\n")]
|
36
|
+
else
|
37
|
+
label + scan_shift(new_lines.join("\n"),level)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
label + scan_shift(new_lines.join("\n"),level)
|
41
|
+
end
|
42
|
+
|
29
43
|
else
|
30
44
|
new_lines.length > 0 ? label + [new_lines] : label
|
31
45
|
end
|
@@ -33,6 +47,7 @@ class LineTree
|
|
33
47
|
[x.lines.map{|x| x.sub(/^\s{2}/,'')}.join]
|
34
48
|
end
|
35
49
|
end
|
50
|
+
|
36
51
|
end
|
37
52
|
|
38
53
|
def scan_a(a)
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
ErtlSTAImlBCK8q5BS4jBBt8VAEpNdkWpWbtDtLPA639pW2QWIcPx13ObWJh7Ejk
|
32
32
|
THoVqqsHTfeg3g==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-
|
34
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexle
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '1.0'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.0.
|
45
|
+
version: 1.0.33
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '1.0'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.0.
|
55
|
+
version: 1.0.33
|
56
56
|
description: Line-tree parses indented lines of text and returns an array representing
|
57
57
|
a tree structure.
|
58
58
|
email: james@r0bertson.co.uk
|
metadata.gz.sig
CHANGED
Binary file
|