line-tree 0.6.0 → 0.6.1
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 +23 -7
- data.tar.gz.sig +3 -1
- metadata +2 -2
- 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: 9eea653b96b08caee17505735b6c35b6b68e7917
|
4
|
+
data.tar.gz: e5720fe0881c519f10c5a30790887bcdcb8d88af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3864cf71c4bea5d7ca00efc69bde2f6b72de5766ef4aec818c3d9d066183e9eb029a66e1bf7da83df42b3613d4664dfbb42045e8c7da7e3c3465575775cef91e
|
7
|
+
data.tar.gz: 528e32387580e163d02c57a3d0e75dff37c4cf65c034be0357c8e304dfdf8e091c4c8480fc71d13c0d5c7c4a651388567f101c68379df9121d9405140c0cff6d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/line-tree.rb
CHANGED
@@ -10,11 +10,12 @@ class LineTree
|
|
10
10
|
attr_reader :to_a
|
11
11
|
|
12
12
|
def initialize(s, level: nil, ignore_non_element: true,
|
13
|
-
ignore_blank_lines: true, ignore_label: false)
|
13
|
+
ignore_blank_lines: true, ignore_label: false, ignore_newline: true)
|
14
14
|
|
15
15
|
@ignore_non_element = ignore_non_element
|
16
16
|
@ignore_label = ignore_label
|
17
17
|
@ignore_blank_lines = ignore_blank_lines
|
18
|
+
@ignore_newline = ignore_newline
|
18
19
|
|
19
20
|
lines = ignore_blank_lines ? s.gsub(/^ *$\n/,'') : s
|
20
21
|
|
@@ -41,20 +42,35 @@ class LineTree
|
|
41
42
|
|
42
43
|
if @ignore_label == true or not x[/.*/][/^ *\w+:\S+/] then
|
43
44
|
|
44
|
-
rlines =
|
45
|
-
x.sub(/(.)\n$/,'\1')
|
45
|
+
rlines = if @ignore_newline then
|
46
|
+
x.lines.map {|x| x.sub(/(.)\n$/,'\1') }
|
47
|
+
else
|
48
|
+
x.lines
|
46
49
|
end
|
47
|
-
|
50
|
+
|
48
51
|
rlines = [x.gsub(/^ {2}/,'')] if level and level < 0
|
49
52
|
|
50
53
|
label = [rlines.shift]
|
51
54
|
new_lines = rlines.map{|x| x.sub(/^ {2}/,'')}
|
52
55
|
|
53
56
|
if new_lines.length > 1 then
|
54
|
-
|
57
|
+
separator = @ignore_newline ? "\n" : ''
|
58
|
+
label + scan_shift(new_lines.join(separator),level)
|
59
|
+
|
55
60
|
else
|
56
|
-
|
57
|
-
|
61
|
+
|
62
|
+
#label = [] if label == ["\n"]
|
63
|
+
|
64
|
+
if (new_lines.length > 0 and new_lines != [nil]) then
|
65
|
+
|
66
|
+
if label == ["\n"] then
|
67
|
+
[new_lines]
|
68
|
+
else
|
69
|
+
label + [new_lines]
|
70
|
+
end
|
71
|
+
else
|
72
|
+
label
|
73
|
+
end
|
58
74
|
end
|
59
75
|
|
60
76
|
else
|
data.tar.gz.sig
CHANGED
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
m6UjuCKOiPqABbG2jvwjzF2RT9/yszKHPuB+qsEDC9HhonU7t7xizbYXXFCa7Ocj
|
32
32
|
UE2/ecWxKMEncA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-12-
|
34
|
+
date: 2017-12-23 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexle
|
metadata.gz.sig
CHANGED
Binary file
|