oddb2xml 2.7.1 → 2.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -2
- data/.standard.yml +2 -0
- data/Gemfile +3 -3
- data/History.txt +24 -0
- data/README.md +3 -3
- data/Rakefile +24 -23
- data/bin/check_artikelstamm +11 -11
- data/bin/compare_v5 +23 -23
- data/bin/oddb2xml +14 -13
- data/lib/oddb2xml/builder.rb +1070 -1038
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -236
- data/lib/oddb2xml/compare.rb +70 -59
- data/lib/oddb2xml/compositions_syntax.rb +451 -430
- data/lib/oddb2xml/compressor.rb +20 -20
- data/lib/oddb2xml/downloader.rb +157 -129
- data/lib/oddb2xml/extractor.rb +295 -295
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +265 -269
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +163 -163
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/lib/oddb2xml.rb +1 -1
- data/oddb2xml.gemspec +34 -34
- data/shell.nix +17 -0
- data/spec/artikelstamm_spec.rb +111 -110
- data/spec/builder_spec.rb +490 -505
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +173 -174
- data/spec/compare_spec.rb +9 -11
- data/spec/composition_syntax_spec.rb +390 -409
- data/spec/compressor_spec.rb +48 -48
- data/spec/data/transfer.dat +1 -0
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +251 -260
- data/spec/extractor_spec.rb +171 -159
- data/spec/fixtures/vcr_cassettes/oddb2xml.json +1 -1
- data/spec/galenic_spec.rb +233 -256
- data/spec/options_spec.rb +116 -119
- data/spec/parslet_spec.rb +896 -863
- data/spec/spec_helper.rb +153 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +42 -12
data/spec/compressor_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@compressor.contents << File.join(Oddb2xml::SpecCompressor,
|
8
|
-
@compressor.contents << File.join(Oddb2xml::SpecCompressor,
|
9
|
-
@compressor.contents << File.join(Oddb2xml::SpecCompressor,
|
10
|
-
@compressor.contents << File.join(Oddb2xml::SpecCompressor,
|
11
|
-
|
12
|
-
@compressor.
|
13
|
-
expect(@compressor.finalize!).not_to be nil
|
3
|
+
shared_examples_for "any compressor" do
|
4
|
+
it "should create compress file" do
|
5
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, "oddb_article.xml")
|
6
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, "oddb_product.xml")
|
7
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, "oddb_substance.xml")
|
8
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, "oddb_limitation.xml")
|
9
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, "oddb_fi.xml")
|
10
|
+
@compressor.contents << File.join(Oddb2xml::SpecCompressor, "oddb_fi_product.xml")
|
11
|
+
%(
|
12
|
+
expect{@compressor.finalize!}.not_to be nil
|
14
13
|
compress_file = @compressor.instance_variable_get(:@compress_file)
|
15
|
-
expect(File.
|
14
|
+
expect(File.exist?(compress_file)).to eq(true)
|
16
15
|
@compressor = nil
|
16
|
+
)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,96 +22,96 @@ describe Oddb2xml::Compressor do
|
|
22
22
|
cleanup_compressor
|
23
23
|
if @compress_file
|
24
24
|
compress_file = @compressor.instance_variable_get(:@compress_file)
|
25
|
-
FileUtils.rm_f(compress_file, :
|
25
|
+
FileUtils.rm_f(compress_file, verbose: true)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
after(:all) do
|
29
29
|
cleanup_compressor
|
30
30
|
end
|
31
|
-
context
|
32
|
-
context
|
31
|
+
context "at initialize" do
|
32
|
+
context " argment is given" do
|
33
33
|
before(:each) do
|
34
34
|
cleanup_directories_before_run
|
35
35
|
@compressor = Oddb2xml::Compressor.new
|
36
36
|
end
|
37
|
-
it
|
37
|
+
it "should have empty contents as array" do
|
38
38
|
expect(@compressor.contents).to be_a Array
|
39
39
|
expect(@compressor.contents).to be_empty
|
40
40
|
end
|
41
|
-
it
|
42
|
-
expect(@compressor.instance_variable_get(:@compress_file))
|
43
|
-
to match(/oddb_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.tar\.gz/)
|
41
|
+
it "should have formated filename with datetime" do
|
42
|
+
expect(@compressor.instance_variable_get(:@compress_file))
|
43
|
+
.to match(/oddb_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.tar\.gz/)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
context "when swiss prefix is given" do
|
47
47
|
before(:each) do
|
48
48
|
cleanup_directories_before_run
|
49
|
-
@compressor = Oddb2xml::Compressor.new(
|
49
|
+
@compressor = Oddb2xml::Compressor.new("swiss", {compress_ext: "tar.gz"})
|
50
50
|
end
|
51
|
-
it
|
52
|
-
expect(@compressor.instance_variable_get(:@compress_file))
|
53
|
-
to match(/swiss_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.tar\.gz/)
|
51
|
+
it "should have formated filename with datetime" do
|
52
|
+
expect(@compressor.instance_variable_get(:@compress_file))
|
53
|
+
.to match(/swiss_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.tar\.gz/)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
context "when tar.gz ext is given" do
|
57
57
|
before(:each) do
|
58
58
|
cleanup_directories_before_run
|
59
|
-
@compressor = Oddb2xml::Compressor.new(
|
59
|
+
@compressor = Oddb2xml::Compressor.new("oddb", {compress_ext: "tar.gz"})
|
60
60
|
end
|
61
|
-
it
|
62
|
-
expect(@compressor.instance_variable_get(:@compress_file))
|
63
|
-
to match(/oddb_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.tar\.gz/)
|
61
|
+
it "should have formated filename with datetime" do
|
62
|
+
expect(@compressor.instance_variable_get(:@compress_file))
|
63
|
+
.to match(/oddb_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.tar\.gz/)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
context "when zip ext is given" do
|
67
67
|
before(:each) do
|
68
68
|
cleanup_directories_before_run
|
69
|
-
@compressor = Oddb2xml::Compressor.new(
|
69
|
+
@compressor = Oddb2xml::Compressor.new("oddb", {compress_ext: "zip"})
|
70
70
|
end
|
71
|
-
it
|
72
|
-
expect(@compressor.instance_variable_get(:@compress_file))
|
73
|
-
to match(/oddb_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.zip/)
|
71
|
+
it "should have formated filename with datetime" do
|
72
|
+
expect(@compressor.instance_variable_get(:@compress_file))
|
73
|
+
.to match(/oddb_xml_\d{2}.\d{2}.\d{4}_\d{2}.\d{2}.zip/)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
context
|
78
|
-
context
|
77
|
+
context "when finalize! is called" do
|
78
|
+
context "unexpectedly" do
|
79
79
|
before(:each) do
|
80
80
|
cleanup_directories_before_run
|
81
|
-
@
|
81
|
+
@saved_dir = Dir.pwd
|
82
82
|
Dir.chdir Oddb2xml::SpecCompressor
|
83
83
|
@compressor = Oddb2xml::Compressor.new
|
84
84
|
end
|
85
85
|
after(:each) do
|
86
|
-
Dir.chdir @
|
86
|
+
Dir.chdir @saved_dir if @saved_dir && File.directory?(@saved_dir)
|
87
87
|
end
|
88
|
-
it
|
88
|
+
it "should fail with no contents" do
|
89
89
|
expect(@compressor.finalize!).to eq(false)
|
90
90
|
end
|
91
|
-
it
|
92
|
-
@compressor.contents <<
|
93
|
-
expect
|
91
|
+
it "should fail with invalid file" do
|
92
|
+
@compressor.contents << "../invalid_file"
|
93
|
+
expect { @compressor.finalize! }.to raise_error(RuntimeError)
|
94
94
|
end
|
95
95
|
end
|
96
|
-
context
|
97
|
-
context
|
96
|
+
context "successfully" do
|
97
|
+
context "with tar.gz" do
|
98
98
|
before(:each) do
|
99
99
|
cleanup_directories_before_run
|
100
100
|
@compressor = Oddb2xml::Compressor.new
|
101
101
|
end
|
102
|
-
it_behaves_like
|
102
|
+
it_behaves_like "any compressor"
|
103
103
|
end
|
104
|
-
context
|
104
|
+
context "with zip" do
|
105
105
|
before(:each) do
|
106
106
|
cleanup_directories_before_run
|
107
|
-
@
|
107
|
+
@saved_dir = Dir.pwd
|
108
108
|
Dir.chdir Oddb2xml::SpecCompressor
|
109
|
-
@compressor = Oddb2xml::Compressor.new(
|
109
|
+
@compressor = Oddb2xml::Compressor.new("oddb", {compress_ext: "zip"})
|
110
110
|
end
|
111
111
|
after(:each) do
|
112
|
-
Dir.chdir @
|
112
|
+
Dir.chdir @saved_dir if @saved_dir && File.directory?(@saved_dir)
|
113
113
|
end
|
114
|
-
it_behaves_like
|
114
|
+
it_behaves_like "any compressor"
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
data/spec/data/transfer.dat
CHANGED
@@ -69,5 +69,6 @@
|
|
69
69
|
1122069562EINF ARZNEI Urtinktur 1-10g/ml 0010040013401000000000025000005884712
|
70
70
|
1122069639EINF ARZNEI Ceres Urtinktur spez 20ml 0023440031301000000000025000005885322
|
71
71
|
1122069622EINF ARZNEI Ceres Urtinktur 20ml 0018870025201000000000025000005885252
|
72
|
+
1130361821SEROCYTOL Kolon Supp 3 Stk 002275003960401B080700076800027800132
|
72
73
|
1131770177VARILRIX Trockensub c Solv (alt) Fertspr 0.5 ml 004768006650101B080800076800058500102
|
73
74
|
1127766692VARILRIX Trockensub c Solv Fertspr 0.5 ml 004767006650101B080800076800058500342
|
data/spec/data_helper.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift File.join(File.dirname(__FILE__))
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
module Oddb2xml
|
5
|
-
# Small helper script to see, whether all files are correctly filled
|
6
|
-
def
|
5
|
+
# Small helper script to see, whether all files are correctly filled
|
6
|
+
def self.fill
|
7
7
|
start_keys = [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
]
|
36
|
-
|
37
|
-
gtins = GTINS_DRUGS + [ FERRO_GRADUMET_GTIN,
|
38
|
-
HIRUDOID_GTIN,LANSOYL_GTIN, LEVETIRACETAM_GTIN,
|
39
|
-
SOFRADEX_GTIN, THREE_TC_GTIN, ZYVOXID_GTIN]
|
40
|
-
gtins.each{|gtin| Oddb2xml.check_gtin(gtin)}
|
8
|
+
1125822801,
|
9
|
+
1125830700,
|
10
|
+
1122465312,
|
11
|
+
1120020209,
|
12
|
+
1120020244,
|
13
|
+
1130020646,
|
14
|
+
1120020652,
|
15
|
+
1130021806,
|
16
|
+
1130021976,
|
17
|
+
1130023722,
|
18
|
+
1130027447,
|
19
|
+
1130028470,
|
20
|
+
1135366964,
|
21
|
+
1122871437,
|
22
|
+
1122871443,
|
23
|
+
1122871466,
|
24
|
+
1122871472,
|
25
|
+
1132867163,
|
26
|
+
1138110429,
|
27
|
+
1130598003,
|
28
|
+
1125565072,
|
29
|
+
1126000923,
|
30
|
+
1128111222,
|
31
|
+
1128111718,
|
32
|
+
1128807890,
|
33
|
+
1117199565,
|
34
|
+
1128111611
|
35
|
+
]
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
gtins = GTINS_DRUGS + [FERRO_GRADUMET_GTIN,
|
38
|
+
HIRUDOID_GTIN, LANSOYL_GTIN, LEVETIRACETAM_GTIN,
|
39
|
+
SOFRADEX_GTIN, THREE_TC_GTIN, ZYVOXID_GTIN]
|
40
|
+
gtins.each { |gtin| Oddb2xml.check_gtin(gtin) }
|
41
|
+
|
42
|
+
ENV["LANG"] = "de_CH.ISO-8859"
|
43
|
+
outfile = "spec/data/transfer.dat"
|
44
|
+
FileUtils.rm_f(outfile, verbose: true)
|
45
45
|
start_keys.each do |key|
|
46
46
|
cmd = "egrep '^#{key}' downloads/transfer.dat >> #{outfile}"
|
47
47
|
system(cmd)
|
@@ -50,23 +50,21 @@ module Oddb2xml
|
|
50
50
|
gtins.each do |key|
|
51
51
|
cmd = "grep #{key} downloads/transfer.dat >> #{outfile}"
|
52
52
|
system(cmd)
|
53
|
-
iksnrs << key.to_s[4..8] if /^7680/i.match(key.to_s)
|
53
|
+
iksnrs << key.to_s[4..8] if /^7680/i.match?(key.to_s)
|
54
54
|
end
|
55
55
|
puts "Created #{outfile} #{File.size(outfile)} bytes"
|
56
|
-
puts "Used IKSNRS are #{iksnrs.sort.uniq.join(
|
56
|
+
puts "Used IKSNRS are #{iksnrs.sort.uniq.join(" ")}"
|
57
57
|
end
|
58
|
-
|
59
|
-
def
|
58
|
+
|
59
|
+
def self.check_gtin(gtin)
|
60
60
|
files = `grep -l #{gtin} downloads/*.xml`.split("\n")
|
61
61
|
files.each do |file|
|
62
|
-
short = File.join(SpecData,File.basename(file))
|
63
|
-
|
64
|
-
|
65
|
-
puts "Could not find #{gtin} in #{short}" unless
|
62
|
+
short = File.join(SpecData, File.basename(file))
|
63
|
+
nr_matches = 0
|
64
|
+
nr_matches = `grep -c #{gtin} #{short}`.to_i if File.exist?(short)
|
65
|
+
puts "Could not find #{gtin} in #{short}" unless nr_matches > 0
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
Oddb2xml.fill
|
71
|
-
|
72
|
-
|