oddb2xml 2.6.7 → 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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +40 -0
  3. data/.standard.yml +2 -0
  4. data/Elexis_Artikelstamm_v5.xsd +0 -3
  5. data/Gemfile +3 -3
  6. data/History.txt +30 -0
  7. data/README.md +1 -1
  8. data/Rakefile +24 -23
  9. data/bin/check_artikelstamm +11 -11
  10. data/bin/compare_v5 +23 -23
  11. data/bin/oddb2xml +14 -13
  12. data/lib/oddb2xml.rb +1 -1
  13. data/lib/oddb2xml/builder.rb +1077 -1039
  14. data/lib/oddb2xml/calc.rb +232 -233
  15. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  16. data/lib/oddb2xml/cli.rb +252 -233
  17. data/lib/oddb2xml/compare.rb +70 -59
  18. data/lib/oddb2xml/compositions_syntax.rb +448 -430
  19. data/lib/oddb2xml/compressor.rb +20 -20
  20. data/lib/oddb2xml/downloader.rb +155 -129
  21. data/lib/oddb2xml/extractor.rb +302 -296
  22. data/lib/oddb2xml/options.rb +34 -35
  23. data/lib/oddb2xml/parslet_compositions.rb +263 -265
  24. data/lib/oddb2xml/semantic_check.rb +39 -33
  25. data/lib/oddb2xml/util.rb +169 -159
  26. data/lib/oddb2xml/version.rb +1 -1
  27. data/lib/oddb2xml/xml_definitions.rb +32 -33
  28. data/oddb2xml.gemspec +32 -30
  29. data/spec/artikelstamm_spec.rb +139 -132
  30. data/spec/builder_spec.rb +495 -524
  31. data/spec/calc_spec.rb +552 -593
  32. data/spec/check_artikelstamm_spec.rb +26 -26
  33. data/spec/cli_spec.rb +182 -157
  34. data/spec/compare_spec.rb +9 -11
  35. data/spec/composition_syntax_spec.rb +390 -409
  36. data/spec/compressor_spec.rb +48 -48
  37. data/spec/data/Preparations.xml +139 -3
  38. data/spec/data/refdata_NonPharma.xml +0 -3
  39. data/spec/data/refdata_Pharma.xml +10 -25
  40. data/spec/data/swissmedic_package.xlsx +0 -0
  41. data/spec/data/transfer.dat +3 -1
  42. data/spec/data/varia_De.htm +2 -2
  43. data/spec/data_helper.rb +47 -49
  44. data/spec/downloader_spec.rb +247 -260
  45. data/spec/extractor_spec.rb +173 -165
  46. data/spec/galenic_spec.rb +233 -256
  47. data/spec/options_spec.rb +116 -119
  48. data/spec/parslet_spec.rb +833 -861
  49. data/spec/spec_helper.rb +154 -153
  50. data/test_options.rb +39 -42
  51. data/tools/win_fetch_cacerts.rb +2 -3
  52. metadata +49 -5
  53. data/.travis.yml +0 -30
@@ -1,46 +1,46 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'oddb2xml/semantic_check'
1
+ require "spec_helper"
2
+ require "oddb2xml/semantic_check"
3
+ CHECK_DIR = File.expand_path(File.join(File.dirname(__FILE__), "data", "check_artikelstamm"))
5
4
 
6
5
  describe Oddb2xml::SemanticCheck do
7
- CheckDir = File.expand_path(File.join(File.dirname(__FILE__), 'data', 'check_artikelstamm'))
8
-
9
6
  def common_run_init(options = {})
10
- @savedDir = Dir.pwd
7
+ @saved_dir = Dir.pwd
11
8
  cleanup_directories_before_run
12
- FileUtils.makedirs(Oddb2xml::WorkDir)
13
- Dir.chdir(Oddb2xml::WorkDir)
9
+ FileUtils.makedirs(Oddb2xml::WORK_DIR)
10
+ Dir.chdir(Oddb2xml::WORK_DIR)
14
11
  mock_downloads
15
12
  end
16
13
 
17
14
  after(:all) do
18
- Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir)
15
+ Dir.chdir @saved_dir if @saved_dir && File.directory?(@saved_dir)
19
16
  end
20
- context 'checking' do
17
+ context "checking" do
21
18
  before(:each) do
22
19
  common_run_init
23
20
  end
24
-
25
- files2check = Dir.glob(CheckDir + '/*.xml')
21
+
22
+ files2check = Dir.glob(CHECK_DIR + "/*.xml")
26
23
 
