oddb2xml 2.7.1 → 2.7.2

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.standard.yml +2 -0
  4. data/Gemfile +3 -3
  5. data/History.txt +8 -0
  6. data/README.md +1 -1
  7. data/Rakefile +24 -23
  8. data/bin/check_artikelstamm +11 -11
  9. data/bin/compare_v5 +23 -23
  10. data/bin/oddb2xml +14 -13
  11. data/lib/oddb2xml.rb +1 -1
  12. data/lib/oddb2xml/builder.rb +1070 -1038
  13. data/lib/oddb2xml/calc.rb +232 -233
  14. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  15. data/lib/oddb2xml/cli.rb +252 -236
  16. data/lib/oddb2xml/compare.rb +70 -59
  17. data/lib/oddb2xml/compositions_syntax.rb +448 -430
  18. data/lib/oddb2xml/compressor.rb +20 -20
  19. data/lib/oddb2xml/downloader.rb +153 -127
  20. data/lib/oddb2xml/extractor.rb +302 -289
  21. data/lib/oddb2xml/options.rb +34 -35
  22. data/lib/oddb2xml/parslet_compositions.rb +263 -269
  23. data/lib/oddb2xml/semantic_check.rb +39 -33
  24. data/lib/oddb2xml/util.rb +163 -163
  25. data/lib/oddb2xml/version.rb +1 -1
  26. data/lib/oddb2xml/xml_definitions.rb +32 -33
  27. data/oddb2xml.gemspec +31 -32
  28. data/spec/artikelstamm_spec.rb +111 -110
  29. data/spec/builder_spec.rb +489 -505
  30. data/spec/calc_spec.rb +552 -593
  31. data/spec/check_artikelstamm_spec.rb +26 -26
  32. data/spec/cli_spec.rb +173 -174
  33. data/spec/compare_spec.rb +9 -11
  34. data/spec/composition_syntax_spec.rb +390 -409
  35. data/spec/compressor_spec.rb +48 -48
  36. data/spec/data/transfer.dat +1 -0
  37. data/spec/data_helper.rb +47 -49
  38. data/spec/downloader_spec.rb +247 -260
  39. data/spec/extractor_spec.rb +171 -159
  40. data/spec/galenic_spec.rb +233 -256
  41. data/spec/options_spec.rb +116 -119
  42. data/spec/parslet_spec.rb +833 -861
  43. data/spec/spec_helper.rb +154 -153
  44. data/test_options.rb +39 -42
  45. data/tools/win_fetch_cacerts.rb +2 -3
  46. metadata +19 -3
data/spec/spec_helper.rb CHANGED
@@ -5,125 +5,125 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
  #
8
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
8
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
9
9
  $:.unshift File.dirname(__FILE__)
10
10
 
11
- require 'rspec'
12
- require 'webmock/rspec'
13
- require 'flexmock/rspec'
14
- require 'pp'
11
+ require "rspec"
12
+ require "webmock/rspec"
13
+ require "flexmock/rspec"
14
+ require "pp"
15
15
 
16
- begin # load pry if is available
17
- require 'pry'
18
- Pry.config.output = STDOUT
16
+ # load pry if is available
17
+ begin
18
+ require "pry"
19
+ Pry.config.output = $stdout
19
20
  rescue LoadError
20
21
  end
21
22
 
22
- require 'vcr'
23
- require 'timecop'
23
+ require "vcr"
24
+ require "timecop"
24
25
 
25
26
  module Oddb2xml
26
27
  # we override here a few directories to make input/output when running specs to
27
28
  # be in different places compared when running
28
- SpecData = File.join(File.dirname(__FILE__), 'data')
29
- WorkDir = File.join(File.dirname(__FILE__), 'run')
30
- Downloads = File.join(WorkDir, 'downloads')
31
- SpecCompressor = File.join(Oddb2xml::SpecData, 'compressor')
32
- DATE_REGEXP = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[-+]\d{4}/
29
+ SpecData = File.join(File.dirname(__FILE__), "data")
30
+ WORK_DIR = File.join(File.dirname(__FILE__), "run")
31
+ DOWNLOADS = File.join(WORK_DIR, "downloads")
32
+ SpecCompressor = File.join(Oddb2xml::SpecData, "compressor")
33
+ DATE_REGEXP = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[-+]\d{4}/
33
34
 
