polyrex 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/polyrex.rb +55 -4
- metadata +20 -18
- 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: 013bb5179a22169991d73399b03f9c698c6f8c45
|
4
|
+
data.tar.gz: 58b0c25df6492abd6827b94fa55e9f4e91645b14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c95f20a89040cae9ec260e960627bff7c20f016c539e94c6951f5bd6968e9e1a8ab3023ddcc01197ea17bc62e1e96a51f9355b3bf64c49c958115b51c82e67c6
|
7
|
+
data.tar.gz: fe48dda760665c06aec8976930063bdbb331f2273c522514ebae19fe0724e01a5d63f918b3e31b92b3730f7421c00f1363c45090c3bcfa355e4fb4abcbf223b4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/polyrex.rb
CHANGED
@@ -37,13 +37,15 @@ end
|
|
37
37
|
|
38
38
|
|
39
39
|
class Polyrex
|
40
|
-
attr_accessor :summary_fields, :xslt_schema, :id_counter,
|
40
|
+
attr_accessor :summary_fields, :xslt_schema, :id_counter,
|
41
|
+
:schema, :type, :delimiter
|
41
42
|
|
42
43
|
def initialize(location=nil, opt={})
|
43
44
|
|
44
45
|
options = {id_counter: '1'}.merge opt
|
45
46
|
@id_counter = options[:id_counter]
|
46
47
|
@format_masks = []
|
48
|
+
@delimiter = ''
|
47
49
|
|
48
50
|
if location then
|
49
51
|
self.method(:schema=).call(options[:schema]) if options[:schema]
|
@@ -91,6 +93,8 @@ class Polyrex
|
|
91
93
|
|
92
94
|
def delimiter=(separator)
|
93
95
|
|
96
|
+
@delimiter = separator
|
97
|
+
|
94
98
|
@format_masks.map! do |format_mask|
|
95
99
|
format_mask.to_s.gsub(/\s/, separator)
|
96
100
|
end
|
@@ -212,6 +216,53 @@ EOF
|
|
212
216
|
|
213
217
|
end
|
214
218
|
|
219
|
+
def to_s()
|
220
|
+
|
221
|
+
def build(records, indent=0)
|
222
|
+
|
223
|
+
records.map do |item|
|
224
|
+
|
225
|
+
summary = item.element 'summary'
|
226
|
+
format_mask = summary.text 'format_mask'
|
227
|
+
line = format_mask.gsub(/\[![^\]]+\]/){|x| summary.text x[2..-2]}
|
228
|
+
|
229
|
+
records = item.element('records').elements.to_a
|
230
|
+
line = line + "\n" + build(records, indent + 1).join("\n") if records.length > 0
|
231
|
+
(' ' * indent) + line
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
sumry = ''
|
236
|
+
|
237
|
+
|
238
|
+
summary_fields = self.summary.to_h.keys
|
239
|
+
|
240
|
+
%w(recordx_type schema format_mask).each {|x| summary_fields.delete x}
|
241
|
+
sumry = summary_fields.map {|x| x + ': ' + \
|
242
|
+
self.summary.method(x.to_sym).call}.join("\n") + "\n"
|
243
|
+
|
244
|
+
|
245
|
+
if @raw_header then
|
246
|
+
declaration = @raw_header
|
247
|
+
else
|
248
|
+
|
249
|
+
smry_fields = %i(schema)
|
250
|
+
if self.delimiter.length > 0 then
|
251
|
+
smry_fields << :delimiter
|
252
|
+
else
|
253
|
+
smry_fields << :format_mask
|
254
|
+
end
|
255
|
+
s = smry_fields.map {|x| "%s=\"%s\"" % \
|
256
|
+
[x, self.summary.send(x).gsub('"', '\"') ]}.join ' '
|
257
|
+
|
258
|
+
declaration = %Q(<?polyrex %s?>\n) % s
|
259
|
+
end
|
260
|
+
|
261
|
+
header = declaration + sumry
|
262
|
+
out = build(self.records).join("\n")
|
263
|
+
header + "\n" + out
|
264
|
+
end
|
265
|
+
|
215
266
|
def to_xslt()
|
216
267
|
@polyrex_xslt.schema = @schema
|
217
268
|
@polyrex_xslt.to_xslt
|
@@ -296,10 +347,10 @@ EOF
|
|
296
347
|
|
297
348
|
def string_parse(buffer, options={})
|
298
349
|
|
299
|
-
raw_header = buffer.slice!(/<\?polyrex[^>]+>/)
|
350
|
+
@raw_header = buffer.slice!(/<\?polyrex[^>]+>/)
|
300
351
|
|
301
|
-
if raw_header then
|
302
|
-
header = raw_header[/<?polyrex (.*)?>/,1]
|
352
|
+
if @raw_header then
|
353
|
+
header = @raw_header[/<?polyrex (.*)?>/,1]
|
303
354
|
a = header.scan(/\w+\=["'][^"']+["']/).map do |x|
|
304
355
|
r = x.split(/=/)
|
305
356
|
[(r[0] + "=").to_sym, r[1][/^["'](.*)["']$/,1]]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,26 +10,28 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTE0MDIyMTIyMTYzNloXDTE1MDIyMTIyMTYzNlowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
17
|
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
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HI1Ouxe
|
32
|
+
SmUIljyExpxiHQ==
|
31
33
|
-----END CERTIFICATE-----
|
32
|
-
date: 2014-
|
34
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
33
35
|
dependencies:
|
34
36
|
- !ruby/object:Gem::Dependency
|
35
37
|
name: polyrex-schema
|
@@ -156,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
158
|
version: '0'
|
157
159
|
requirements: []
|
158
160
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.1.11
|
160
162
|
signing_key:
|
161
163
|
specification_version: 4
|
162
164
|
summary: polyrex
|
metadata.gz.sig
CHANGED
Binary file
|