oddb2xml 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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,238 +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
- context 'when -e and -f dat option is given' do
184
+ context "when -e and -f dat option is given" do
188
185
  before(:all) do
189
186
  cleanup_directories_before_run
190
- options = Oddb2xml::Options.parse('-e -f dat')
187
+ options = Oddb2xml::Options.parse("-e -f dat")
191
188
  @cli = Oddb2xml::Cli.new(options)
192
189
  @cli_output = buildr_capture(:stdout) { @cli.run }
193
190
  end
194
- it_behaves_like 'any interface for product'
195
- it 'should have calc option' do
196
- expect(@cli).to have_option(:format => :dat)
197
- expect(@cli).to have_option(:calc => true)
198
- expect(@cli).to have_option(:extended => 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)
199
196
  end
200
- it 'should create xml files' do
197
+ it "should create xml files" do
201
198
  expect(@cli_output).to match(/NonPharma/)
202
199
  file_today = "oddb_calc_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.xml"
203
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_calc.xml')).size).to eq 1
204
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, file_today)).size).to eq 1
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
205
202
  end
206
- it 'should create migel files' do
203
+ it "should create migel files" do
207
204
  expect(@cli_output).to match(/NonPharma/)
208
205
  file_today = "oddb_with_migel_#{Time.now.strftime("%d.%m.%Y_%H.%M")}.dat"
209
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_with_migel.dat')).size).to eq 1
210
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, file_today)).size).to eq 1
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
211
208
  end
212
209
  end
213
210
 
214
- context 'when -a nonpharma option is given' do
211
+ context "when -a nonpharma option is given" do
215
212
  before(:all) do
216
213
  cleanup_directories_before_run
217
- options = Oddb2xml::Options.parse('-a nonpharma')
214
+ options = Oddb2xml::Options.parse("-a nonpharma")
218
215
  @cli = Oddb2xml::Cli.new(options)
219
216
  @cli_output = buildr_capture(:stdout) { @cli.run }
220
217
  end
221
- it_behaves_like 'any interface for product'
222
- it 'should have nonpharma option' do
223
- expect(@cli).to have_option(:nonpharma => true)
218
+ it_behaves_like "any interface for product"
219
+ it "should have nonpharma option" do
220
+ expect(@cli).to have_option(nonpharma: true)
224
221
  end
225
- it 'should not create any compressed file' do
222
+ it "should not create any compressed file" do
226
223
  expect(@cli_output).to match(/NonPharma/)
227
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
228
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
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
229
226
  end
230
- it 'should create xml files' do
227
+ it "should create xml files" do
231
228
  expect(@cli_output).to match(/NonPharma/)
232
229
  expected = [
233
- 'oddb_product.xml',
234
- 'oddb_article.xml',
235
- 'oddb_limitation.xml',
236
- 'oddb_substance.xml',
237
- 'oddb_interaction.xml',
238
- 'oddb_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"
239
236
  ].length
240
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
241
- 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
242
239
  end.to_a.length).to equal expected
243
240
  end
244
241
  end
245
- context 'when -t _swiss option is given' do
242
+ context "when -t _swiss option is given" do
246
243
  before(:all) do
247
244
  cleanup_directories_before_run
248
- options = Oddb2xml::Options.parse('-t _swiss')
245
+ options = Oddb2xml::Options.parse("-t _swiss")
249
246
  @cli = Oddb2xml::Cli.new(options)
250
247
  @cli_output = buildr_capture(:stdout) { @cli.run }
251
248
  end
252
- it_behaves_like 'any interface for product'
253
- it 'should have tag_suffix option' do
254
- expect(@cli).to have_option(:tag_suffix=> '_swiss')
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")
255
252
  end
256
- it 'should not create any compressed file' do
253
+ it "should not create any compressed file" do
257
254
  expect(@cli_output).to match(/Pharma/)
258
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
259
- 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
260
257
  end
261
- it 'should create xml files with prefix swiss_' do
258
+ it "should create xml files with prefix swiss_" do
262
259
  expect(@cli_output).to match(/Pharma/)
263
260
  expected = [
264
- 'swiss_product.xml',
265
- 'swiss_article.xml',
266
- 'swiss_limitation.xml',
267
- 'swiss_substance.xml',
268
- 'swiss_interaction.xml',
269
- 'swiss_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"
270
267
  ].length
271
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'swiss_*.xml')).each do |file|
272
- 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
273
270
  end.to_a.length).to equal expected
274
271
  end
275
272
  end
276
- context 'when -o fi option is given' do
273
+ context "when -o fi option is given" do
277
274
  before(:all) do
278
275
  cleanup_directories_before_run
279
- options = Oddb2xml::Options.parse('-o fi')
276
+ options = Oddb2xml::Options.parse("-o fi")
280
277
  @cli = Oddb2xml::Cli.new(options)
281
278
  @cli_output = buildr_capture(:stdout) { @cli.run }
282
279
  end
283
- it_behaves_like 'any interface for product'
284
- it 'should have nonpharma option' do
285
- expect(@cli).to have_option(:fi => true)
280
+ it_behaves_like "any interface for product"
281
+ it "should have nonpharma option" do
282
+ expect(@cli).to have_option(fi: true)
286
283
  end
287
- it 'should not create any compressed file' do
284
+ it "should not create any compressed file" do
288
285
  expect(@cli_output).to match(/Pharma/)
289
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
290
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
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
291
288
  end
292
- it 'should create xml files' do
289
+ it "should create xml files" do
293
290
  expect(@cli_output).to match(/Pharma/)
294
291
  expected = [
295
- 'oddb_fi.xml',
296
- 'oddb_fi_product.xml',
297
- 'oddb_product.xml',
298
- 'oddb_article.xml',
299
- 'oddb_limitation.xml',
300
- 'oddb_substance.xml',
301
- 'oddb_interaction.xml',
302
- 'oddb_code.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"
303
300
  ].length
304
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
305
- 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
306
303
  end.to_a.length).to equal expected
307
304
  end
308
305
  end
309
- context 'when -x address option is given' do
310
- before(:all) do
311
- cleanup_directories_before_run
312
- options = Oddb2xml::Options.parse('-x address')
313
- @cli = Oddb2xml::Cli.new(options)
314
- @cli_output = buildr_capture(:stdout) { @cli.run }
315
- end
316
- it_behaves_like 'any interface for address'
317
- it 'should have address option' do
318
- expect(@cli).to have_option(:address=> true)
319
- end
320
- it 'should not create any compressed file' do
321
- pending 'Cannot download medreg at the moment'
322
- expect(@cli_output).to match(/addresses/)
323
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.tar.gz')).first).to be_nil
324
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.zip')).first).to be_nil
325
- end
326
- it 'should create xml files' do
327
- pending 'Cannot download medreg at the moment'
328
- expect(@cli_output).to match(/addresses/)
329
- expected = [
330
- 'oddb_betrieb.xml',
331
- 'oddb_medizinalperson.xml',
332
- ].length
333
- expect(Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
334
- expect(File.exists?(file)).to eq true
335
- end.to_a.length).to equal expected
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
336
335
  end
337
- end if false # TODO: pending medreg
336
+ end
338
337
  end