34
35
  GTINS_CALC = [
35
- '7680458820202', # for calc_spec.rb
36
- '7680555940018', # for calc_spec.rb
37
- '7680434541015', # for calc_spec.rb
38
- '7680300150105', # for calc_spec.rb
39
- '7680446250592', # for calc_spec.rb
40
- '7680611860045', # for calc_spec.rb
41
- '7680165980114', # for calc_spec.rb
42
- '7680589430011', # for calc_spec.rb
43
- '7680556740075', # for calc_spec.rb
44
- '7680540151009', # for calc_spec.rb
45
- '7680560890018', # for calc_spec.rb
46
- '7680532900196', # Insulin, gentechnik
47
- '7680555610041', # Diaphin 10 g i.v. drug
48
- ]
49
- FRIDGE_GTIN = '7680002770014' # fridge drug 7680002770014 Coeur-Vaisseaux Sérocytol, suppositoire
50
- ORPHAN_GTIN = '7680587340015' # orphan drug IKSNR 62132: Adcetris, Pulver zur Herstellung einer Infusionslösung
51
- GTINS_DRUGS = [ '733905577161', # 1-DAY ACUVUE Moist Tag -2.00dpt BC 8.5
52
- FRIDGE_GTIN,
53
- ORPHAN_GTIN,
54
- '4042809018288',
55
- '4042809018400',
56
- '4042809018493',
57
- '5000223074777',
58
- '5000223439507',
59
- '7611600441013',
60
- '7611600441020',
61
- '7611600441037',
62
- '7680161050583', # Hirudoid Creme 3 mg/g
63
- '7680172330414', # SELSUN
64
- '7680284860144',
65
- '7680316440115', # FERRO-GRADUMET Depottabl 30 Stk
66
- '7680316950157', # SOFRADEX Gtt Auric 8 ml
67
- '7680324750190', # LANSOYL Gel
68
- '7680353660163',
69
- '7680403330459',
70
- '7680536620137', # 3TC Filmtabl 150 mg
71
- '7680555580054', # ZYVOXID
72
- '7680620690084', # LEVETIRACETAM DESITIN Mini Filmtab 250 mg needed for extractor_spec.rb
73
- ] + GTINS_CALC
74
- FERRO_GRADUMET_GTIN = '7680316440115'
75
- HIRUDOID_GTIN = '7680161050583'
76
- LANSOYL_GTIN = '7680324750190'
77
- LANSOYL_PRICE_RESELLER_PUB = 18.95
78
- LANSOYL_PRICE_ZURROSE = 10.54
79
- LANSOYL_PRICE_ZURROSEPUB = 16.25
80
- LEVETIRACETAM_GTIN = '7680620690084'
81
- LEVETIRACETAM_PRICE_PPUB = 27.8
82
- LEVETIRACETAM_PRICE_ZURROSE = 13.49
83
- LEVETIRACETAM_PRICE_RESELLER_PUB = 24.3
84
- SOFRADEX_GTIN = '7680316950157'
85
- SOFRADEX_PRICE_RESELLER_PUB = 12.9
86
- SOFRADEX_PRICE_ZURROSE = 7.18
87
- SOFRADEX_PRICE_ZURROSEPUB = 15.45
88
- THREE_TC_GTIN = '7680536620137'
89
- ZYVOXID_GTIN = '7680555580054'
36
+ "7680458820202", # for calc_spec.rb
37
+ "7680555940018", # for calc_spec.rb
38
+ "7680434541015", # for calc_spec.rb
39
+ "7680300150105", # for calc_spec.rb
40
+ "7680446250592", # for calc_spec.rb
41
+ "7680611860045", # for calc_spec.rb
42
+ "7680165980114", # for calc_spec.rb
43
+ "7680589430011", # for calc_spec.rb
44
+ "7680556740075", # for calc_spec.rb
45
+ "7680540151009", # for calc_spec.rb
46
+ "7680560890018", # for calc_spec.rb
47
+ "7680532900196", # Insulin, gentechnik
48
+ "7680555610041" # Diaphin 10 g i.v. drug
49
+ ]
50
+ FRIDGE_GTIN = "7680002770014" # fridge drug 7680002770014 Coeur-Vaisseaux Sérocytol, suppositoire
51
+ ORPHAN_GTIN = "7680587340015" # orphan drug IKSNR 62132: Adcetris, Pulver zur Herstellung einer Infusionslösung
52
+ GTINS_DRUGS = ["733905577161", # 1-DAY ACUVUE Moist Tag -2.00dpt BC 8.5
53
+ FRIDGE_GTIN,
54
+ ORPHAN_GTIN,
55
+ "4042809018288",
56
+ "4042809018400",
57
+ "4042809018493",
58
+ "5000223074777",
59
+ "5000223439507",
60
+ "7611600441013",
61
+ "7611600441020",
62
+ "7611600441037",
63
+ "7680161050583", # Hirudoid Creme 3 mg/g
64
+ "7680172330414", # SELSUN
65
+ "7680284860144",
66
+ "7680316440115", # FERRO-GRADUMET Depottabl 30 Stk
67
+ "7680316950157", # SOFRADEX Gtt Auric 8 ml
68
+ "7680324750190", # LANSOYL Gel
69
+ "7680353660163",
70
+ "7680403330459",
71
+ "7680536620137", # 3TC Filmtabl 150 mg
72
+ "7680555580054", # ZYVOXID
73
+ # 7680620690084 is LEVETIRACETAM DESITIN Mini Filmtab 250 mg needed for extractor_spec.rb
74
+ "7680620690084"] +
75
+ GTINS_CALC
76
+ FERRO_GRADUMET_GTIN = "7680316440115"
77
+ HIRUDOID_GTIN = "7680161050583"
78
+ LANSOYL_GTIN = "7680324750190"
79
+ LANSOYL_PRICE_RESELLER_PUB = 18.95
80
+ LANSOYL_PRICE_ZURROSE = 10.54
81
+ LANSOYL_PRICE_ZURROSEPUB = 16.25
82
+ LEVETIRACETAM_GTIN = "7680620690084"
83
+ LEVETIRACETAM_PRICE_PPUB = 27.8
84
+ LEVETIRACETAM_PRICE_ZURROSE = 13.49
85
+ LEVETIRACETAM_PRICE_RESELLER_PUB = 24.3
86
+ SOFRADEX_GTIN = "7680316950157"
87
+ SOFRADEX_PRICE_RESELLER_PUB = 12.9
88
+ SOFRADEX_PRICE_ZURROSE = 7.18
89
+ SOFRADEX_PRICE_ZURROSEPUB = 15.45
90
+ THREE_TC_GTIN = "7680536620137"
91
+ ZYVOXID_GTIN = "7680555580054"
90
92
 
