line-tree 0.6.6 → 0.6.7

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: e05262cfe7c1837b9f24701a9fd1a9117862a11c
4
- data.tar.gz: 4ce637c24ea955eafa11036e94fc502971de2da7
3
+ metadata.gz: 932ffe2082ae648bc26ccf7b0b78c1d42401b834
4
+ data.tar.gz: 69144908f9b36cb399c0e88ceeca6aec16ffbeb3
5
5
  SHA512:
6
- metadata.gz: fe1a66fc75a5d5240eb15bdb7701a737cc8d9d2201461ca839ef1df2f7bb08c0f4421681235b370665408f86639996f758b7bd6be64fb57b02c496faa2091ae7
7
- data.tar.gz: 8de02a8a98aebc58404612682b195a36f9b6464157240c45e1da24e8589ef18ee7840b490f8cfab34c6660b4400177d0da8dea71c078778514060ed7a8ed6c43
6
+ metadata.gz: c20912bd69c76d2078bdafaee7bb401a6a79c788220745640ca17020c2d5d604236d6be954557aaf34ed98c27bedfaf098f705871194d8fa91d2b012cd6667c7
7
+ data.tar.gz: 411e8bd28d98cb873da43851a8bc6e1e553bc7ee4bab5d2aff49a6c36fbaf78e86c9d0ce06abb845ee05dd45ac83ad08ec138f01c96362fd0eb12d023432541d
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/line-tree.rb CHANGED
@@ -13,6 +13,7 @@ class LineTree
13
13
  ignore_blank_lines: true, ignore_label: false,
14
14
  ignore_newline: true, root: nil, debug: false)
15
15
 
16
+ puts 'inside linetree' if @debug
16
17
  s = root ? root + "\n" + raw_s.lines.map {|x| ' ' + x}.join : raw_s
17
18
 
18
19
  @ignore_non_element = ignore_non_element
@@ -34,6 +35,7 @@ class LineTree
34
35
  a2 = if a[0].is_a? Array then
35
36
  encapsulate ? encap(a) : scan_a(a)
36
37
  else
38
+ puts 'before scan_a' if @debug
37
39
  scan_a(*a)
38
40
  end
39
41
 
@@ -124,46 +126,40 @@ class LineTree
124
126
  end
125
127
 
126
128
  end
127
-
129
+
128
130
  def scan_a(a)
129
131
 
130
- s = a.shift
131
-
132
- if @ignore_non_element then
133
- non_element = s[/^ *(\w+:)/,1]
134
- return [nil,non_element] if non_element
135
- end
132
+ puts 'a: ' + a.inspect if @debug
136
133
 
137
- r = s.match(/('[^']+[']|[^ ]+) *(\{.*\})? *(.*)/m)
138
- .captures.values_at(0,1,-1)
134
+ a.each do |node|
139
135
 
140
- if r[1] then
141
-
142
- r[1] = get_attributes(r[1])
143
-
144
- elsif s[/(\w+ *= *["'])/]
136
+ scan_a node[-1] if node[-1].is_a? Array
145
137
 
146
- raw_attributes, value = s.split(/(?=[^'"]+$)/,2)
147
- r[1] = get_xml_attributes raw_attributes
148
- r[-1] = value.to_s.strip
138
+ if node.is_a? Array then
139
+ r = parse_node(node[0])
140
+ node[0] = r[0]; node.insert 1, r[1], r[2]
141
+ end
149
142
 
150
143
  end
151
-
152
- if a.is_a? Array then
144
+
145
+ if a.first.is_a? String then
153
146
 
154
- a.map do |x|
155
- result, remaining = scan_a(x.clone)
156
-
157
- if remaining then
158
- r.last ? r << remaining : r[-1] += remaining
159
- end
160
- r << result
161
- end
147
+ s = a[0]
148
+
149
+ if @ignore_non_element then
150
+ non_element = s[/^ *(\w+:)/,1]
151
+ return [nil,non_element] if non_element
152
+ end
153
+
154
+ r = parse_node(s)
155
+ a[0] = r[0]; a.insert 1, r[1], r[2]
162
156
  end
163
157
 
164
- [r, non_element]
158
+ a
159
+
165
160
  end
166
161
 
162
+
167
163
  def get_attributes(s)
168
164
 
169
165
  a = s.scan(/\w+: ["'][^"']+["']/).map do |attr|
@@ -189,5 +185,24 @@ class LineTree
189
185
  return r
190
186
  end
191
187
 
188
+ def parse_node(s)
189
+
190
+ r = s.match(/('[^']+[']|[^ ]+) *(\{.*\})? *(.*)/m)
191
+ .captures.values_at(0,1,-1)
192
+
193
+ if r[1] then
194
+
195
+ r[1] = get_attributes(r[1])
196
+
197
+ elsif s[/(\w+ *= *["'])/]
198
+
199
+ raw_attributes, value = s.split(/(?=[^'"]+$)/,2)
200
+ r[1] = get_xml_attributes raw_attributes
201
+ r[-1] = value.to_s.strip
202
+
203
+ end
204
+
205
+ r
206
+ end
192
207
 
193
208
  end
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ���R��� `�͍?�9�&6AfQCE��:��p��h:�{ g]i�(J�E~T����A�7L�����*9��g 5Q�ZEb,�K
2
- ����$ N �����̹�x@�S1�Y���3� ��K��N ]$�?C﹇:E2�Ū9��AWD��}�sH��)
1
+ N��_t ���A����kl<F7�ĝ�7��U�:�[���/��B���F"�"iT��>8dȱ+ҝ7rw@"����a4����|-t�niV�rmC��u�29��z�E�1�\���B^���=�KVRH�A�f�rf���"�y���I�S�Y�_�q�᧐9��F��+�a
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.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file