oddb2xml 2.7.1 → 2.7.5

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -2
  3. data/.standard.yml +2 -0
  4. data/Gemfile +3 -3
  5. data/History.txt +24 -0
  6. data/README.md +3 -3
  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/builder.rb +1070 -1038
  12. data/lib/oddb2xml/calc.rb +232 -233
  13. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  14. data/lib/oddb2xml/cli.rb +252 -236
  15. data/lib/oddb2xml/compare.rb +70 -59
  16. data/lib/oddb2xml/compositions_syntax.rb +451 -430
  17. data/lib/oddb2xml/compressor.rb +20 -20
  18. data/lib/oddb2xml/downloader.rb +157 -129
  19. data/lib/oddb2xml/extractor.rb +295 -295
  20. data/lib/oddb2xml/options.rb +34 -35
  21. data/lib/oddb2xml/parslet_compositions.rb +265 -269
  22. data/lib/oddb2xml/semantic_check.rb +39 -33
  23. data/lib/oddb2xml/util.rb +163 -163
  24. data/lib/oddb2xml/version.rb +1 -1
  25. data/lib/oddb2xml/xml_definitions.rb +32 -33
  26. data/lib/oddb2xml.rb +1 -1
  27. data/oddb2xml.gemspec +34 -34
  28. data/shell.nix +17 -0
  29. data/spec/artikelstamm_spec.rb +111 -110
  30. data/spec/builder_spec.rb +490 -505
  31. data/spec/calc_spec.rb +552 -593
  32. data/spec/check_artikelstamm_spec.rb +26 -26
  33. data/spec/cli_spec.rb +173 -174
  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/transfer.dat +1 -0
  38. data/spec/data_helper.rb +47 -49
  39. data/spec/downloader_spec.rb +251 -260
  40. data/spec/extractor_spec.rb +171 -159
  41. data/spec/fixtures/vcr_cassettes/oddb2xml.json +1 -1
  42. data/spec/galenic_spec.rb +233 -256
  43. data/spec/options_spec.rb +116 -119
  44. data/spec/parslet_spec.rb +896 -863
  45. data/spec/spec_helper.rb +153 -153
  46. data/test_options.rb +39 -42
  47. data/tools/win_fetch_cacerts.rb +2 -3
  48. metadata +42 -12
@@ -1,14 +1,19 @@
1
- # encoding: utf-8
2
- require 'oddb2xml/extractor'
3
- require 'ox'
4
- require 'open-uri'
1
+ require "oddb2xml/extractor"
2
+ require "ox"
3
+ require "open-uri"
5
4
 
6
5
  module Oddb2xml
7
6
  class Chapter70xtractor < Extractor
8
- def Chapter70xtractor.parse_td(elem)
7
+ def self.parse_td(elem)
9
8
  begin
10
9
  values = elem.is_a?(Array) ? elem : elem.values
11
- res = values.flatten.collect{|x| x.nil? ? nil : x.is_a?(Hash) ? x.values : x.gsub(/\r\n/,'').strip }
10
+ res = values.flatten.collect { |x|
11
+ if x.nil?
12
+ nil
13
+ else
14
+ x.is_a?(Hash) ? x.values : x.gsub(/\r\n/, "").strip
15
+ end
16
+ }
12
17
  puts "parse_td returns: #{res}" if $VERBOSE
13
18
  rescue => exc
14
19
  puts "Unable to pars #{elem} #{exc}"
@@ -18,53 +23,54 @@ module Oddb2xml
18
23
  res.flatten # .join("\t")
19
24
  end
