line-tree 0.4.0 → 0.4.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: 72ab54108743428550e162b237c57d3f5f3ebd04
4
- data.tar.gz: e24bd36af28eac887fcfe7bf2d13c7eaa8e546ff
3
+ metadata.gz: 34927fc0e7f9e55bab79c71bcf50b3f4c26edb0a
4
+ data.tar.gz: 186c4daa0b0d66c99a827b5ba148d7ab795aeb86
5
5
  SHA512:
6
- metadata.gz: fb799969d60bfbebeb2e7b36e731db81334960d3e87ab3a5cf273091740c3f8d9ec2167ca6f5cb4ec0ed5498651ecac9cf2f485e3f04086d3b1dd939a19a9fe4
7
- data.tar.gz: 95f8c929e6b1e53f0c98427a5d3e7e001cf567afcd810c6b02e610e90d623dc29ac7cfee6129362872e08a5e6ef819eb799d217daee13095f79260947685d882
6
+ metadata.gz: 7d5238c533f67ee110b235fbedbb4000ca39f7b74a1323d1e8ee49c0781deec06f0bd764991ff92802bb914829412fa80782b0b8c20f2492f5d12496658d6ecb
7
+ data.tar.gz: 5179885c6fc86d2bedbbb281b407892d4695cb584624b6758cf58a91ed0d20357e80118f71f357336ef07ffb0520dfc34580f39b75f9a28f582f46b92586d80d
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/line-tree.rb CHANGED
@@ -9,7 +9,11 @@ class LineTree
9
9
  attr_reader :to_a
10
10
 
11
11
  def initialize(lines, level: nil) @to_a = scan_shift(lines.strip, level) end
12
- def to_xml(options={}) Rexle.new(scan_a(*@to_a)).xml(options) end
12
+
13
+ def to_xml(options={})
14
+ a = scan_a(*@to_a).first
15
+ Rexle.new(a).xml(options)
16
+ end
13
17
 
14
18
  private
15
19
 
@@ -53,9 +57,11 @@ class LineTree
53
57
  def scan_a(a)
54
58
 
55
59
  s = a.shift
60
+ non_element = s[/^\s*(\w+:)/,1]
61
+ return [nil,non_element] if non_element
62
+
56
63
  r = s.match(/('[^']+[']|[^\s]+)\s*(\{[^\}]+\})?\s*(.*)/m)
57
64
  .captures.values_at(0,-1,1)
58
-
59
65
  if r.last then
60
66
 
61
67
  r[-1] = get_attributes(r.last)
@@ -68,9 +74,19 @@ class LineTree
68
74
 
69
75
  end
70
76
 
71
- a.map {|x| r << scan_a(x.clone) } if a.is_a? Array
77
+ if a.is_a? Array then
78
+
79
+ a.map do |x|
80
+ result, remaining = scan_a(x.clone)
81
+
82
+ if remaining then
83
+ r.last ? r << remaining : r[1] += remaining
84
+ end
85
+ r << result
86
+ end
87
+ end
72
88
 
73
- r
89
+ [r, non_element]
74
90
  end
75
91
 
76
92
  def get_attributes(s)
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.0
4
+ version: 0.4.1
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-11-06 00:00:00.000000000 Z
34
+ date: 2014-11-21 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
metadata.gz.sig CHANGED
Binary file