91
93
  GTINS_MEDREG = [
92
- '7601001380028', # Glarus
93
- '7601002017145', # Kantonsspital Glarus AG
94
- '7601001395145', # Kantonstierärztlicher Dienst
95
- '7601001396043', # St. Fridolin Pharma AG
96
- '7601000159199', # Davatz Ursula
97
- '7601000159199', # Davatz Ursula
98
- '7601000254344', # Pfister Daniel 8753 Mollis
99
- '7601000254207', # Züst Peter 8753 Mollis
100
- '7601000752314', # Züst Yvonne 8753 Mollis
101
- ]
102
-
94
+ "7601001380028", # Glarus
95
+ "7601002017145", # Kantonsspital Glarus AG
96
+ "7601001395145", # Kantonstierärztlicher Dienst
97
+ "7601001396043", # St. Fridolin Pharma AG
98
+ "7601000159199", # Davatz Ursula
99
+ "7601000159199", # Davatz Ursula
100
+ "7601000254344", # Pfister Daniel 8753 Mollis
101
+ "7601000254207", # Züst Peter 8753 Mollis
102
+ "7601000752314" # Züst Yvonne 8753 Mollis
103
+ ]
103
104
  end
104
105
 
105
106
  RSpec.configure do |config|
106
- config.mock_with :flexmock
107
- end
107
+ config.mock_with :flexmock
108
+ end
108
109
 
109
110
  VCR.configure do |config|
110
111
  config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
111
112
  config.hook_into :webmock
112
- config.debug_logger = File.open(File.join(File.dirname(File.dirname(__FILE__)), 'vcr.log'), 'w+')
113
+ config.debug_logger = File.open(File.join(File.dirname(File.dirname(__FILE__)), "vcr.log"), "w+")
113
114
  config.debug_logger.sync = true
114
- config.default_cassette_options = { :record =>:once, # ARGV.join(' ').index('downloader_spec') ? :new_episodes : :once ,
115
- :preserve_exact_body_bytes => true,
116
- :allow_playback_repeats => true,
117
- :serialize_with => :json,
118
- :decode_compressed_response => true,
119
- :match_requests_on => [:method, :uri, :body],
120
- }
121
- # :match_requests_on (Array<Symbol, #call>) —
122
- #
123
- # List of request matchers to use to determine what recorded HTTP interaction to replay. Defaults to [:method, :uri]. The built-in matchers are :method, :uri, :host, :path, :headers and :body. You can also pass the name of a registered custom request matcher or any object that responds to #call.
115
+ config.default_cassette_options = {record: :once, # ARGV.join(' ').index('downloader_spec') ? :new_episodes : :once ,
116
+ preserve_exact_body_bytes: true,
117
+ allow_playback_repeats: true,
118
+ serialize_with: :json,
119
+ decode_compressed_response: true,
120
+ match_requests_on: [:method, :uri, :body]}
121
+ # :match_requests_on (Array<Symbol, #call>) —
122
+ #
123
+ # List of request matchers to use to determine what recorded HTTP interaction to replay. Defaults to [:method, :uri]. The built-in matchers are :method, :uri, :host, :path, :headers and :body. You can also pass the name of a registered custom request matcher or any object that responds to #call.
124
124
 
125
125
  config.before_http_request(:real?) do |request|
126
- $stderr.puts("before real request: #{request.method} #{request.uri} #{caller[0..5].join("\n")}")
126
+ warn("before real request: #{request.method} #{request.uri} #{caller[0..5].join("\n")}")
127
127
  $stderr.flush
128
128
  end
129
129
  end
@@ -131,17 +131,20 @@ end
131
131
  AllCompositionLines = File.expand_path("#{__FILE__}/../data/compositions.txt")
132
132
  AllColumn_C_Lines = File.expand_path("#{__FILE__}/../data/column_c.txt")
133
133
 
134
- require 'oddb2xml'
134
+ require "oddb2xml"
135
135
 
136
136
  module Kernel
137
137
  def buildr_capture(stream)
138
138
  begin
139
+ # We know that standardrb complains here. But there is no time to fix it
139
140
  stream = stream.to_s
140
141
  eval "$#{stream} = StringIO.new"
141
142
  yield
142
143
  result = eval("$#{stream}").string
143
144
  ensure
144
- eval "$#{stream} = #{stream.upcase}"
145
+ eval <<-RUBY, binding, __FILE__, __LINE__ + 1
146
+ "$#{stream} = #{stream.upcase}"
147
+ RUBY
145
148
  end
146
149
  result
147
150
  end
@@ -149,19 +152,19 @@ end
149
152
 
150
153
  module ServerMockHelper
151
154
  def cleanup_compressor
152
- [ File.join(Oddb2xml::SpecCompressor, '*.zip'),
153
- File.join(Oddb2xml::SpecCompressor, '*.tar.gz'),
154
- File.join(Oddb2xml::SpecCompressor, 'epha_interactions.txt*'),
155
- File.join(Oddb2xml::SpecCompressor, 'medregbm_company.txt*'),
156
- File.join(Oddb2xml::SpecCompressor, 'medregbm_person.txt*'),
157
- File.join(Oddb2xml::SpecCompressor, 'transfer.dat.*'),
158
- File.join(Oddb2xml::SpecCompressor, 'oddb2xml_files_nonpharma.xls.*'),
159
- ].each { |file| FileUtils.rm_f(Dir.glob(file), :verbose => false) if Dir.glob(file).size > 0 }
155
+ [File.join(Oddb2xml::SpecCompressor, "*.zip"),
156
+ File.join(Oddb2xml::SpecCompressor, "*.tar.gz"),
157
+ File.join(Oddb2xml::SpecCompressor, "epha_interactions.txt*"),
158
+ File.join(Oddb2xml::SpecCompressor, "medregbm_company.txt*"),
159
+ File.join(Oddb2xml::SpecCompressor, "medregbm_person.txt*"),
160
+ File.join(Oddb2xml::SpecCompressor, "transfer.dat.*"),
161
+ File.join(Oddb2xml::SpecCompressor, "oddb2xml_files_nonpharma.xls.*")].each { |file| FileUtils.rm_f(Dir.glob(file), verbose: false) if Dir.glob(file).size > 0 }
160
162
  end
163
+
161
164
  def cleanup_directories_before_run
162
- dirs = [ Oddb2xml::Downloads, Oddb2xml::WorkDir]
163
- dirs.each{ |dir| FileUtils.rm_rf(Dir.glob(File.join(dir, '*')), :verbose => false) }
164
- dirs.each{ |dir| FileUtils.makedirs(dir, :verbose => false) }
165
+ dirs = [Oddb2xml::DOWNLOADS, Oddb2xml::WORK_DIR]
166
+ dirs.each { |dir| FileUtils.rm_rf(Dir.glob(File.join(dir, "*")), verbose: false) }
167
+ dirs.each { |dir| FileUtils.makedirs(dir, verbose: false) }
165
168
  cleanup_compressor
166
169
  mock_downloads
167
170
  end
@@ -177,9 +180,9 @@ def check_elements(xml_name, tests)
177
180
  value = test[1]
178
181
  it "should have correct entries #{value} for path #{path}" do
179
182
  found = false
180
- Nokogiri::XML(File.read(xml_name)).search(path, nil, nil).each do |x|
183
+ Nokogiri::XML(File.read(xml_name)).search(path, nil, nil).each do |x|
181
184
  if value.match(x.text)
182
- found= true
185
+ found = true
183
186
  break
184
187
  end
185
188
  end
@@ -196,8 +199,8 @@ def check_attributes(xml_name, tests)
196
199
  it "should have correct value #{value} for attribute #{attribute} in #{path}" do
197
200
  found = false
198
201
  Nokogiri::XML(File.read(xml_name)).search(path, nil, nil).each do |x|
199
- if value.match(x["#{attribute}"])
200
- found= true
202
+ if value.match(x[attribute.to_s])
203
+ found = true
201
204
  break
202
205
  end
203
206
  end
@@ -210,62 +213,60 @@ RSpec.configure do |config|
210
213
  config.run_all_when_everything_filtered = true
211
214
  config.filter_run :focus
212
215
  config.filter_run_excluding :slow
213
- #config.exclusion_filter = {:slow => true}
216
+ # config.exclusion_filter = {:slow => true}
214
217
 
215
218
  # Run specs in random order to surface order dependencies. If you find an
216
219
  # order dependency and want to debug it, you can fix the order by providing
217
220
  # the seed, which is printed after each run.
218
221
  # --seed 1234
219
- config.order = 'random'
222
+ config.order = "random"
220
223
 
221
224
  # Helper
222
225
  config.include(ServerMockHelper)
223
226
  end
224
227
 
225
228
  def validate_via_xsd(xsd_file, xml_file)
226
- xsd =open(xsd_file).read
229
+ xsd = File.open(xsd_file).read
227
230
  xsd_rtikelstamm_xml = Nokogiri::XML::Schema(xsd)
228
231
  doc = Nokogiri::XML(File.read(xml_file))
229
- xsd_rtikelstamm_xml.validate(doc).each do
230
- |error|
231
- if error.message
232
- puts "Failed validating #{xml_file} with #{File.size(xml_file)} bytes using XSD from #{xsd_file}"
233
- puts "CMD: xmllint --noout --schema #{xsd_file} #{xml_file}"
234
- end
235
- msg = "expected #{error.message} to be nil\nfor #{xml_file}"
236
- puts msg
237
- expect(error.message).to be_nil, msg
232
+ xsd_rtikelstamm_xml.validate(doc).each do |error|
233
+ if error.message
234
+ puts "Failed validating #{xml_file} with #{File.size(xml_file)} bytes using XSD from #{xsd_file}"
235
+ puts "CMD: xmllint --noout --schema #{xsd_file} #{xml_file}"
236
+ end
237
+ msg = "expected #{error.message} to be nil\nfor #{xml_file}"
238
+ puts msg
239
+ expect(error.message).to be_nil, msg
238
240
  end
