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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 379a5191f6a4347dc9c913ef4eb7f743eed29474
4
- data.tar.gz: 10e45ac98f0142c9fc66a7269e3c5881131e0e5d
3
+ metadata.gz: 72ab54108743428550e162b237c57d3f5f3ebd04
4
+ data.tar.gz: e24bd36af28eac887fcfe7bf2d13c7eaa8e546ff
5
5
  SHA512:
6
- metadata.gz: dbdcf815f8a323753eed2abea3afb64996658429300edfec752445795a4d6ddae36c665e689e1c695dbd8a85d074bd9f71f0eb8c8db71607e628dd0c8ce71ac0
7
- data.tar.gz: ec37e2b4af6e5ab127672f364dc971d5e9d7714eabc5d79231067b1569e382a63ae7b45e3173f2572a2ec6da72f9354b26f36391e70b59207328d98027a2f136
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
- label + scan_shift(new_lines.join("\n"))
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.3.22
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-10-25 00:00:00.000000000 Z
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.11
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.11
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