dynarex 1.0.6 → 1.0.7

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 -1
  2. metadata +2 -2
@@ -143,8 +143,28 @@ EOF
143
143
  header.scan(/\w+\="[^"]+\"/).map{|x| r = x.split(/=/); [(r[0] + "=").to_sym, r[1][/^"(.*)"$/,1]] }.each {|name, value| self.method(name).call(value)}
144
144
  end
145
145
 
146
- #i = XPath.match(@doc.root, 'records/*/attribute::id').max_by(&:value).to_s.to_i
146
+ # if records already exist find the max id
147
147
  i = @doc.xpath('records/*/attribute::id').max_by(&:value).to_s.to_i
148
+
149
+
150
+ # 'a' and 'a_split' just used for validation
151
+ a = @format_mask.scan(/\[!\w+\]/)
152
+ a_split = @format_mask.split(/\[!\w+\]/)
153
+
154
+ if a.length == 2 and a_split[1].length == 1 then
155
+ a2 = []
156
+
157
+ # 1st
158
+ a2 << "([^#{a_split[1]}]+)" << a_split[1]
159
+
160
+ # last
161
+ a2 << "(.*)"
162
+ t = a2.join
163
+ else
164
+ t = @format_mask.to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[').sub(/\]/,'\]')
165
+ end
166
+
167
+ # convert the format mask into a friendly reg exp string
148
168
  t = @format_mask.to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[').sub(/\]/,'\]')
149
169
 
150
170
  lines = buffer.strip.split(/\r?\n|\r(?!\n)/).map {|x|x.match(/#{t}/).captures}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
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: 2011-02-06 00:00:00 +00:00
12
+ date: 2011-02-07 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency