line-tree 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/line-tree.rb +9 -3
  2. metadata +4 -3
data/lib/line-tree.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  # file: line-tree.rb
4
4
 
@@ -14,11 +14,15 @@ class LineTree
14
14
  private
15
15
 
16
16
  def scan_shift(lines)
17
- a = lines.split(/^\b/)
17
+
18
+ a = lines.split(/(?=^\S+)/)
19
+
18
20
  a.map do |x|
21
+
19
22
  rlines = x.split(/\n/)
20
23
  label = [rlines.shift]
21
24
  new_lines = rlines.map{|x| x[2..-1]}
25
+
22
26
  if new_lines.length > 1 then
23
27
  label + scan_shift(new_lines.join("\n"))
24
28
  else
@@ -28,7 +32,9 @@ class LineTree
28
32
  end
29
33
 
30
34
  def scan_a(a)
31
- r = a.shift.match(/([^\s]+)\s*(\{[^\}]+\})?\s*(.*)/).captures.values_at(0,-1,1)
35
+
36
+ r = a.shift.match(/('[^']+[']|[^\s]+)\s*(\{[^\}]+\})?\s*(.*)/).captures.values_at(0,-1,1)
37
+
32
38
  r[-1] = get_attributes(r.last) if r.last
33
39
  a.map {|x| r << scan_a(x.clone) } if a.is_a? Array
34
40
  r
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: line-tree
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.5
5
+ version: 0.3.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-07 00:00:00 +01:00
13
+ date: 2012-05-12 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -26,6 +26,7 @@ dependencies:
26
26
  version_requirements: *id001
27
27
  description: Line-tree parses indented lines of text and returns an array representing a tree structure.
28
28
  email:
29
+ - james@r0bertson.co.uk
29
30
  executables: []
30
31
 
31
32
  extensions: []
@@ -35,7 +36,7 @@ extra_rdoc_files: []
35
36
  files:
36
37
  - lib/line-tree.rb
37
38
  has_rdoc: true
38
- homepage:
39
+ homepage: http://github.com/jrobertson/line-tree
39
40
  licenses: []
40
41
 
41
42
  post_install_message: