gtin2atc 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/History.txt +4 -0
- data/lib/gtin2atc/builder.rb +42 -33
- data/lib/gtin2atc/version.rb +1 -1
- data/spec/builder_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDRhOWFiNzFhNzM0YmE0N2NlYTA0NWI5MDEyOGRkNjY5YWZjYTU3Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmZlMDkxMWRiM2VkNTY0MDZiMjk0YWFkYjM0MGY3ZDFjMDEzMTBlYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzk0OGY2MTU2NmY2ZmY0NmRiYTM2MGI4Mzc0NzdhNjFmM2RlMGJjNTVjZDhm
|
10
|
+
NmEzMDI1NjYxNzk0Njg2MDhhYTQ4ZDNkZDNiZTUyYzE0MTRiODdiZmYxODc5
|
11
|
+
NjJhMDk3MDY1ODRlMzBmY2YxNzUyMTM4ZDQwNzZjNzNjMDQ0MTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDk1NDkxZmY0NGY3OTZjYzY3MTYwMzFmMmFkMjQ3OTExZmRmZWE2YTcxZDQ0
|
14
|
+
MmUxNWE4OGRiOGRiZmIzMGEyNGQwYmYzMTA1NWQzYmEwMTBiODFkNTcxNmVj
|
15
|
+
MWE1YzAyNDg3OTgyYjJlMTg4ZmQ3YTI4ZjhhOWNhYTExNjllMGU=
|
data/History.txt
CHANGED
data/lib/gtin2atc/builder.rb
CHANGED
@@ -8,6 +8,11 @@ require 'mechanize'
|
|
8
8
|
module Gtin2atc
|
9
9
|
class Builder
|
10
10
|
Strip_For_Sax_Machine = '<?xml version="1.0" encoding="utf-8"?>'+"\n"
|
11
|
+
SameInAll = 'atc where the same in bag, swissindex and swissmedic'
|
12
|
+
AtcNotInSwissindex = 'atc not in swissindex'
|
13
|
+
AtcNotInSwissmedic = 'atc not in swissmedic'
|
14
|
+
AtcNotInBag = 'atc not in bag'
|
15
|
+
AtcDifferent = 'atc differed'
|
11
16
|
def initialize(opts)
|
12
17
|
Util.set_logging(opts[:log])
|
13
18
|
@do_compare = opts[:compare]
|
@@ -174,25 +179,25 @@ module Gtin2atc
|
|
174
179
|
if not @data_swissindex[gtin]
|
175
180
|
not_in_swissindex << "#{gtin}: Not in swissindex #{item}"
|
176
181
|
elsif atc_code == @data_swissindex[gtin][:atc_code]
|
177
|
-
match_in_swissindex << "
|
182
|
+
match_in_swissindex << "ATC code #{atc_code} for #{gtin} matches swissindex #{@data_swissindex[gtin][:atc_code]}"
|
178
183
|
elsif atc_code.length < @data_swissindex[gtin][:atc_code].length
|
179
|
-
longer_in_swissindex << "
|
184
|
+
longer_in_swissindex << "ATC code #{item[:atc_code]} for #{gtin} longer in swissindex #{@data_swissindex[gtin][:atc_code]}"
|
180
185
|
elsif atc_code.length > @data_swissindex[gtin][:atc_code].length
|
181
|
-
shorter_in_swissindex << "
|
186
|
+
shorter_in_swissindex << "ATC code #{atc_code} for #{gtin} shorter in swissindex #{@data_swissindex[gtin][:atc_code]}"
|
182
187
|
else
|
183
|
-
matching_atc_codes << "
|
188
|
+
matching_atc_codes << "ATC code #{atc_code} for #{gtin} differs from swissindex #{@data_swissindex[gtin][:atc_code]}"
|
184
189
|
end
|
185
190
|
|
186
191
|
if not @data_swissmedic[gtin]
|
187
192
|
not_in_swissmedic << "#{gtin}: Not in swissmedic #{item}"
|
188
193
|
elsif atc_code == @data_swissmedic[gtin][:atc_code]
|
189
|
-
match_in_swissmedic << "
|
194
|
+
match_in_swissmedic << "ATC code #{atc_code} for #{gtin} matches swissmedic #{@data_swissmedic[gtin][:atc_code]}"
|
190
195
|
elsif atc_code.length < @data_swissmedic[gtin][:atc_code].length
|
191
|
-
longer_in_swissmedic << "
|
196
|
+
longer_in_swissmedic << "ATC code #{item[:atc_code]} for #{gtin} longer in swissmedic #{@data_swissmedic[gtin][:atc_code]}"
|
192
197
|
elsif atc_code.length > @data_swissmedic[gtin][:atc_code].length
|
193
|
-
shorter_in_swissmedic << "
|
198
|
+
shorter_in_swissmedic << "ATC code #{atc_code} for #{gtin} shorter in swissmedic #{@data_swissmedic[gtin][:atc_code]}"
|
194
199
|
else
|
195
|
-
different_atc_in_swissmedic << "
|
200
|
+
different_atc_in_swissmedic << "ATC code #{atc_code} for #{gtin} differs from swissmedic #{@data_swissmedic[gtin][:atc_code]}"
|
196
201
|
end
|
197
202
|
total1 = not_in_swissindex + match_in_swissindex + longer_in_swissindex + shorter_in_swissindex + different_atc_in_swissindex
|
198
203
|
total2 = not_in_swissmedic + match_in_swissmedic + longer_in_swissmedic + shorter_in_swissmedic + different_atc_in_swissmedic
|
@@ -208,18 +213,20 @@ module Gtin2atc
|
|
208
213
|
Not in swissindex #{not_in_swissindex.size}
|
209
214
|
"
|
210
215
|
Util.info "Comparing ATC-Codes between bag and swissmedic"
|
211
|
-
|
212
|
-
report(
|
213
|
-
report(
|
214
|
-
report(
|
215
|
-
report(
|
216
|
+
topic_swissmedic = 'compare_bag_to_swissmedic'
|
217
|
+
report(topic_swissmedic, SameInAll, matching_atc_codes)
|
218
|
+
report(topic_swissmedic, 'atc are the same in swissmedic and bag, but not in swissindex', match_in_swissmedic)
|
219
|
+
report(topic_swissmedic, 'atc are different in swissmedic and bag', different_atc_in_swissmedic)
|
220
|
+
report(topic_swissmedic, 'atc are shorter in swissmedic than in bag', shorter_in_swissmedic)
|
221
|
+
report(topic_swissmedic, 'atc are longer in swissmedic than in bag', longer_in_swissmedic)
|
216
222
|
|
217
223
|
Util.info "Comparing ATC-Codes between bag and swissindex"
|
218
|
-
|
219
|
-
report(
|
220
|
-
report(
|
221
|
-
report(
|
222
|
-
report(
|
224
|
+
topic_swissindex = 'compare_bag_to_swissindex'
|
225
|
+
report(topic_swissindex, SameInAll, matching_atc_codes)
|
226
|
+
report(topic_swissindex, 'atc are the same in swissindex and bag, but not in swissmedic', match_in_swissindex)
|
227
|
+
report(topic_swissindex, 'atc are different in swissmedic and bag', different_atc_in_swissindex)
|
228
|
+
report(topic_swissindex, 'atc are shorter in swissindex than in bag', shorter_in_swissindex)
|
229
|
+
report(topic_swissindex, 'atc are longer in swissindex than in bag', longer_in_swissindex)
|
223
230
|
end
|
224
231
|
|
225
232
|
def report(topic, msg, details)
|
@@ -229,7 +236,7 @@ module Gtin2atc
|
|
229
236
|
File.open((full_msg+'.txt').gsub(/[: ,]+/, '_'), 'w+') {
|
230
237
|
|file|
|
231
238
|
file.puts full_msg
|
232
|
-
details.each{|detail| file.puts detail }
|
239
|
+
details.sort.each{|detail| file.puts detail }
|
233
240
|
}
|
234
241
|
end
|
235
242
|
def check_swissmedic
|
@@ -256,13 +263,13 @@ module Gtin2atc
|
|
256
263
|
next
|
257
264
|
end
|
258
265
|
if item[:atc_code] == @data_swissindex[gtin][:atc_code]
|
259
|
-
matching_atc_codes << "
|
266
|
+
matching_atc_codes << "ATC code #{atc_code} for #{gtin} matches swissindex #{@data_swissindex[gtin][:atc_code]}"
|
260
267
|
elsif item[:atc_code].length < @data_swissindex[gtin][:atc_code].length
|
261
|
-
longer_in_swissindex << "
|
268
|
+
longer_in_swissindex << "ATC code #{item[:atc_code]} for #{gtin} longer in swissindex #{@data_swissindex[gtin][:atc_code]}"
|
262
269
|
elsif item[:atc_code].length > @data_swissindex[gtin][:atc_code].length
|
263
|
-
shorter_in_swissmedic << "
|
270
|
+
shorter_in_swissmedic << "ATC code #{atc_code} for #{gtin} shorter in swissindex #{@data_swissindex[gtin][:atc_code]}"
|
264
271
|
else
|
265
|
-
different_atc << "
|
272
|
+
different_atc << "ATC code #{atc_code} for #{gtin} differs from swissindex #{@data_swissindex[gtin][:atc_code]}"
|
266
273
|
end
|
267
274
|
unless @data_bag[gtin]
|
268
275
|
not_in_bag << "#{gtin}: Not in bag #{item}"
|
@@ -278,11 +285,12 @@ module Gtin2atc
|
|
278
285
|
Not in swissindex #{not_in_swissindex.size}
|
279
286
|
Comparing ATC-Codes between swissmedic and swissindex
|
280
287
|
"
|
281
|
-
|
282
|
-
report(
|
283
|
-
report(
|
284
|
-
report(
|
285
|
-
report(
|
288
|
+
topic = 'compare swissmedic to swisssindex'
|
289
|
+
report(topic, 'atc match in swissindex and swissmedic', matching_atc_codes)
|
290
|
+
report(topic, 'atc are different in swissindex and swissmedic', different_atc)
|
291
|
+
report(topic, 'atc are the same in swissindex and swissmedic', matching_atc_codes)
|
292
|
+
report(topic, 'atc are shorter in swissindex', shorter_in_swissmedic)
|
293
|
+
report(topic, 'atc are longer in swissindex', longer_in_swissindex)
|
286
294
|
end
|
287
295
|
|
288
296
|
def compare
|
@@ -320,11 +328,12 @@ module Gtin2atc
|
|
320
328
|
swissindex #{@data_swissindex.size} entries. Fetched from #{@swissindex.origin}
|
321
329
|
swissmedic #{@data_swissmedic.size} entries. Fetched from #{@swissmedic.origin}
|
322
330
|
"
|
323
|
-
|
324
|
-
report(
|
325
|
-
report(
|
326
|
-
report(
|
327
|
-
report(
|
331
|
+
topic = 'compare all'
|
332
|
+
report(topic, SameInAll, matching_atc_codes)
|
333
|
+
report(topic, AtcNotInBag, not_in_bag)
|
334
|
+
report(topic, AtcNotInSwissindex, not_in_swissindex)
|
335
|
+
report(topic, AtcNotInSwissmedic, not_in_swissmedic)
|
336
|
+
report(topic, AtcDifferent, different_atc)
|
328
337
|
end
|
329
338
|
end
|
330
339
|
class Swissmedic
|
data/lib/gtin2atc/version.rb
CHANGED
data/spec/builder_spec.rb
CHANGED
@@ -132,7 +132,7 @@ describe Gtin2atc::Builder do
|
|
132
132
|
/not in bag/,
|
133
133
|
/not in swissmedic/,
|
134
134
|
/not in swissindex/,
|
135
|
-
/
|
135
|
+
/atc are different/,
|
136
136
|
].each {
|
137
137
|
|pattern|
|
138
138
|
unless pattern.match(@res)
|
@@ -153,8 +153,8 @@ describe Gtin2atc::Builder do
|
|
153
153
|
|
154
154
|
it 'should produce a many report files' do
|
155
155
|
@res = buildr_capture(:stdout){ cli.run }
|
156
|
-
Dir.glob(Gtin2atc::WorkDir + '/
|
157
|
-
Dir.glob(Gtin2atc::WorkDir + '/
|
156
|
+
Dir.glob(Gtin2atc::WorkDir + '/compare_all_*.txt').size.should == 5
|
157
|
+
Dir.glob(Gtin2atc::WorkDir + '/compare_swissmedic_to_swisssindex_*.txt').size.should == 5
|
158
158
|
Dir.glob(Gtin2atc::WorkDir + '/compare_bag_to_swissindex_*.txt').size.should == 5
|
159
159
|
Dir.glob(Gtin2atc::WorkDir + '/compare_bag_to_swissmedic_*.txt').size.should == 5
|
160
160
|
end
|