oddb2xml 2.4.2 → 2.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e843316fece7832e0a39b9ee486b2e1443a53c5
4
- data.tar.gz: afe50f51c3876a86737dda382c68f9f5b736ac6f
3
+ metadata.gz: f3bb1935034ceac75c20a7a760647779e269cfbd
4
+ data.tar.gz: c7a68dad6adbf982c83d6ef8b9794bc551f2233b
5
5
  SHA512:
6
- metadata.gz: f3374d25d048992d8a0dac05eda9a8041c8801049a134110c26dae2acae50aae302d17da71904d95679fd050a3881edf5d8ef65919970db8e8d3ac614460ca0a
7
- data.tar.gz: cc42b09f80d81c4d2e39348075c6044b96f17822f277dfbd9d8e5bcdebb6c0a95dfc7bca785941b03139d17359a25be8151303d23a5cf765c8b131f199d86e24
6
+ metadata.gz: 549c6c25a4e157b3dd463fbae8ab2fea31d26a6ef0eac7c6020acc8a0904ed6c638d4ee29f4bad6e594874686a1c24e3b6ec84fefb0bf6baf0e85381e453f546
7
+ data.tar.gz: 0dce9a5cf5bb1afc960d524cf2208e27d79c516c0f00b42596783004de39f2b3d949c66874dba7576e2bfd41768bc21bf850c58e7dba91b873ffca1b0e5e9515
data/.travis.yml CHANGED
@@ -11,16 +11,16 @@ before_install:
11
11
  script: bundle exec rspec
12
12
 
13
13
  rvm:
14
- - 1.9.3
15
- - 2.0.0
16
- - 2.1
17
- - 2.2
18
- - 2.3.1
14
+ - 2.2.7
15
+ - 2.3.4
16
+ - 2.4.1
19
17
  - ruby-head
20
18
 
21
19
  matrix:
22
20
  allow_failures:
23
21
  - rvm: ruby-head
22
+ - rvm: 2.2.7
23
+ - rvm: 2.3.4
24
24
 
25
25
  notifications:
26
26
  email:
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 2.4.3 / 11.09.2017
2
+
3
+ * Never drop lines with UTF-8 problems while creating XML files
4
+ * Fix some rspec errors
5
+ * Travis runs only for ruby 2.2.7 and newer
6
+ * Do not emit a DEL field for limitations, as it is not specifid in the oddb2xml.xsd
7
+
1
8
  === 2.4.2 / 6.09.2017
2
9
 
3
10
  * Ignore lines that cannot be converted from UTF-8 to ISO-8859-1
@@ -299,10 +299,14 @@ module Oddb2xml
299
299
  _builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
300
300
  xml.doc.tag_suffix = @tag_suffix
301
301
  datetime = Time.new.strftime('%FT%T%z')
302
- xml.LIMITATION(XML_OPTIONS) {
302
+ xml.LIMITATION(XML_OPTIONS) do
303
303
  nbr_records = 0
304
304
  @limitations.each do |lim|
305
- xml.LIM('DT' => '') {
305
+ if lim[:id].empty?
306
+ puts "Skipping empty id of #{lim}"
307
+ next
308
+ end
309
+ xml.LIM('DT' => '') do
306
310
  case lim[:key]
307
311
  when :swissmedic_number8
308
312
  xml.SwissmedicNo8 lim[:id]
@@ -319,20 +323,16 @@ module Oddb2xml
319
323
  xml.DSCRD lim[:desc_de]
320
324
  xml.DSCRF lim[:desc_fr]
321
325
  xml.VDAT lim[:vdate]
322
- if lim[:del]
323
- xml.DEL 3
324
- end
325
326
  nbr_records += 1
326
-
327
- }
327
+ end
328
328
  end
329
- xml.RESULT {
329
+ xml.RESULT do
330
330
  xml.OK_ERROR 'OK'
331
331
  xml.NBR_RECORD nbr_records
332
332
  xml.ERROR_CODE ''
333
333
  xml.MESSAGE ''
334
- }
335
- }
334
+ end
335
+ end
336
336
  end
337
337
  Oddb2xml.add_hash(_builder.to_xml)
338
338
  end
@@ -642,7 +642,7 @@ module Oddb2xml
642
642
  xml.SUBSTANCE_NAME substance.name
643
643
  xml.IS_ACTIVE_AGENT substance.is_active_agent if emit_active
