line-tree 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/line-tree.rb +43 -28
- data.tar.gz.sig +1 -2
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 932ffe2082ae648bc26ccf7b0b78c1d42401b834
|
4
|
+
data.tar.gz: 69144908f9b36cb399c0e88ceeca6aec16ffbeb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
138
|
-
.captures.values_at(0,1,-1)
|
134
|
+
a.each do |node|
|
139
135
|
|
140
|
-
|
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
|
-
|
147
|
-
|
148
|
-
|
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?
|
144
|
+
|
145
|
+
if a.first.is_a? String then
|
153
146
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
-
|
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
|
-
|
2
|
-
����$ N�����̹�x@�S1�Y���3� ��K��N ]$�?C﹇:E2�Ū9��AWD��}�sH��)
|
1
|
+
N��_t���A����kl<F7�ĝ�7��U�:�[���/��B���F�"�"iT��>8�dȱ+ҝ7r�w@"����a4����|-t�niV�rmC��u�29��z�E�1�\���B^���=�KVRH�A�f�rf���"�y���I�S�Y�_�q�᧐9��F��+�a
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|