oddb2xml 2.2.6 → 2.2.7
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 +4 -4
- data/.gitignore +18 -0
- data/Gemfile.lock +28 -28
- data/History.txt +6 -0
- data/lib/oddb2xml/builder.rb +8 -8
- data/lib/oddb2xml/cli.rb +5 -6
- data/lib/oddb2xml/extractor.rb +12 -4
- data/lib/oddb2xml/version.rb +1 -1
- data/oddb2xml.xsd +2 -1
- data/spec/builder_spec.rb +159 -137
- data/spec/calc_spec.rb +40 -40
- data/spec/cli_spec.rb +57 -55
- data/spec/compressor_spec.rb +16 -16
- data/spec/data/swissmedic_fridge.xlsx +0 -0
- data/spec/data/swissmedic_orphan.xlsx +0 -0
- data/spec/data/swissmedic_package.xlsx +0 -0
- data/spec/downloader_spec.rb +50 -45
- data/spec/extractor_spec.rb +8 -8
- data/spec/fixtures/vcr_cassettes/oddb2xml.json +660 -1599
- data/spec/spec_helper.rb +5 -1
- metadata +2 -2
data/spec/downloader_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
|
+
require "rexml/document"
|
3
4
|
|
4
5
|
VCR.eject_cassette # we use insert/eject around each example
|
5
6
|
|
@@ -60,7 +61,7 @@ shared_examples_for 'any downloader' do
|
|
60
61
|
expect {
|
61
62
|
Array.new(3).map do
|
62
63
|
Thread.new do
|
63
|
-
@downloader.send(:retrievable?).
|
64
|
+
expect(@downloader.send(:retrievable?)).to be(true)
|
64
65
|
end
|
65
66
|
end.map(&:join)
|
66
67
|
}.to change {
|
@@ -155,13 +156,13 @@ describe Oddb2xml::RefdataDownloader do
|
|
155
156
|
it_behaves_like 'any downloader'
|
156
157
|
context 'when download_by is called' do
|
157
158
|
it 'should parse response hash to xml' do
|
158
|
-
@xml.
|
159
|
-
@xml.length.
|
160
|
-
@xml.
|
159
|
+
expect(@xml).to be_a String
|
160
|
+
expect(@xml.length).not_to eq(0)
|
161
|
+
expect(@xml).to match(XML_VERSION_1_0)
|
161
162
|
end
|
162
163
|
it 'should return valid xml' do
|
163
|
-
@xml.
|
164
|
-
@xml.
|
164
|
+
expect(@xml).to match(/PHAR/)
|
165
|
+
expect(@xml).to match(/ITEM/)
|
165
166
|
end
|
166
167
|
end
|
167
168
|
end
|
@@ -174,13 +175,13 @@ describe Oddb2xml::RefdataDownloader do
|
|
174
175
|
end
|
175
176
|
context 'when download_by is ' do
|
176
177
|
it 'should parse response hash to xml' do
|
177
|
-
@xml.
|
178
|
-
@xml.length.
|
179
|
-
@xml.
|
178
|
+
expect(@xml).to be_a String
|
179
|
+
expect(@xml.length).not_to eq(0)
|
180
|
+
expect(@xml).to match(XML_VERSION_1_0)
|
180
181
|
end
|
181
182
|
it 'should return valid xml' do
|
182
|
-
@xml.
|
183
|
-
@xml.
|
183
|
+
expect(@xml).to match(/NONPHAR/)
|
184
|
+
expect(@xml).to match(/ITEM/)
|
184
185
|
end
|
185
186
|
end
|
186
187
|
end
|
@@ -250,14 +251,14 @@ end
|
|
250
251
|
}
|
251
252
|
it 'should return valid Binary-String' do
|
252
253
|
# unless [:orphan, :package].index(@downloader.type)
|
253
|
-
bin.
|
254
|
-
bin.bytes.
|
254
|
+
expect(bin).to be_a String
|
255
|
+
expect(bin.bytes).not_to be nil
|
255
256
|
# end
|
256
257
|
end
|
257
258
|
it 'should clean up current directory' do
|
258
259
|
unless [:orphan, :package].index(@downloader.type)
|
259
260
|
expect { bin }.not_to raise_error
|
260
|
-
File.exist?('oddb_orphan.xls').
|
261
|
+
expect(File.exist?('oddb_orphan.xls')).to eq(false)
|
261
262
|
end
|
262
263
|
end
|
263
264
|
end
|
@@ -275,8 +276,8 @@ end
|
|
275
276
|
@downloader.download
|
276
277
|
}
|
277
278
|
it 'should return valid Binary-String' do
|
278
|
-
bin.
|
279
|
-
bin.bytes.
|
279
|
+
expect(bin).to be_a String
|
280
|
+
expect(bin.bytes).not_to be nil
|
280
281
|
end
|
281
282
|
end
|
282
283
|
end
|
@@ -293,8 +294,8 @@ end
|
|
293
294
|
@downloader.download
|
294
295
|
}
|
295
296
|
it 'should return valid Binary-String' do
|
296
|
-
bin.
|
297
|
-
bin.bytes.
|
297
|
+
expect(bin).to be_a String
|
298
|
+
expect(bin.bytes).not_to be nil
|
298
299
|
end
|
299
300
|
end
|
300
301
|
end
|
@@ -333,8 +334,8 @@ describe Oddb2xml::EphaDownloader do
|
|
333
334
|
@downloader.download
|
334
335
|
}
|
335
336
|
it 'should read csv as String' do
|
336
|
-
csv.
|
337
|
-
csv.bytes.
|
337
|
+
expect(csv).to be_a String
|
338
|
+
expect(csv.bytes).not_to be nil
|
338
339
|
end
|
339
340
|
it 'should clean up current directory' do
|
340
341
|
expect { csv }.not_to raise_error
|
@@ -389,13 +390,13 @@ describe Oddb2xml::BagXmlDownloader do
|
|
389
390
|
end
|
390
391
|
}
|
391
392
|
it 'should parse zip to string' do
|
392
|
-
xml.
|
393
|
-
xml.length.
|
393
|
+
expect(xml).to be_a String
|
394
|
+
expect(xml.length).not_to eq(0)
|
394
395
|
end
|
395
396
|
it 'should return valid xml' do
|
396
|
-
xml.
|
397
|
-
xml.
|
398
|
-
xml.
|
397
|
+
expect(xml).to match(XML_VERSION_1_0)
|
398
|
+
expect(xml).to match(/Preparations/)
|
399
|
+
expect(xml).to match(/DescriptionDe/)
|
399
400
|
end
|
400
401
|
end
|
401
402
|
end
|
@@ -415,8 +416,8 @@ describe Oddb2xml::LppvDownloader do
|
|
415
416
|
context 'when download is called' do
|
416
417
|
let(:txt) { @downloader.download }
|
417
418
|
it 'should read txt as String' do
|
418
|
-
@text.
|
419
|
-
@text.bytes.
|
419
|
+
expect(@text).to be_a String
|
420
|
+
expect(@text.bytes).not_to be nil
|
420
421
|
end
|
421
422
|
end
|
422
423
|
end
|
@@ -435,12 +436,12 @@ describe Oddb2xml::MigelDownloader do
|
|
435
436
|
context 'when download is called' do
|
436
437
|
let(:bin) { @downloader.download }
|
437
438
|
it 'should read xls as Binary-String' do
|
438
|
-
bin.
|
439
|
-
bin.bytes.
|
439
|
+
expect(bin).to be_a String
|
440
|
+
expect(bin.bytes).not_to be nil
|
440
441
|
end
|
441
442
|
it 'should clean up current directory' do
|
442
443
|
expect { bin }.not_to raise_error
|
443
|
-
File.exist?('oddb2xml_files_nonpharma.txt').
|
444
|
+
expect(File.exist?('oddb2xml_files_nonpharma.txt')).to eq(false)
|
444
445
|
end
|
445
446
|
end
|
446
447
|
end
|
@@ -471,12 +472,12 @@ describe Oddb2xml::ZurroseDownloader do
|
|
471
472
|
context 'when download is called' do
|
472
473
|
let(:dat) { @downloader.download }
|
473
474
|
it 'should read dat as String' do
|
474
|
-
dat.
|
475
|
-
dat.bytes.
|
475
|
+
expect(dat).to be_a String
|
476
|
+
expect(dat.bytes).not_to be nil
|
476
477
|
end
|
477
478
|
it 'should clean up current directory' do
|
478
479
|
expect { dat }.not_to raise_error
|
479
|
-
File.exist?('oddb2xml_zurrose_transfer.dat').
|
480
|
+
expect(File.exist?('oddb2xml_zurrose_transfer.dat')).to eq(false)
|
480
481
|
end
|
481
482
|
end
|
482
483
|
end
|
@@ -528,12 +529,14 @@ describe Oddb2xml::MedregbmDownloader do
|
|
528
529
|
context 'download betrieb txt' do
|
529
530
|
let(:txt) { @downloader.download }
|
530
531
|
it 'should return valid String' do
|
531
|
-
|
532
|
-
txt.
|
532
|
+
pending 'Should handle SSL issues'
|
533
|
+
expect(txt).to be_a String
|
534
|
+
expect(txt.bytes).not_to be nil
|
533
535
|
end
|
534
536
|
it 'should clean up current directory' do
|
537
|
+
pending 'Should handle SSL issues'
|
535
538
|
expect { txt }.not_to raise_error
|
536
|
-
File.exist?('oddb_company.xls').
|
539
|
+
expect(File.exist?('oddb_company.xls')).to eq(false)
|
537
540
|
end
|
538
541
|
end
|
539
542
|
end
|
@@ -551,12 +554,14 @@ describe Oddb2xml::MedregbmDownloader do
|
|
551
554
|
@downloader.download
|
552
555
|
}
|
553
556
|
it 'should return valid String' do
|
554
|
-
|
555
|
-
txt.
|
557
|
+
pending 'Should handle SSL issues'
|
558
|
+
expect(txt).to be_a String
|
559
|
+
expect(txt.bytes).not_to be nil
|
556
560
|
end
|
557
561
|
it 'should clean up current directory' do
|
562
|
+
pending 'Should handle SSL issues'
|
558
563
|
expect { txt }.not_to raise_error
|
559
|
-
File.exist?('oddb_person.xls').
|
564
|
+
expect(File.exist?('oddb_person.xls')).to eq(false)
|
560
565
|
end
|
561
566
|
end
|
562
567
|
end
|
@@ -594,17 +599,17 @@ describe Oddb2xml::SwissmedicInfoDownloader do
|
|
594
599
|
context 'when download is called' do
|
595
600
|
let(:xml) { @downloader.download }
|
596
601
|
it 'should parse zip to String' do
|
597
|
-
xml.
|
598
|
-
xml.length.
|
602
|
+
expect(xml).to be_a String
|
603
|
+
expect(xml.length).not_to eq(0)
|
599
604
|
end
|
600
605
|
it 'should return valid xml' do
|
601
|
-
xml.
|
602
|
-
xml.
|
603
|
-
xml.
|
606
|
+
expect(xml).to match(XML_VERSION_1_0)
|
607
|
+
expect(xml).to match(/medicalInformations/)
|
608
|
+
expect(xml).to match(/content/)
|
604
609
|
end
|
605
610
|
it 'should clean up current directory' do
|
606
611
|
expect { xml }.not_to raise_error
|
607
|
-
File.exist?('swissmedic_info.zip').
|
612
|
+
expect(File.exist?('swissmedic_info.zip')).to eq(false)
|
608
613
|
end
|
609
614
|
end
|
610
615
|
end
|
data/spec/extractor_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require "#{Dir.pwd}/lib/oddb2xml/downloader"
|
5
5
|
ENV['TZ'] = 'UTC' # needed for last_change
|
6
6
|
LAST_CHANGE = "2015-07-03 00:00:00 +0000"
|
7
|
-
NR_PACKS =
|
7
|
+
NR_PACKS = 23
|
8
8
|
|
9
9
|
describe Oddb2xml::LppvExtractor do
|
10
10
|
before(:all) {
|
@@ -39,7 +39,7 @@ end
|
|
39
39
|
describe Oddb2xml::RefdataExtractor do
|
40
40
|
before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
|
41
41
|
after(:all) { VCR.eject_cassette }
|
42
|
-
@@last_change = '2015-
|
42
|
+
@@last_change = '2015-11-24 00:00:00 +0000'
|
43
43
|
|
44
44
|
context 'should handle pharma articles' do
|
45
45
|
subject do
|
@@ -64,7 +64,7 @@ describe Oddb2xml::RefdataExtractor do
|
|
64
64
|
:company_name=>"Desitin Pharma GmbH",
|
65
65
|
:company_ean=>"7601001320451"}
|
66
66
|
expect(item_found).to eq(expected)
|
67
|
-
expect(@pharma_items.size).to eq(
|
67
|
+
expect(@pharma_items.size).to eq(19)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
context 'should handle nonpharma articles' do
|
@@ -208,7 +208,7 @@ describe Oddb2xml::SwissmedicExtractor do
|
|
208
208
|
it {
|
209
209
|
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
|
210
210
|
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :fridge).to_arry
|
211
|
-
expect(@packs.size).to eq
|
211
|
+
expect(@packs.size).to eq 16
|
212
212
|
expect(@packs[0]).to eq("58618")
|
213
213
|
expect(@packs[1]).to eq("00696")
|
214
214
|
}
|
@@ -218,7 +218,7 @@ describe Oddb2xml::SwissmedicExtractor do
|
|
218
218
|
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
|
219
219
|
expect(File.exists?(@filename)).to eq(true), "File #{@filename} must exists"
|
220
220
|
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :orphan).to_arry
|
221
|
-
expect(@packs.size).to eq
|
221
|
+
expect(@packs.size).to eq 95
|
222
222
|
expect(@packs.first).to eq("62132")
|
223
223
|
expect(@packs[7]).to eq("00687")
|
224
224
|
}
|
@@ -239,8 +239,8 @@ describe Oddb2xml::EphaExtractor do
|
|
239
239
|
end
|
240
240
|
|
241
241
|
describe Oddb2xml::MedregbmExtractor do
|
242
|
-
before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
|
243
|
-
after(:all) { VCR.eject_cassette }
|
242
|
+
# before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
|
243
|
+
# after(:all) { VCR.eject_cassette }
|
244
244
|
it "pending"
|
245
245
|
end
|
246
246
|
|
@@ -262,7 +262,7 @@ describe Oddb2xml::ZurroseExtractor do
|
|
262
262
|
DAT
|
263
263
|
Oddb2xml::ZurroseExtractor.new(dat)
|
264
264
|
end
|
265
|
-
it { subject.to_hash.size.
|
265
|
+
it { expect(subject.to_hash.size).to eq(1) }
|
266
266
|
end
|
267
267
|
context 'when expected line is given' do
|
268
268
|
subject do
|