27
24
  files2check.each do |file2check|
28
- it 'should exist' do
29
- expect(File.exists?(file2check)).to eq true
25
+ it "should exist" do
26
+ expect(File.exist?(file2check)).to eq true
30
27
  end
31
28
 
32
- it "#{File.basename(file2check)} should return okay" do
33
- result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
34
- puts "\n\nSemanticCheck: #{file2check} #{File.exist?(file2check)} returned #{result}"
35
- puts "SemanticCheck: #{file2check} #{File.size(file2check)}"
36
- # expect(result).to eq true
37
- end if /okay/i.match(File.basename(file2check))
38
-
39
- it "#{File.basename(file2check)} should return an error" do
40
- result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
41
- expect(result).to eq false
42
- end unless /okay/i.match(File.basename(file2check))
29
+ if /okay/i.match?(File.basename(file2check))
30
+ it "#{File.basename(file2check)} should return okay" do
31
+ result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
32
+ puts "\n\nSemanticCheck: #{file2check} #{File.exist?(file2check)} returned #{result}"
33
+ puts "SemanticCheck: #{file2check} #{File.size(file2check)}"
34
+ # expect(result).to eq true
35
+ end
36
+ end
43
37
 
38
+ unless /okay/i.match?(File.basename(file2check))
39
+ it "#{File.basename(file2check)} should return an error" do
40
+ result = Oddb2xml::SemanticCheck.new(file2check).allSemanticChecks
41
+ expect(result).to eq false
42
+ end
43
+ end
44
44
  end
45
45
  end
46
46
  end
data/spec/cli_spec.rb CHANGED
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
1
+ require "spec_helper"
4
2
 
5
3
  RSpec::Matchers.define :have_option do |option|
6
4
  match do |interface|
@@ -14,16 +12,16 @@ RSpec::Matchers.define :have_option do |option|
14
12
  end
15
13
  end
16
14
 
17
- shared_examples_for 'any interface for product' do
15
+ shared_examples_for "any interface for product" do
18
16
  it { expect(@cli).to respond_to(:run) }
19
- it 'should run successfully' do
17
+ it "should run successfully" do
20
18
  expect(@cli_output).to match(/products/)
21
19
  end
22
20
  end
23
21
 
24
- shared_examples_for 'any interface for address' do
22
+ shared_examples_for "any interface for address" do
25
23
  it { buildr_capture(:stdout) { expect(@cli).to respond_to(:run) } }
26
- it 'should run successfully' do
24
+ it "should run successfully" do
27
25
  expect(@cli_output).to match(/addresses/)
28
26
  end
29
27
  end
@@ -34,65 +32,64 @@ describe Oddb2xml::Cli do
34
32
  include ServerMockHelper
35
33
  before(:all) do
36
34
  VCR.eject_cassette
37
- VCR.insert_cassette('oddb2xml')
38
- @savedDir = Dir.pwd
35
+ VCR.insert_cassette("oddb2xml")
36
+ @saved_dir = Dir.pwd
39
37
  cleanup_directories_before_run
40
- FileUtils.makedirs(Oddb2xml::WorkDir)
41
- Dir.chdir(Oddb2xml::WorkDir)
38
+ FileUtils.makedirs(Oddb2xml::WORK_DIR)
39
+ Dir.chdir(Oddb2xml::WORK_DIR)
42
40
  end
43
41
  after(:all) do
44
- Dir.chdir(@savedDir) if @savedDir and File.directory?(@savedDir)
42
+ Dir.chdir(@saved_dir) if @saved_dir && File.directory?(@saved_dir)
45
43
  cleanup_compressor
46
44
  end
47
45
 
48
- context 'when -x address option is given' do
46
+ context "when -x address option is given" do
49
47
  before(:all) do
50
48
  cleanup_directories_before_run
51
- options = Oddb2xml::Options.parse('-e')
49
+ Oddb2xml::Options.parse("-e")
52
50
  # @cli = Oddb2xml::Cli.new(options); @cli.run
53
51
  @cli_output = buildr_capture(:stdout) { @cli.run }
54
52
  end
55
53
  end
56
- context 'when -o fi option is given' do
54
+ context "when -o fi option is given" do
57
55
  before(:all) do
58
56
  cleanup_directories_before_run
