dynarex 1.1.10 → 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/dynarex.rb +21 -3
  2. metadata +2 -2
@@ -56,7 +56,11 @@ class Dynarex
56
56
  @format_mask = s
57
57
  @summary[:format_mask] = @format_mask
58
58
  end
59
-
59
+
60
+ def inspect()
61
+ "<object #%s>" % [self.object_id]
62
+ end
63
+
60
64
  def schema=(s)
61
65
  open s
62
66
  end
@@ -243,6 +247,10 @@ EOF
243
247
  return xslt
244
248
  end
245
249
 
250
+ def to_rss(opt={}, summary={})
251
+ doc = Rexle.new('<rss version="2.0">' + self.to_xslt(opt) + '</rss>')
252
+ end
253
+
246
254
  def xpath(x)
247
255
  @doc.root.xpath x
248
256
  end
@@ -280,7 +288,8 @@ EOF
280
288
 
281
289
  fields.each do |k,v|
282
290
  element = Rexle::Element.new(k.to_s)
283
- element.text = v if v
291
+ element.root.text = v if v
292
+
284
293
  record.add element if record
285
294
  end
286
295
 
@@ -361,7 +370,16 @@ EOF
361
370
  t = @format_mask.to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[').sub(/\]/,'\]')
362
371
  end
363
372
 
364
- lines = buffer.strip.split(/\r?\n|\r(?!\n)/).map {|x|x.strip.match(/#{t}/).captures}
373
+ a_summary = schema[/\[([^\]]+)/,1].split(',').map(&:strip)
374
+ raw_lines = buffer.strip.split(/\r?\n|\r(?!\n)/)
375
+
376
+ @summary = {}
377
+ while raw_lines.first[/#{a_summary.join('|')}:\s+\w+/] do
378
+ label, val = raw_lines.shift.match(/(\w+):\s+([^$]+)$/).captures
379
+ @summary[label] = val
380
+ end
381
+ lines = raw_lines.map {|x|x.strip.match(/#{t}/).captures}
382
+
365
383
 
366
384
  a = lines.map do|x|
367
385
  created = Time.now.to_s
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.10
5
+ version: 1.1.11
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: 2012-03-21 00:00:00 +00:00
13
+ date: 2012-03-24 23:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency