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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05d33607cf41ebd4fb8415ccf95b3db6bec3f6da
4
- data.tar.gz: 30af0b6cc6c52c57c466e0eca2fa562d0ef45a2d
3
+ metadata.gz: 9eea653b96b08caee17505735b6c35b6b68e7917
4
+ data.tar.gz: e5720fe0881c519f10c5a30790887bcdcb8d88af
5
5
  SHA512:
6
- metadata.gz: 49c7907e54d39fcaf796729c2eb41a2252651e514fdba2dc975137e9ec7565c10cff1c2f248852b191e52eb3d03ec6a44342437d721a292672c4242154c71b2f
7
- data.tar.gz: b330b2b8030fb7e79c435964f2df122b6ccde1eb7de4c022a9775749a63af6e6bbe0b23f6dffc9683e5635105c3d7b81bd9cafdfd2d6f9055499c13e979ae149
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 = x.lines.map do |x|
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
- label + scan_shift(new_lines.join("\n"),level)
57
+ separator = @ignore_newline ? "\n" : ''
58
+ label + scan_shift(new_lines.join(separator),level)
59
+
55
60
  else
56
- (new_lines.length > 0 and \
57
- new_lines != [nil])? label + [new_lines] : label
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
@@ -1 +1,3 @@
1
- ��y��_ݖ"���2.)H|p+���sHV���QyI��j��@������2Lȣ��]�z[q�Z����Y��P��K'�6#�Qv�,(2���ɋX�=��%�+��)�tsuC�j�A�+E�� H���=������~��A�Im[[�=x����;��j%?w tf�?�PK��Aᴕ�TjGn����I�����;7 ���Č_xNnbLj��0zGtr�������>/���9�1>/� f�
1
+ '�C�xՇN���,:�-��nLL�I;��L��\����=i��
2
+ �����$C
3
+ ��wlK���
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.0
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-22 00:00:00.000000000 Z
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