239
241
  end
240
242
 
241
243
  def mock_downloads
242
- WebMock.enable!
243
- { 'transfer.zip' => ['transfer.dat'],
244
- 'XMLPublications.zip' => ['Preparations.xml', 'ItCodes.xml', 'GL_Diff_SB.xml']
245
- }.each do |zip, entries|
246
- zip_file = File.join(Oddb2xml::SpecData,zip)
247
- files = entries.collect{|entry| File.join(Oddb2xml::SpecData, entry)}
248
- FileUtils.rm(zip_file, :verbose => false) if File.exist?(zip_file)
249
- cmd = "zip --quiet --junk-paths #{zip_file} #{files.join(' ')}"
250
- system(cmd)
251
- end
252
- { 'https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/interactions_de_utf8.csv' => 'epha_interactions.csv',
253
- 'https://www.swissmedic.ch/swissmedic/de/home/services/listen_neu.html' => 'listen_neu.html',
254
- 'https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/status_ophan%20Drug.xlsx.download.xlsx/Liste_OrphanDrug_Internet_2019_01_31.xlsx' => 'swissmedic_orphan.xlsx',
255
- 'https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/zugelassene_packungen_ham.xlsx.download.xlsx/Zugelassene_Packungen%20HAM_31012019.xlsx' => 'swissmedic_package.xlsx',
256
- 'http://pillbox.oddb.org/TRANSFER.ZIP' => 'transfer.zip',
257
- 'https://github.com/zdavatz/cpp2sqlite/blob/master/input/atc_codes_multi_lingual.txt' => 'atc.csv',
258
- 'https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/LPPV.txt' => 'oddb2xml_files_lppv.txt',
259
- 'http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip' => 'XMLPublications.zip',
260
- 'http://www.spezialitaetenliste.ch/varia_De.htm' => 'varia_De.htm',
261
- # 'http://refdatabase.refdata.ch/Service/Article.asmx?WSDL' => 'refdata_Pharma.xml',
262
- }.each do |url, file|
263
- inhalt = File.read(File.join(Oddb2xml::SpecData, file))
264
- m = flexmock('open-uri')
265
- m.should_receive(:open).with(url).and_return(inhalt)
266
- stub_request(:any,url).to_return(body: inhalt)
267
- stub_request(:get,url).to_return(body: inhalt)
268
- stub_request(:open,url).to_return(body: inhalt)
269
- end
270
- VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
244
+ WebMock.enable!
245
+ {"transfer.zip" => ["transfer.dat"],
246
+ "XMLPublications.zip" => ["Preparations.xml", "ItCodes.xml", "GL_Diff_SB.xml"]}.each do |zip, entries|
247
+ zip_file = File.join(Oddb2xml::SpecData, zip)
248
+ files = entries.collect { |entry| File.join(Oddb2xml::SpecData, entry) }
249
+ FileUtils.rm(zip_file, verbose: false) if File.exist?(zip_file)
250
+ cmd = "zip --quiet --junk-paths #{zip_file} #{files.join(" ")}"
251
+ system(cmd)
252
+ end
253
+ {"https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/interactions_de_utf8.csv" => "epha_interactions.csv",
254
+ "https://www.swissmedic.ch/swissmedic/de/home/services/listen_neu.html" => "listen_neu.html",
255
+ "https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/status_ophan%20Drug.xlsx.download.xlsx/Liste_OrphanDrug_Internet_2019_01_31.xlsx" => "swissmedic_orphan.xlsx",
256
+ "https://www.swissmedic.ch/dam/swissmedic/de/dokumente/internetlisten/zugelassene_packungen_ham.xlsx.download.xlsx/Zugelassene_Packungen%20HAM_31012019.xlsx" => "swissmedic_package.xlsx",
257
+ "http://pillbox.oddb.org/TRANSFER.ZIP" => "transfer.zip",
258
+ "https://github.com/zdavatz/cpp2sqlite/blob/master/input/atc_codes_multi_lingual.txt" => "atc.csv",
259
+ "https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/LPPV.txt" => "oddb2xml_files_lppv.txt",
260
+ "http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip" => "XMLPublications.zip",
261
+ # 'http://refdatabase.refdata.ch/Service/Article.asmx?WSDL' => 'refdata_Pharma.xml
262
+ "http://www.spezialitaetenliste.ch/varia_De.htm" => "varia_De.htm"}.each do |url, file|
263
+ inhalt = File.read(File.join(Oddb2xml::SpecData, file))
264
+ m = flexmock("open-uri")
265
+ m.should_receive(:open).with(url).and_return(inhalt)
266
+ stub_request(:any, url).to_return(body: inhalt)
267
+ stub_request(:get, url).to_return(body: inhalt)
268
+ stub_request(:open, url).to_return(body: inhalt)
269
+ end
270
+ VCR.eject_cassette
271
+ VCR.insert_cassette("oddb2xml")
271
272
  end