644
644
  if substance.dose
645
- if substance.qty.is_a?(Float) or substance.qty.is_a?(Fixnum)
645
+ if substance.qty.is_a?(Float) or substance.qty.is_a?(Integer)
646
646
  xml.QTY substance.qty
647
647
  xml.UNIT substance.unit
648
648
  else
data/lib/oddb2xml/calc.rb CHANGED
@@ -289,7 +289,7 @@ public
289
289
  end
290
290
 
291
291
  def pkg_size_to_int(pkg_size, skip_last_part = false)
292
- return pkg_size if pkg_size.is_a?(Fixnum)
292
+ return pkg_size if pkg_size.is_a?(Integer)
293
293
  return 1 unless pkg_size
294
294
  parts = pkg_size.split(/\s*x\s*/i)
295
295
  parts = parts[0..-2] if skip_last_part and parts.size > 1
@@ -349,4 +349,4 @@ public
349
349
  return nil
350
350
  end
351
351
  end
352
- end
352
+ end
data/lib/oddb2xml/cli.rb CHANGED
@@ -137,12 +137,10 @@ module Oddb2xml
137
137
  end
138
138
  File.open(File.join(WorkDir, file), 'w:utf-8') do |fh|
139
139
  output.split("\n").each do |line|
140
- begin
141
- # We want to ignore lines which are not really UTF-8 encoded
142
- iso_8859_1 = line.encode('ISO-8859-1')
140
+ if /.xml$/i.match(file)
143
141
  fh.puts(line)
144
- rescue => error
145
- puts "#{error}: #{file} Ignoring #{line}"
142
+ else
143
+ fh.puts(Oddb2xml.convert_to_8859_1(line))
146
144
  end
147
145
  end
148
146
  end
@@ -228,7 +228,6 @@ module Oddb2xml
228
228
  :log_level => :info,
229
229
  :log => false, # $stdout
230
230
  :raise_errors => true,
231
- :ssl_version => :SSLv3,
232
231
  :wsdl => @url
233
232
  }
234
233
  @client = Savon::Client.new(config)
@@ -124,6 +124,10 @@ module Oddb2xml
124
124
  key = :swissmedic_number8
125
125
  id = item[:packages][ean][key].to_s
126
126
  end
127
+ if id.empty? && item[:packages][ean][ :swissmedic_number8]
128
+ key = :swissmedic_number8
129
+ id = item[:packages][ean][key].to_s
130
+ end
127
131
  lims.each do |lim|
