polyrex 0.5.2 → 0.5.3

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.
Files changed (2) hide show
  1. data/lib/polyrex.rb +12 -2
  2. metadata +2 -2
data/lib/polyrex.rb CHANGED
@@ -105,7 +105,13 @@ class Polyrex
105
105
 
106
106
  @field_names = @format_masks[i].to_s.scan(/\[!(\w+)\]/).flatten.map(&:to_sym)
107
107
  t = @format_masks[i].to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[').sub(/\]/,'\]')
108
- field_values = line.match(/#{t}/).captures
108
+ a = t.reverse.split(/(?=\)\*\.\()/).reverse.map &:reverse
109
+
110
+ patterns = tail_map(a)
111
+ pattern = patterns.detect {|x| line.match(/#{x}/)}.join
112
+ field_values = line.match(/#{pattern}/).captures
113
+ field_values += [''] * (@field_names.length - field_values.length)
114
+ #field_values = line.match(/#{t}/).captures
109
115
 
110
116
  @id = (@id.to_i + 1).to_s
111
117
  record = Element.new(tag_name)
@@ -176,6 +182,10 @@ class Polyrex
176
182
  load_handlers(schema)
177
183
  @parent_node = XPath.first(@doc.root,'records')
178
184
 
179
- end
185
+ end
186
+
187
+ def tail_map(a)
188
+ [a] + (a.length > 1 ? tail(a[0..-2]) : [])
189
+ end
180
190
 
181
191
  end
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.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-06-02 00:00:00 +01:00
12
+ date: 2010-06-04 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency