polyrex 0.8.29 → 0.8.30

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: 52916136797bf571b97e16e4fe8efbdfa2b2d654
4
- data.tar.gz: ebdd6171caf75db3897f1b6c1630ae1a9e949d64
3
+ metadata.gz: d9f780f2497eee0bb328cedbacf2d450467c5743
4
+ data.tar.gz: e6350fe9139dd22a8b835ee5b31562f8ab1b9e12
5
5
  SHA512:
6
- metadata.gz: 206873a6085140c34a5c3445278a6ad912e258259a2517c2cba8f6ddfa4f8d0e67d09d6d3f246f6d58180178c92ba28575c9fb457dc907e92505558d5edbe146
7
- data.tar.gz: d046a1855671f6d7824a334c661dda55d5ff088c81e7423845bd1713d9d9ef7c5ba90fc5c7a57280484fbdb7c5baeb3ea593e9e4d7b0dc9116f5f5692e75508b
6
+ metadata.gz: 4ac931a09ed9793168f8ea133ab8ca342d94f552f9bbb827c05b15303b216f655b7c4a9ec5d40829b1b066429a45ad4db5eaeb7d121d80921d2a2e635bf7b233
7
+ data.tar.gz: e5cecbf9dbe3b4b49965278a14cc6c5d71ffff68646d12927e265bea47fee37d5a562fbf335c08fb19b10031be5820166710c726c17562b793ec2f4c185f16c6
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/polyrex.rb CHANGED
@@ -107,12 +107,14 @@ class Polyrex
107
107
  @format_masks
108
108
  end
109
109
 
110
- def parse(buffer='')
110
+ def parse(buffer='', options={})
111
111
  buffer = yield if block_given?
112
- string_parse buffer
112
+ string_parse buffer, options
113
113
  self
114
114
  end
115
115
 
116
+ alias import parse
117
+
116
118
  def element(s)
117
119
  @doc.root.element(s)
118
120
  end
@@ -124,7 +126,7 @@ class Polyrex
124
126
  end
125
127
 
126
128
  def schema=(s)
127
- open s
129
+ open(s)
128
130
  summary_h = Hash[*@doc.root.xpath("summary/*").map {|x| [x.name, x.text]}.flatten]
129
131
  #@summary = OpenStruct.new summary_h
130
132
  @summary = RecordX.new summary_h
@@ -206,21 +208,34 @@ class Polyrex
206
208
  [fields, a]
207
209
  end
208
210
 
209
- def string_parse(buffer)
211
+ def string_parse(buffer, options={})
210
212
 
211
213
  raw_header = buffer.slice!(/<\?polyrex[^>]+>/)
212
214
 
213
215
  if raw_header then
214
216
  header = raw_header[/<?polyrex (.*)?>/,1]
215
- header.scan(/\w+\=["'][^"']+["']/).map{|x| r = x.split(/=/); \
216
- [(r[0] + "=").to_sym, r[1][/^["'](.*)["']$/,1]] }.each do |name, value|
217
- self.method(name).call(value)
218
- end
217
+ a = header.scan(/\w+\=["'][^"']+["']/).map do |x|
218
+ r = x.split(/=/)
219
+ [(r[0] + "=").to_sym, r[1][/^["'](.*)["']$/,1]]
220
+ end
221
+
222
+ if options[:schema] then
223
+ a.delete a.assoc(:schema)
224
+ self.method(:schema=).call(options[:schema])
225
+ end
226
+
227
+ a.each do |name, value|
228
+ unless options.keys.include? name[0..-2].to_sym then
229
+ self.method(name).call(value)
230
+ end
231
+ end
219
232
  end
220
233
 
221
- raw_summary = schema[/^\w+\[([^\]]+)/,1]
234
+
222
235
  raw_lines = buffer.strip.split(/\r?\n|\r(?!\n)/)
223
236
 
237
+ raw_summary = schema[/^\w+\[([^\]]+)/,1]
238
+
224
239
  if raw_summary then
225
240
  a_summary = raw_summary.split(',').map(&:strip)
226
241
 
@@ -386,8 +401,8 @@ class Polyrex
386
401
 
387
402
  @doc = Rexle.new buffer
388
403
 
389
- schema = @doc.root.text('summary/schema')
390
-
404
+ schema = @schema ? @schema : @doc.root.text('summary/schema')
405
+
391
406
  unless @format_masks
392
407
  schema_rpath = schema.gsub(/\[[^\]]+\]/,'')
393
408
  @recordx = schema_rpath.split('/')
data.tar.gz.sig CHANGED
Binary file
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.8.29
4
+ version: 0.8.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -29,7 +29,7 @@ cert_chain:
29
29
  7hfiCsNv+0o/OwBNlpn8pTTpd3jV6o1Qq0Y7QiFomKd6XWlaHT4ZNtZdb/XTpC7W
30
30
  ZUZv+oXV5L4FrLlOrnTUhA+cZRntSyHs
31
31
  -----END CERTIFICATE-----
32
- date: 2013-09-20 00:00:00.000000000 Z
32
+ date: 2013-09-21 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: polyrex-schema
metadata.gz.sig CHANGED
Binary file