128
132
  limitation = {
129
133
  :it => item[:it_code],
data/lib/oddb2xml/util.rb CHANGED
@@ -20,6 +20,27 @@ module Oddb2xml
20
20
  @atc_csv_origin = 'https://raw.githubusercontent.com/epha/robot/master/data/manual/swissmedic/atc.csv'
21
21
  @atc_csv_content = {}
22
22
 
23
+ def Oddb2xml.convert_to_8859_1(line)
24
+ begin
25
+ # We want to ignore lines which are not really UTF-8 encoded
26
+ return line.encode('ISO-8859-1')
27
+ rescue => error
28
+ ausgabe = ''
29
+ 0.upto(line.size-1).each do |idx|
30
+ begin
31
+ if line[idx].ord == 8211
32
+ ausgabe += '-'
33
+ else
34
+ ausgabe += line[idx].encode('ISO-8859-1')
35
+ end
36
+ rescue => error
37
+ puts "#{error}: in #{line} at #{idx}"
38
+ end
39
+ end
40
+ end
41
+ ausgabe.encode('ISO-8859-1')
42
+ end
43
+
23
44
  def Oddb2xml.add_epha_changes_for_ATC(iksnr, atc_code)
24
45
  if @atc_csv_content.size == 0
25
46
  open(@atc_csv_origin).readlines.each{
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.3"
3
3
  end
data/spec/builder_spec.rb CHANGED
@@ -60,8 +60,8 @@ ARTICLE_COMMON_ELEMENTS = [
60
60
  ['ARTICLE/ART/ARTBAR/BC', Oddb2xml::ORPHAN_GTIN.to_s],
61
61
  ['ARTICLE/ART/ARTBAR/BC', Oddb2xml::FRIDGE_GTIN.to_s],
62
62
  ['ARTICLE/ART/DSCRD', 'NAROPIN Inj Lös 0.2 % 5 Polybag 100 ml'],
63
- ['ARTICLE/ART/DSCRF', 'NAROPIN sol inj 0.2 % 5 polybag 100 ml"'],
64
- ['ARTICLE/ART/SORTD', 'NAROPIN INJ LöS 0.2 % 5 POLYBAG 100 ML'],
63
+ ['ARTICLE/ART/DSCRF', 'NAROPIN sol inj 0.2 % 5 polybag 100 ml'],
64
+ ['ARTICLE/ART/SORTD', 'NAROPIN INJ LÖS 0.2 % 5 POLYBAG 100 ML'],
65
65
  ['ARTICLE/ART/SORTF', 'NAROPIN SOL INJ 0.2 % 5 POLYBAG 100 ML'],
66
66
  ['ARTICLE/ART/SYN1D', 'Hirudoid'],
67
67
  ['ARTICLE/ART/SYN1F', 'Hirudoid'],
@@ -943,6 +943,14 @@ if RUN_ALL
943
943
  IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line, 892, true) }
944
944
  end
945
945
  end
946
+ context 'when utf-8 to iso-8859 fails' do
947
+ it 'should return a correct 8859 line' do
948
+ lines = IO.readlines(File.join(Oddb2xml::SpecData, 'problems.txt'))
949
+ out = Oddb2xml.convert_to_8859_1(lines.first)
950
+ expect(out.encoding.to_s).to eq 'ISO-8859-1'
951
+ expect(out.chomp).to eq '<NAME_DE>SENSURA Mio 1t Uro 10-33 midi con lig so op 10 Stk</NAME_DE>'
952
+ end
953
+ end
954
+ end
946
955
  end
947
956
  end
948
- end
@@ -0,0 +1,4 @@
1
+ <NAME_DE>SENSURA Mio 1t Uro 10–33 midi con lig so op 10 Stk</NAME_DE>
2
+ <NAME_FR>SENSURA Mio 1t Uro 10–33 midi con lig so op 10 pce</NAME_FR>
3
+ <NAME_DE>SENSURA Mio 1t Uro 10–33 maxi con lig so op 10 Stk</NAME_DE>
4
+ <NAME_FR>SENSURA Mio 1t Uro 10–33 maxi con lig so op 10 pce</NAME_FR>
@@ -326,7 +326,7 @@ describe Oddb2xml::EphaDownloader do
326
326
  expect(csv.bytes).not_to be nil
327
327
  end
328
328
  it 'should clean up current directory' do
329
- File.exist?('epha_interactions.csv').should eq(false)
329
+ expect(File.exist?('epha_interactions.csv')).to eq(false)
330
330
  end
331
331
  it 'should save under download' do
332
332
  expect(File.exist?(File.join(Oddb2xml::Downloads, 'epha_interactions.csv'))).to eq(true)
@@ -533,12 +533,10 @@ describe Oddb2xml::MedregbmDownloader do
533
533
  context 'download betrieb txt' do
534
534
  let(:txt) { @downloader.download }
535
535
  it 'should return valid String' do
536
- pending 'Should handle SSL issues'
537
536
  expect(txt).to be_a String
538
537
  expect(txt.bytes).not_to be nil
539
538
  end
540
539
  it 'should clean up current directory' do
541
- pending 'Should handle SSL issues'
542
540
  expect { txt }.not_to raise_error
543
541
  expect(File.exist?('oddb_company.xls')).to eq(false)
544
542
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-06 00:00:00.000000000 Z
11
+ date: 2017-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -343,6 +343,7 @@ files:
343
343
  - spec/data/oddb2xml_files_bm_update.txt
344
344
  - spec/data/oddb2xml_files_lppv.txt
345
345
  - spec/data/oddb2xml_files_nonpharma.xls
346
+ - spec/data/problems.txt
346
347
  - spec/data/swissmedic_fridges.html
347
348
  - spec/data/swissmedic_info.html
348
349
  - spec/data/swissmedic_info_2.html
@@ -421,6 +422,7 @@ test_files:
421
422
  - spec/data/oddb2xml_files_bm_update.txt
422
423
  - spec/data/oddb2xml_files_lppv.txt
423
424
  - spec/data/oddb2xml_files_nonpharma.xls
425
+ - spec/data/problems.txt
424
426
  - spec/data/swissmedic_fridges.html
425
427
  - spec/data/swissmedic_info.html
426
428
  - spec/data/swissmedic_info_2.html