59
- options = Oddb2xml::Options.parse('-o fi')
60
- @cli = Oddb2xml::Cli.new(options);
57
+ options = Oddb2xml::Options.parse("-o fi")
58
+ @cli = Oddb2xml::Cli.new(options)
61
59
  @cli_output = buildr_capture(:stdout) { @cli.run }
62
60
  end
63
- # it_behaves_like 'any interface for product'
64
- it 'should have nonpharma option' do
65
- expect(@cli).to have_option(:fi => true)
61
+ # it_behaves_like 'any interface for product'
62
+ it "should have nonpharma option" do
63
+ expect(@cli).to have_option(fi: true)
66
64
  end
67
65
  end
68
66
 
69
- context 'when -t md option is given' do
67
+ context "when -t md option is given" do
70
68
  before(:all) do
71
69
  cleanup_directories_before_run
72
- options = Oddb2xml::Options.parse('-t md')
70
+ options = Oddb2xml::Options.parse("-t md")
73
71
  @cli = Oddb2xml::Cli.new(options)
74
72
  @cli_output = buildr_capture(:stdout) { @cli.run }
75
73
  end
76
- it_behaves_like 'any interface for product'
77
- it 'should have tag_suffix option' do
78
- expect(@cli).to have_option(:tag_suffix=> 'md')
74
+ it_behaves_like "any interface for product"
75
+ it "should have tag_suffix option" do
76
+ expect(@cli).to have_option(tag_suffix: "md")
79
77
  end
80
- it 'should not create a compressed file' do
81
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
82
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
78
+ it "should not create a compressed file" do
79
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
80
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
83
81
  end
84
- it 'should create xml files with prefix swiss_' do
82
+ it "should create xml files with prefix swiss_" do
85
83
  expected = [
86
- 'md_product.xml',
87
- 'md_article.xml',
88
- 'md_limitation.xml',
89
- 'md_substance.xml',
90
- 'md_interaction.xml',
91
- 'md_code.xml'
84
+ "md_product.xml",
85
+ "md_article.xml",
86
+ "md_limitation.xml",
87
+ "md_substance.xml",
88
+ "md_interaction.xml",
89
+ "md_code.xml"
92
90
  ]
