gtin2atc 0.1.2 → 0.1.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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGNiOTI1OWE4YWFkNDYzODUxMTQwYWE4NTEyOWU3OWU5MmYyN2Q4OA==
4
+ ZDRhOWFiNzFhNzM0YmE0N2NlYTA0NWI5MDEyOGRkNjY5YWZjYTU3Yg==
5
5
  data.tar.gz: !binary |-
6
- ZTkzODk2MDEzYzE0MDFjOWNjYTczOTJlNGYwMTViNzZhYTQ0N2U1NQ==
6
+ YmZlMDkxMWRiM2VkNTY0MDZiMjk0YWFkYjM0MGY3ZDFjMDEzMTBlYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTk1MzFjZDk5MDljN2Y1OGM1MDM1ZWRmNDhhNmM0YTY5ZTgxZDliNmFlMjcx
10
- YjE2NWM5OTllMjhkNDA3Zjk1MzExODA0ODg4N2IwOTY0Yzc4MDI2M2Y3ZDll
11
- YzliMjY2YmJhMWQ0YjI0ZGMwYzIyNWY0ZDZmM2Y4MmU3NDJhOTk=
9
+ Yzk0OGY2MTU2NmY2ZmY0NmRiYTM2MGI4Mzc0NzdhNjFmM2RlMGJjNTVjZDhm
10
+ NmEzMDI1NjYxNzk0Njg2MDhhYTQ4ZDNkZDNiZTUyYzE0MTRiODdiZmYxODc5
11
+ NjJhMDk3MDY1ODRlMzBmY2YxNzUyMTM4ZDQwNzZjNzNjMDQ0MTY=
12
12
  data.tar.gz: !binary |-
13
- NDU0ZTA5NDY0OTZiYTQwZWRjMjIzMzlkYTIyN2RlZWI3Mjg2YTQ3YWZmY2Yw
14
- MmIyMDlhY2NiYjM5NTFkOGUwYTcyOGYzMTI5MTU0OTI3M2M2YzVhZGRkNzYz
15
- ZDNlYTg3OWFlMGZkY2E5YTRjYWE3YjFiNmQ4ZjkwNGNiZGQ3NWE=
13
+ ZDk1NDkxZmY0NGY3OTZjYzY3MTYwMzFmMmFkMjQ3OTExZmRmZWE2YTcxZDQ0
14
+ MmUxNWE4OGRiOGRiZmIzMGEyNGQwYmYzMTA1NWQzYmEwMTBiODFkNTcxNmVj
15
+ MWE1YzAyNDg3OTgyYjJlMTg4ZmQ3YTI4ZjhhOWNhYTExNjllMGU=
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.3 27.01.2015
2
+
3
+ * Clearer filenames
4
+
1
5
  === 0.1.2 27.01.2015
2
6
 
3
7
  * Travis should install and test installed gem, too
@@ -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 << "swissindex #{gtin}: ATC code #{atc_code} matches swissindex #{@data_swissindex[gtin][:atc_code]}"
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 << "swissindex #{gtin}: ATC code #{atc_code} longer in swissindex #{@data_swissindex[gtin][:atc_code]}"
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 << "swissindex #{gtin}: ATC code #{atc_code} shorter in swissindex #{@data_swissindex[gtin][:atc_code]}"
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 << "swissindex #{gtin}: ATC code #{atc_code} differs from swissindex #{@data_swissindex[gtin][:atc_code]}"
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 << "swissmedic #{gtin}: ATC code #{atc_code} matches swissmedic #{@data_swissmedic[gtin][:atc_code]}"
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 << "swissmedic #{gtin}: ATC code #{atc_code} longer in swissmedic #{@data_swissmedic[gtin][:atc_code]}"
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 << "swissmedic #{gtin}: ATC code #{atc_code} shorter in swissmedic #{@data_swissmedic[gtin][:atc_code]}"
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 << "swissmedic #{gtin}: ATC code #{atc_code} differs from swissmedic #{@data_swissmedic[gtin][:atc_code]}"
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
- report('compare_bag_to_swissmedic', 'items had the same ATC code in bag, swissindex and swissmedic', matching_atc_codes)
212
- report('compare_bag_to_swissmedic', 'are the same in swissmedic and bag, but not in swissindex', match_in_swissmedic)
213
- report('compare_bag_to_swissmedic', 'are different in swissmedic and bag', different_atc_in_swissmedic)
214
- report('compare_bag_to_swissmedic', 'are shorter in swissmedic than in bag', shorter_in_swissmedic)
215
- report('compare_bag_to_swissmedic', 'are longer in swissmedic than in bag', longer_in_swissmedic)
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
- report('compare_bag_to_swissindex', 'items had the same ATC code in bag, swissindex and swissmedic', matching_atc_codes)
219
- report('compare_bag_to_swissindex', 'are the same in swissindex and bag, but not in swissmedic', match_in_swissindex)
220
- report('compare_bag_to_swissindex', 'are different in swissmedic and bag', different_atc_in_swissindex)
221
- report('compare_bag_to_swissindex', 'are shorter in swissindex than in bag', shorter_in_swissindex)
222
- report('compare_bag_to_swissindex', 'are longer in swissindex than in bag', longer_in_swissindex)
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 << "swissindex #{gtin}: ATC code #{item[:atc_code]} matches swissindex #{@data_swissindex[gtin][:atc_code]}"
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 << "swissindex #{gtin}: ATC code #{item[:atc_code]} longer in swissindex #{@data_swissindex[gtin][:atc_code]}"
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 << "swissindex #{gtin}: ATC code #{item[:atc_code]} shorter in swissindex #{@data_swissindex[gtin][:atc_code]}"
270
+ shorter_in_swissmedic << "ATC code #{atc_code} for #{gtin} shorter in swissindex #{@data_swissindex[gtin][:atc_code]}"
264
271
  else
265
- different_atc << "swissindex #{gtin}: ATC code #{item[:atc_code]} differs from swissindex #{@data_swissindex[gtin][:atc_code]}"
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
- report('swissmedic', 'match in swissindex and swissmedic', matching_atc_codes)
282
- report('swissmedic', 'are different in swissindex and swissmedic', different_atc)
283
- report('swissmedic', 'are the same in swissindex and swissmedic', matching_atc_codes)
284
- report('swissmedic', 'are shorter in swissindex', shorter_in_swissmedic)
285
- report('swissmedic', 'are longer in swissindex', longer_in_swissindex)
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
- report('compare_all_gtins', 'items had the same ATC code in bag, swissindex and swissmedic', matching_atc_codes)
324
- report('compare_all_gtins', 'not in bag', not_in_bag)
325
- report('compare_all_gtins', 'not in swissindex', not_in_swissindex)
326
- report('compare_all_gtins', 'not in swissmedic', not_in_swissmedic)
327
- report('compare_all_gtins', 'ATC-Codes differed', different_atc)
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
@@ -1,3 +1,3 @@
1
1
  module Gtin2atc
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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
- /ATC-Codes diff/,
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 + '/compare_all_gtins*.txt').size.should == 5
157
- Dir.glob(Gtin2atc::WorkDir + '/swissmedic_*.txt').size.should == 5
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtin2atc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niklaus Giger, Zeno R.R. Davatz