polyrex 0.8.23 → 0.8.24
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.
- data/lib/polyrex.rb +34 -5
- metadata +2 -2
data/lib/polyrex.rb
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
|
37
37
|
class Polyrex
|
38
|
-
attr_accessor :summary_fields, :xslt_schema, :id_counter, :schema
|
38
|
+
attr_accessor :summary_fields, :xslt_schema, :id_counter, :schema, :type
|
39
39
|
|
40
40
|
def initialize(location=nil, id_counter='1')
|
41
41
|
|
@@ -231,6 +231,13 @@ class Polyrex
|
|
231
231
|
|
232
232
|
end
|
233
233
|
|
234
|
+
if @type == 'checklist' then
|
235
|
+
|
236
|
+
@format_masks.each do |fm|
|
237
|
+
fm.sub!(/\s(\[[^\[]+\]$)/,'999999999\1')
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
234
241
|
@summary.format_mask = @format_masks
|
235
242
|
|
236
243
|
format_line!(@parent_node.element('summary'), @parent_node.root, LineTree.new(raw_lines.join("\n").strip).to_a)
|
@@ -250,7 +257,7 @@ class Polyrex
|
|
250
257
|
|
251
258
|
def format_line!(summary, records, a, i=0)
|
252
259
|
|
253
|
-
a.each do |x|
|
260
|
+
a.each do |x|
|
254
261
|
|
255
262
|
unless @recordx[i] then
|
256
263
|
@recordx[i] = @recordx[-1].clone
|
@@ -258,8 +265,22 @@ class Polyrex
|
|
258
265
|
end
|
259
266
|
|
260
267
|
tag_name = @recordx[i].to_s
|
261
|
-
line = x.shift
|
268
|
+
line = raw_line = x.shift
|
262
269
|
|
270
|
+
if @type == 'checklist' then
|
271
|
+
|
272
|
+
raw_checked, line = raw_line.partition(/\]/).values_at 0,2
|
273
|
+
|
274
|
+
if raw_checked.lstrip[/^\[/] then
|
275
|
+
checkmark = raw_checked[/x/] ? true : false
|
276
|
+
else
|
277
|
+
checkmark = nil
|
278
|
+
line = raw_line
|
279
|
+
end
|
280
|
+
else
|
281
|
+
line = raw_line
|
282
|
+
end
|
283
|
+
|
263
284
|
if line[/\w+\s*---/] then
|
264
285
|
|
265
286
|
node_name = line.sub(/\s*---/,'')
|
@@ -284,7 +305,7 @@ class Polyrex
|
|
284
305
|
i = patterns.index(pattern)
|
285
306
|
|
286
307
|
@field_names = format_masks[i].to_s.scan(/\[!(\w+)\]/).flatten.map(&:to_sym)
|
287
|
-
|
308
|
+
|
288
309
|
field_values = line.match(/#{pattern}/).captures
|
289
310
|
|
290
311
|
end
|
@@ -296,13 +317,21 @@ class Polyrex
|
|
296
317
|
record.add_attribute(id: @id_counter.clone)
|
297
318
|
summary = Rexle::Element.new('summary')
|
298
319
|
|
320
|
+
if @type == 'checklist' then
|
321
|
+
field_values[-1] = checkmark.to_s unless checkmark.nil?
|
322
|
+
end
|
323
|
+
|
299
324
|
@field_names.zip(field_values).each do |name, value|
|
300
325
|
field = Rexle::Element.new(name.to_s)
|
301
326
|
field.text = value
|
302
327
|
summary.add field
|
303
328
|
end
|
304
329
|
|
305
|
-
|
330
|
+
format_mask = @format_masks[i]
|
331
|
+
if @type == 'checklist' then
|
332
|
+
format_mask = format_mask.sub(/999999999/,' ')
|
333
|
+
end
|
334
|
+
summary.add Rexle::Element.new('format_mask').add_text(format_mask)
|
306
335
|
|
307
336
|
new_records = Rexle::Element.new('records')
|
308
337
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: polyrex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.8.
|
5
|
+
version: 0.8.24
|
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:
|
13
|
+
date: 2013-01-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: polyrex-schema
|