93
- expected.each{
94
- |name|
95
- tst_file = File.join(Oddb2xml::WorkDir, name)
91
+ expected.each { |name|
92
+ tst_file = File.join(Oddb2xml::WORK_DIR, name)
96
93
  expect(Dir.glob(tst_file).size).to eq 1
97
94
  tst_size = File.size(tst_file)
98
95
  if tst_size < 1024
@@ -101,212 +98,240 @@ describe Oddb2xml::Cli do
101
98
  expect(tst_size).to be >= 400
102
99
  }
103
100
  end
104
- it 'should produce a correct report' do
101
+ it "should produce a correct report" do
105
102
  expect(@cli_output).to match(/Pharma products:/)
106
103
  end
107
104
  end
108
105
 
109
- context 'when -c tar.gz option is given' do
106
+ context "when -c tar.gz option is given" do
110
107
  before(:all) do
111
108
  cleanup_directories_before_run
112
- options = Oddb2xml::Options.parse('-c tar.gz')
109
+ options = Oddb2xml::Options.parse("-c tar.gz")
113
110
  @cli = Oddb2xml::Cli.new(options)
114
111
  @cli_output = buildr_capture(:stdout) { @cli.run }
115
112
  # @cli_output = @cli.run # to debug
116
113
  end
117
114
 
118
- it_behaves_like 'any interface for product'
119
- it 'should not create any xml file' do
120
- expect(@cli_output).to match(/Pharma/)
121
- Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
122
- expect(File.exists?(file)).to be_falsey
115
+ it_behaves_like "any interface for product"
116
+ it "should not create any xml file" do
117
+ expect(@cli_output).to match(/Pharma/)
118
+ Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
119
+ expect(File.exist?(file)).to be_falsey
123
120
  end
124
121
  end
125
- it 'should have compress option' do
126
- expect(@cli).to have_option(:compress_ext => 'tar.gz')
122
+ it "should have compress option" do
123
+ expect(@cli).to have_option(compress_ext: "tar.gz")
127
124
  end
128
- it 'should create tar.gz file' do
129
- file = Dir.glob(File.join(Dir.pwd, 'oddb_*.tar.gz')).first
130
- expect(File.exists?(file)).to eq true
125
+ it "should create tar.gz file" do
126
+ file = Dir.glob(File.join(Dir.pwd, "oddb_*.tar.gz")).first
127
+ expect(File.exist?(file)).to eq true
131
128
  end
132
- it 'should not create any xml file' do
133
- Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
134
- expect(File.exists?(file)).to be_falsey
129
+ it "should not create any xml file" do
130
+ Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
131
+ expect(File.exist?(file)).to be_falsey
135
132
  end
136
133
  end
137
134
  end
138
135
 
139
- context 'when -c zip option is given' do
136
+ context "when -c zip option is given" do
140
137
  before(:all) do
141
138
  cleanup_directories_before_run
142
- options = Oddb2xml::Options.parse('-c zip')
139
+ options = Oddb2xml::Options.parse("-c zip")
143
140
  @cli = Oddb2xml::Cli.new(options)
144
141
  @cli_output = buildr_capture(:stdout) { @cli.run }
145
142
  end
146
- it_behaves_like 'any interface for product'
147
- it 'should have compress option' do
148
- expect(@cli).to have_option(:compress_ext => 'zip')
143
+ it_behaves_like "any interface for product"
144
+ it "should have compress option" do
145
+ expect(@cli).to have_option(compress_ext: "zip")
149
146
  end
150
- it 'should create zip file' do
147
+ it "should create zip file" do
151
148
  expect(@cli_output).to match(/Pharma/)
152
- file = Dir.glob(File.join(Dir.pwd, 'oddb_*.zip')).first
153
- expect(File.exists?(file)).to eq true
149
+ file = Dir.glob(File.join(Dir.pwd, "oddb_*.zip")).first
150
+ expect(File.exist?(file)).to eq true
154
151
  end
155
- it 'should not create any xml file' do
156
- Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file| FileUtil.rm_f(file) end
152
+ it "should not create any xml file" do
153
+ Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each { |file| FileUtil.rm_f(file) }
157
154
  expect(@cli_output).to match(/Pharma/)
158
- Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
159
- expect(File.exists?(file)).to be_falsey
155
+ Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
156
+ expect(File.exist?(file)).to be_falsey
160
157
  end
161
158
  end
162
159
  end
163
160
 
164
- context 'when -f dat option is given' do
161
+ context "when -f dat option is given" do
165
162
  before(:all) do
166
163
  cleanup_directories_before_run
167
- options = Oddb2xml::Options.parse('-f dat')
164
+ options = Oddb2xml::Options.parse("-f dat")
168
165
  @cli = Oddb2xml::Cli.new(options)
169
166
  @cli_output = buildr_capture(:stdout) { @cli.run }
170
167
  end
171
- it_behaves_like 'any interface for product'
172
- it 'should have nonpharma option' do
173
- expect(@cli).to have_option(:format => :dat, :extended => false)
168
+ it_behaves_like "any interface for product"
169
+ it "should have nonpharma option" do
170
+ expect(@cli).to have_option(format: :dat, extended: false)
174
171
  end
175
- it 'should create the needed files' do
172
+ it "should create the needed files" do
176
173
  expect(@cli_output).to match(/\sPharma\s/)
177
- expect(File.exists?(File.join(Oddb2xml::Downloads, 'transfer.zip'))).to eq true
178
- expect(File.exists?(File.join(Oddb2xml::WorkDir, 'transfer.zip'))).to eq false
179
- expected = [
180
- 'duplicate_ean13_from_zur_rose.txt',
181
- 'oddb.dat',
182
- ].each{ |file|
183
- expect(File.exists?(File.join(Oddb2xml::WorkDir, file))).to eq true
184
- }
174
+ expect(File.exist?(File.join(Oddb2xml::DOWNLOADS, "transfer.zip"))).to eq true
175
+ expect(File.exist?(File.join(Oddb2xml::WORK_DIR, "transfer.zip"))).to eq false
176
+ [
177
+ "duplicate_ean13_from_zur_rose.txt",
178
+ "oddb.dat"
179
+ ].each { |file|
180
+ expect(File.exist?(File.join(Oddb2xml::WORK_DIR, file))).to eq true
181
+ }
185
182
  end
186
183
  end
187
-
188
- context 'when -a nonpharma option is given' do
184
+ context "when -e and -f dat option is given" do
189
185
  before(:all) do
190
186
  cleanup_directories_before_run
191
- options = Oddb2xml::Options.parse('-a nonpharma')
187
+ options = Oddb2xml::Options.parse("-e -f dat")
192
188
  @cli = Oddb2xml::Cli.new(options)
193
189
  @cli_output = buildr_capture(:stdout) { @cli.run }
194
190
  end
195
- it_behaves_like 'any interface for product'
196
- it 'should have nonpharma option' do
197
- expect(@cli).to have_option(:nonpharma => true)
191
+ it_behaves_like "any interface for product"
192
+ it "should have calc option" do
193
+ expect(@cli).to have_option(format: :dat)
194
+ expect(@cli).to have_option(calc: true)
195
+ expect(@cli).to have_option(extended: true)
198
196
  end
199
- it 'should not create any compressed file' do
197
+ it "should create xml files" do
200
198
  expect(@cli_output).to match(/NonPharma/)
201
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
202
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
199
+ file_today = "oddb_calc_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.xml"
200
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_calc.xml")).size).to eq 1
201
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, file_today)).size).to eq 1
203
202
  end