data/test_options.rb CHANGED
@@ -5,66 +5,63 @@
5
5
  # - runs all commands (and add ---skip-download)
6
6
  # - saveds output and downloads to ausgabe/time_stamp
7
7
 
8
-
9
- require 'fileutils'
10
- require 'socket'
11
- require 'oddb2xml/version'
8
+ require "fileutils"
9
+ require "socket"
10
+ require "oddb2xml/version"
12
11
 
13
12
  def test_one_call(cmd)
14
- dest = File.join(Ausgabe, cmd.gsub(/[ -]/, '_'))
15
- all_downloads = File.join(dest, 'downloads')
16
- FileUtils.makedirs(all_downloads) unless File.exists?(all_downloads)
17
- cmd.sub!('oddb2xml', 'oddb2xml --skip-download --log')
18
- files = (Dir.glob('%.xls*') + Dir.glob('*.dat*') + Dir.glob('*.xml'))
19
- FileUtils.rm(files, :verbose => true)
13
+ dest = File.join(Ausgabe, cmd.gsub(/[ -]/, "_"))
14
+ all_downloads = File.join(dest, "downloads")
15
+ FileUtils.makedirs(all_downloads) unless File.exist?(all_downloads)
16
+ cmd.sub!("oddb2xml", "oddb2xml --skip-download --log")
17
+ files = (Dir.glob("%.xls*") + Dir.glob("*.dat*") + Dir.glob("*.xml"))
18
+ FileUtils.rm(files, verbose: true)
20
19
  puts "#{Time.now}: Running cmd #{cmd}"
21
- startTime = Time.now
20
+ start_time = Time.now
22
21
  res = system(cmd)
23
- endTime = Time.now
24
- diffSeconds = (endTime - startTime).to_i
25
- duration = "#{Time.now}: Took #{sprintf('%3d', diffSeconds)} seconds for"
22
+ end_time = Time.now
23
+ diff_seconds = (end_time - start_time).to_i
24
+ duration = "#{Time.now}: Took #{sprintf("%3d", diff_seconds)} seconds for"
26
25
  puts "#{duration} success #{res} for #{cmd}"
27
26
  exit 2 unless res
28
27
  FileUtils.makedirs(dest)
29
- return unless File.directory?('downloads')
30
- FileUtils.cp_r('downloads', dest, :preserve => true, :verbose => true) if Dir.glob(Ausgabe).size > 0
31
- FileUtils.cp(Dir.glob('*.dat'), dest, :preserve => true, :verbose => true) if Dir.glob('*.dat').size > 0
32
- FileUtils.cp(Dir.glob('*.xml'), dest, :preserve => true, :verbose => true) if Dir.glob('*.xml').size > 0
33
- FileUtils.cp(Dir.glob('*.gz'), dest, :preserve => true, :verbose => true) if Dir.glob('*.gz').size > 0
28
+ return unless File.directory?("downloads")
29
+ FileUtils.cp_r("downloads", dest, preserve: true, verbose: true) if Dir.glob(Ausgabe).size > 0
30
+ FileUtils.cp(Dir.glob("*.dat"), dest, preserve: true, verbose: true) if Dir.glob("*.dat").size > 0
31
+ FileUtils.cp(Dir.glob("*.xml"), dest, preserve: true, verbose: true) if Dir.glob("*.xml").size > 0
32
+ FileUtils.cp(Dir.glob("*.gz"), dest, preserve: true, verbose: true) if Dir.glob("*.gz").size > 0
34
33
  downloaded_files = Dir.glob("#{dest}/*/downloads/*")