20
25
  LIMITATIONS = {
21
- 'L' => 'Kostenübernahme nur nach vorgängiger allergologischer Abklärung.',
22
- 'L1' => 'Eine Flasche zu 20 ml Urtinktur einer bestimmten Pflanze pro Monat.',
23
- 'L1, L2' => 'Eine Flasche zu 20 ml Urtinktur einer bestimmten Pflanze pro Monat. Für Aesculus, Carduus Marianus, Ginkgo, Hedera helix, Hypericum perforatum, Lavandula, Rosmarinus officinalis, Taraxacum officinale.',
24
- 'L3' => 'Alle drei Monate wird eine Verordnung/Originalpackung pro Mittel vergütet.',
26
+ "L" => "Kostenübernahme nur nach vorgängiger allergologischer Abklärung.",
27
+ "L1" => "Eine Flasche zu 20 ml Urtinktur einer bestimmten Pflanze pro Monat.",
28
+ "L1, L2" => "Eine Flasche zu 20 ml Urtinktur einer bestimmten Pflanze pro Monat. Für Aesculus, Carduus Marianus, Ginkgo, Hedera helix, Hypericum perforatum, Lavandula, Rosmarinus officinalis, Taraxacum officinale.",
29
+ "L3" => "Alle drei Monate wird eine Verordnung/Originalpackung pro Mittel vergütet."
25
30
  }
26
31
  def self.items
27
32
  @@items
28
33
  end
29
- def self.parse(html_file = 'http://www.spezialitaetenliste.ch/varia_De.htm')
30
- data = Hash.new{|h,k| h[k] = [] }
34
+
35
+ def self.parse(html_file = "http://www.spezialitaetenliste.ch/varia_De.htm")
36
+ data = Hash.new { |h, k| h[k] = [] }
31
37
  Ox.default_options = {
32
- mode: :generic,
33
- effort: :tolerant,
34
- smart: true
38
+ mode: :generic,
39
+ effort: :tolerant,
40
+ smart: true
35
41
  }
36
- res = Ox.load(Oddb2xml.uri_open(html_file).read, mode: :hash_no_attrs).values.first['body']
42
+ res = Ox.load(Oddb2xml.uri_open(html_file).read, mode: :hash_no_attrs).values.first["body"]
37
43
  result = []
38
44
  idx = 0
39
45
  @@items = {}
40
46
  res.values.last.each do |item|
41
- item.values.first.each do |subElem|
42
- what = Chapter70xtractor.parse_td(subElem)
47
+ item.values.first.each do |sub_elem|
48
+ what = Chapter70xtractor.parse_td(sub_elem)
43
49
  idx += 1
44
50
  puts "#{idx}: xx #{what}" if $VERBOSE
45
51
  result << what
46
52
  end
47
53
  end
48
- result2 = result.find_all{ |x| (x.is_a?(Array) && x.first.is_a?(String)) && x.first.to_i > 100}
54
+ result2 = result.find_all { |x| (x.is_a?(Array) && x.first.is_a?(String)) && x.first.to_i > 100 }
49
55
  result2.each do |entry|
50
56
  data = {}
51
57
  pharma_code = entry.first
52
- ean13 = (Oddb2xml::FAKE_GTIN_START + pharma_code.to_s)
53
- if entry[2].encoding.to_s.eql?('ASCII-8BIT')
54
- german = CGI.unescape(entry[2].force_encoding('ISO-8859-1'))
58
+ ean13 = (Oddb2xml::FAKE_GTIN_START + pharma_code.to_s)
59
+ german = if entry[2].encoding.to_s.eql?("ASCII-8BIT")
60
+ CGI.unescape(entry[2].force_encoding("ISO-8859-1"))
55
61
  else
56
- german = entry[2]
62
+ entry[2]
57
63
  end
58
64
  @@items[ean13] = {
59
- :data_origin => 'Chapter70',
60
- :line => entry.join(","),
61
- :ean13 => ean13,
62
- :description => german,
63
- :quantity => entry[3],
64
- :pharmacode => pharma_code,
65
- :pub_price => entry[4],
66
- :limitation => entry[5],
67
- :type => :pharma,
65
+ data_origin: "Chapter70",
66
+ line: entry.join(","),
67
+ ean13: ean13,
68
+ description: german,
69
+ quantity: entry[3],
70
+ pharmacode: pharma_code,
71
+ pub_price: entry[4],
72
+ limitation: entry[5],
73
+ type: :pharma
68
74
  }
69
75
  end
70
76
  result2