204
- it 'should create xml files' do
203
+ it "should create migel files" do
205
204
  expect(@cli_output).to match(/NonPharma/)
206
- expected = [
207
- 'oddb_product.xml',
208
- 'oddb_article.xml',
209
- 'oddb_limitation.xml',
210
- 'oddb_substance.xml',
211
- 'oddb_interaction.xml',
212
- 'oddb_code.xml'
213
- ].length
214
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
215
- expect(File.exists?(file)).to eq true
216
- end.to_a.length).to equal expected
205
+ file_today = "oddb_with_migel_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.dat"
206
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_with_migel.dat")).size).to eq 1
207
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, file_today)).size).to eq 1
217
208
  end
218
209
  end
219
- context 'when -t _swiss option is given' do
210
+
211
+ context "when -a nonpharma option is given" do
220
212
  before(:all) do
221
213
  cleanup_directories_before_run
222
- options = Oddb2xml::Options.parse('-t _swiss')
214
+ options = Oddb2xml::Options.parse("-a nonpharma")
223
215
  @cli = Oddb2xml::Cli.new(options)
224
216
  @cli_output = buildr_capture(:stdout) { @cli.run }
225
217
  end
226
- it_behaves_like 'any interface for product'
227
- it 'should have tag_suffix option' do
228
- expect(@cli).to have_option(:tag_suffix=> '_swiss')
218
+ it_behaves_like "any interface for product"
219
+ it "should have nonpharma option" do
220
+ expect(@cli).to have_option(nonpharma: true)
229
221
  end
230
- it 'should not create any compressed file' do
231
- expect(@cli_output).to match(/Pharma/)
232
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
233
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
222
+ it "should not create any compressed file" do
223
+ expect(@cli_output).to match(/NonPharma/)
224
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
225
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
234
226
  end
235
- it 'should create xml files with prefix swiss_' do
236
- expect(@cli_output).to match(/Pharma/)
227
+ it "should create xml files" do
228
+ expect(@cli_output).to match(/NonPharma/)
237
229
  expected = [
238
- 'swiss_product.xml',
239
- 'swiss_article.xml',
240
- 'swiss_limitation.xml',
241
- 'swiss_substance.xml',
242
- 'swiss_interaction.xml',
243
- 'swiss_code.xml'
230
+ "oddb_product.xml",
231
+ "oddb_article.xml",
232
+ "oddb_limitation.xml",
233
+ "oddb_substance.xml",
234
+ "oddb_interaction.xml",
235
+ "oddb_code.xml"
244
236
  ].length
245
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'swiss_*.xml')).each do |file|
246
- expect(File.exists?(file)).to eq true
237
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
238
+ expect(File.exist?(file)).to eq true
247
239
  end.to_a.length).to equal expected
248
240
  end
249
241
  end
250
- context 'when -o fi option is given' do
242
+ context "when -t _swiss option is given" do
251
243
  before(:all) do
252
244
  cleanup_directories_before_run
253
- options = Oddb2xml::Options.parse('-o fi')
245
+ options = Oddb2xml::Options.parse("-t _swiss")
254
246
  @cli = Oddb2xml::Cli.new(options)
255
247
  @cli_output = buildr_capture(:stdout) { @cli.run }
256
248
  end
257
- it_behaves_like 'any interface for product'
258
- it 'should have nonpharma option' do
259
- expect(@cli).to have_option(:fi => true)
249
+ it_behaves_like "any interface for product"
250
+ it "should have tag_suffix option" do
251
+ expect(@cli).to have_option(tag_suffix: "_swiss")
260
252
  end
261
- it 'should not create any compressed file' do
253
+ it "should not create any compressed file" do
262
254
  expect(@cli_output).to match(/Pharma/)