35
- FileUtils.mv(downloaded_files, all_downloads, :verbose => true) if downloaded_files.size > 0
36
- FileUtils.rm(Dir.glob("#{dest}/*#{Time.now.year}*.xml"), :verbose => true)
34
+ FileUtils.mv(downloaded_files, all_downloads, verbose: true) if downloaded_files.size > 0
35
+ FileUtils.rm(Dir.glob("#{dest}/*#{Time.now.year}*.xml"), verbose: true)
37
36
  end
38
37
 
39
38
  def prepare_for_gem_test
40
- [ "rake clean gem install" , # build and install our gem first
41
- # "gem uninstall --all --ignore-dependencies --executables",
42
- "gem install --no-ri --no-rdoc pkg/*.gem"
43
- ].each {
44
- |cmd|
45
- puts "Running #{cmd}"
46
- exit 1 unless system(cmd)
39
+ ["rake clean gem install", # build and install our gem first
40
+ # "gem uninstall --all --ignore-dependencies --executables",
41
+ "gem install --no-ri --no-rdoc pkg/*.gem"].each { |cmd|
42
+ puts "Running #{cmd}"
43
+ exit 1 unless system(cmd)
47
44
  }
48
45
  end
49
46
 
50
- Ausgabe = File.join(Dir.pwd, 'ausgabe', "#{Oddb2xml::VERSION}-#{Time.now.strftime('%Y.%m.%d')}")
47
+ Ausgabe = File.join(Dir.pwd, "ausgabe", "#{Oddb2xml::VERSION}-#{Time.now.strftime("%Y.%m.%d")}")
51
48
  puts "FQDN hostname #{Socket.gethostbyname(Socket.gethostname).inspect}"
52
49
  FileUtils.makedirs(Ausgabe)
53
50
  prepare_for_gem_test
54
51
  # we will skip some long running tests as travis jobs must finish in less than 50 minutes
55
52
  # unfortunately it returns a very common name
56
- unless 'localhost.localdomain'.eql?(Socket.gethostbyname(Socket.gethostname).first)
57
- test_one_call('oddb2xml -e')
58
- test_one_call('oddb2xml --artikelstamm')
59
- test_one_call('oddb2xml -e -I80')
60
- test_one_call('oddb2xml -f dat --append -I 80')
61
- test_one_call('oddb2xml -f dat --append')
62
- test_one_call('oddb2xml --append')
53
+ unless "localhost.localdomain".eql?(Socket.gethostbyname(Socket.gethostname).first)
54
+ test_one_call("oddb2xml -e")
55
+ test_one_call("oddb2xml --artikelstamm")
56
+ test_one_call("oddb2xml -e -I80")
57
+ test_one_call("oddb2xml -f dat --append -I 80")
58
+ test_one_call("oddb2xml -f dat --append")
59
+ test_one_call("oddb2xml --append")
63
60
  end
64
- test_one_call('oddb2xml --calc')
65
- test_one_call('oddb2xml -t md -c tar.gz')
66
- test_one_call('oddb2xml -o')
67
- test_one_call('oddb2xml -f xml')
68
- test_one_call('oddb2xml -f dat')
69
- test_one_call('oddb2xml -t md')
61
+ test_one_call("oddb2xml --calc")
62
+ test_one_call("oddb2xml -t md -c tar.gz")
63
+ test_one_call("oddb2xml -o")
64
+ test_one_call("oddb2xml -f xml")
65
+ test_one_call("oddb2xml -f dat")
66
+ test_one_call("oddb2xml -t md")
70
67
  # test_one_call('oddb2xml -x address')