263
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
264
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
255
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
256
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
265
257
  end
266
- it 'should create xml files' do
258
+ it "should create xml files with prefix swiss_" do
267
259
  expect(@cli_output).to match(/Pharma/)
268
260
  expected = [
269
- 'oddb_fi.xml',
270
- 'oddb_fi_product.xml',
271
- 'oddb_product.xml',
272
- 'oddb_article.xml',
273
- 'oddb_limitation.xml',
274
- 'oddb_substance.xml',
275
- 'oddb_interaction.xml',
276
- 'oddb_code.xml'
261
+ "swiss_product.xml",
262
+ "swiss_article.xml",
263
+ "swiss_limitation.xml",
264
+ "swiss_substance.xml",
265
+ "swiss_interaction.xml",
266
+ "swiss_code.xml"
277
267
  ].length
278
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
279
- expect(File.exists?(file)).to eq true
268
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "swiss_*.xml")).each do |file|
269
+ expect(File.exist?(file)).to eq true
280
270
  end.to_a.length).to equal expected
281
271
  end
282
272
  end
283
- context 'when -x address option is given' do
273
+ context "when -o fi option is given" do
284
274
  before(:all) do
285
275
  cleanup_directories_before_run
286
- options = Oddb2xml::Options.parse('-x address')
276
+ options = Oddb2xml::Options.parse("-o fi")
287
277
  @cli = Oddb2xml::Cli.new(options)
288
278
  @cli_output = buildr_capture(:stdout) { @cli.run }
289
279
  end
290
- it_behaves_like 'any interface for address'
291
- it 'should have address option' do
292
- expect(@cli).to have_option(:address=> true)
280
+ it_behaves_like "any interface for product"
281
+ it "should have nonpharma option" do
282
+ expect(@cli).to have_option(fi: true)
293
283
  end
294
- it 'should not create any compressed file' do
295
- pending 'Cannot download medreg at the moment'
296
- expect(@cli_output).to match(/addresses/)
297
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
298
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
284
+ it "should not create any compressed file" do
285
+ expect(@cli_output).to match(/Pharma/)
286
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
287
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
299
288
  end
300
- it 'should create xml files' do
301
- pending 'Cannot download medreg at the moment'
302
- expect(@cli_output).to match(/addresses/)
289
+ it "should create xml files" do
290
+ expect(@cli_output).to match(/Pharma/)
303
291
  expected = [
304
- 'oddb_betrieb.xml',
305
- 'oddb_medizinalperson.xml',
292
+ "oddb_fi.xml",
293
+ "oddb_fi_product.xml",
294
+ "oddb_product.xml",
295
+ "oddb_article.xml",
296
+ "oddb_limitation.xml",
297
+ "oddb_substance.xml",
298
+ "oddb_interaction.xml",
299
+ "oddb_code.xml"
306
300
  ].length
307
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
308
- expect(File.exists?(file)).to eq true
301
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
302
+ expect(File.exist?(file)).to eq true
309
303
  end.to_a.length).to equal expected
310
304
  end
311
- end if false # TODO: pending medreg
305
+ end
306
+ if false
307
+ context "when -x address option is given" do
308
+ before(:all) do
309
+ cleanup_directories_before_run
310
+ options = Oddb2xml::Options.parse("-x address")
311
+ @cli = Oddb2xml::Cli.new(options)
312
+ @cli_output = buildr_capture(:stdout) { @cli.run }
313
+ end
314
+ it_behaves_like "any interface for address"
315
+ it "should have address option" do
316
+ expect(@cli).to have_option(address: true)
317
+ end
318
+ it "should not create any compressed file" do
319
+ pending "Cannot download medreg at the moment"
320
+ expect(@cli_output).to match(/addresses/)
321
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.tar.gz")).first).to be_nil
322
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.zip")).first).to be_nil
323
+ end
324
+ it "should create xml files" do
325
+ pending "Cannot download medreg at the moment"
326
+ expect(@cli_output).to match(/addresses/)
327
+ expected = [
328
+ "oddb_betrieb.xml",
329
+ "oddb_medizinalperson.xml"
330
+ ].length
331
+ expect(Dir.glob(File.join(Oddb2xml::WORK_DIR, "oddb_*.xml")).each do |file|
332
+ expect(File.exist?(file)).to eq true
333
+ end.to_a.length).to equal expected
334
+ end
335
+ end
336
+ end
312
337
  end