oddb2xml 2.8.1 → 2.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cc43d372c64564821c3594e837a93058f4b9aeb51bef7dd76036e694fed737a
4
- data.tar.gz: 44e66c7136db33e6cbb656f070522cffe920f736a1a15ddfa2fa8363a79b3ca4
3
+ metadata.gz: 1b08f317299357e7ac742cf17126a08d8c8fb588e438a77800470b65ed085e7a
4
+ data.tar.gz: ff0beeb14aaba0ccf5ad431438570e352ecaa195ea19a61712c6f1d1c23f4116
5
5
  SHA512:
6
- metadata.gz: 94d01ca34a3d6d535f14f873d377c5a46ae99a28c63330fe5fe14f886f416218d75df5ab3201fd05da9c607110de05666d6297fdfb9941a3b2f61a1a87517560
7
- data.tar.gz: 6313c7015702732aa1be35b404b2b87a4230adc0b20bc8600bfa55d4c7e93ce8f16bab9cc13b6748927ce4ba13d0d97862ceabed64d81ae9baed397c436fd0ac
6
+ metadata.gz: 9a0a1b952a83d5b9d62244f487460325577c415d15d755beda84f63258a60e4de04c2d665395b7efb522c45f5cd07328b28bf36745cc6649faa4a9010f2ccd8e
7
+ data.tar.gz: 785408cf96d8ff18f9de68fa5579c433cb317fb247ff5304400d747d2a7973070461f339c1e8ad16ef6574930dbbea11d759b7a5f7ee3de824389abaf6debe67
@@ -9,7 +9,7 @@ name: Ruby
9
9
 
10
10
  on:
11
11
  push:
12
- branches: [ master ]
12
+ branches: [ master, '*' ]
13
13
  pull_request:
14
14
  branches: [ master ]
15
15
 
@@ -21,19 +21,16 @@ jobs:
21
21
  strategy:
22
22
  fail-fast: false
23
23
  matrix:
24
- os: [ ubuntu]
25
- ruby: [2.6, 2.7, "3.0", 3.1, 3.2]
24
+ os: [ubuntu]
25
+ ruby: ["3.0", "3.1", "3.2"]
26
+ env:
27
+ BUNDLE_PATH: ".bundle/gems"
28
+ BUNDLE_WITHOUT: "debugger"
26
29
  steps:
27
30
  - uses: actions/checkout@v2
28
31
  - uses: ruby/setup-ruby@v1
29
32
  with:
30
33
  ruby-version: ${{ matrix.ruby }}
31
34
  bundler-cache: true
32
-
33
- - name: Install dependencies
34
- run: |
35
- bundle config set path .bundle/gems --local
36
- bundle config set without debugger --local
37
- bundle install
38
35
  - name: Test with RSpec
39
36
  run: bundle exec rspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (2.8.1)
4
+ oddb2xml (2.8.3)
5
5
  htmlentities
6
6
  httpi
7
7
  mechanize
@@ -25,22 +25,23 @@ PATH
25
25
  GEM
26
26
  remote: https://rubygems.org/
27
27
  specs:
28
- addressable (2.8.1)
28
+ addressable (2.8.5)
29
29
  public_suffix (>= 2.0.2, < 6.0)
30
30
  akami (1.3.1)
31
31
  gyoku (>= 0.4.0)
32
32
  nokogiri
33
33
  ast (2.4.2)
34
+ base64 (0.1.1)
34
35
  builder (3.2.4)
35
36
  byebug (11.1.3)
36
37
  coderay (1.1.3)
37
- connection_pool (2.3.0)
38
+ connection_pool (2.4.1)
38
39
  crack (0.4.5)
39
40
  rexml
40
41
  diff-lcs (1.5.0)
41
42
  domain_name (0.5.20190701)
42
43
  unf (>= 0.0.5, < 1.0.0)
43
- flexmock (2.3.6)
44
+ flexmock (2.3.8)
44
45
  gyoku (1.4.0)
45
46
  builder (>= 2.1.2)
46
47
  rexml (~> 3.0)
@@ -53,6 +54,7 @@ GEM
53
54
  socksify
54
55
  json (2.6.3)
55
56
  language_server-protocol (3.17.0.3)
57
+ lint_roller (1.1.0)
56
58
  mechanize (2.7.7)
57
59
  domain_name (~> 0.5, >= 0.5.1)
58
60
  http-cookie (~> 1.0)
@@ -64,25 +66,26 @@ GEM
64
66
  webrick (~> 1.7)
65
67
  webrobots (>= 0.0.9, < 0.2)
66
68
  method_source (1.0.0)
67
- mime-types (3.4.1)
69
+ mime-types (3.5.1)
68
70
  mime-types-data (~> 3.2015)
69
- mime-types-data (3.2022.0105)
70
- mini_portile2 (2.8.1)
71
+ mime-types-data (3.2023.0808)
72
+ mini_portile2 (2.8.4)
71
73
  minitar (0.9)
72
74
  multi_json (1.15.0)
73
75
  net-http-digest_auth (1.4.1)
74
- net-http-persistent (4.0.1)
76
+ net-http-persistent (4.0.2)
75
77
  connection_pool (~> 2.2)
76
78
  nokogiri (1.13.9)
77
79
  mini_portile2 (~> 2.8.0)
78
80
  racc (~> 1.4)
79
81
  nori (2.6.0)
80
82
  ntlm-http (0.1.1)
81
- optimist (3.0.1)
82
- ox (2.14.12)
83
- parallel (1.22.1)
84
- parser (3.2.0.0)
83
+ optimist (3.1.0)
84
+ ox (2.14.17)
85
+ parallel (1.23.0)
86
+ parser (3.2.2.3)
85
87
  ast (~> 2.4.1)
88
+ racc
86
89
  parslet (2.0.0)
87
90
  pry (0.14.2)
88
91
  coderay (~> 1.1)
@@ -94,44 +97,46 @@ GEM
94
97
  pry (~> 0.11)
95
98
  yard (~> 0.9.11)
96
99
  psych (3.3.4)
97
- public_suffix (5.0.1)
98
- racc (1.6.2)
100
+ public_suffix (5.0.3)
101
+ racc (1.7.1)
99
102
  rack (3.0.8)
100
103
  rainbow (3.1.1)
101
104
  rake (13.0.6)
102
105
  rdoc (6.3.3)
103
- regexp_parser (2.6.2)
104
- rexml (3.2.5)
106
+ regexp_parser (2.8.1)
107
+ rexml (3.2.6)
105
108
  rspec (3.12.0)
106
109
  rspec-core (~> 3.12.0)
107
110
  rspec-expectations (~> 3.12.0)
108
111
  rspec-mocks (~> 3.12.0)
109
- rspec-core (3.12.0)
112
+ rspec-core (3.12.2)
110
113
  rspec-support (~> 3.12.0)
111
- rspec-expectations (3.12.2)
114
+ rspec-expectations (3.12.3)
112
115
  diff-lcs (>= 1.2.0, < 2.0)
113
116
  rspec-support (~> 3.12.0)
114
- rspec-mocks (3.12.2)
117
+ rspec-mocks (3.12.6)
115
118
  diff-lcs (>= 1.2.0, < 2.0)
116
119
  rspec-support (~> 3.12.0)
117
- rspec-support (3.12.0)
118
- rubocop (1.42.0)
120
+ rspec-support (3.12.1)
121
+ rubocop (1.56.4)
122
+ base64 (~> 0.1.1)
119
123
  json (~> 2.3)
124
+ language_server-protocol (>= 3.17.0)
120
125
  parallel (~> 1.10)
121
- parser (>= 3.1.2.1)
126
+ parser (>= 3.2.2.3)
122
127
  rainbow (>= 2.2.2, < 4.0)
123
128
  regexp_parser (>= 1.8, < 3.0)
124
129
  rexml (>= 3.2.5, < 4.0)
125
- rubocop-ast (>= 1.24.1, < 2.0)
130
+ rubocop-ast (>= 1.28.1, < 2.0)
126
131
  ruby-progressbar (~> 1.7)
127
- unicode-display_width (>= 1.4.0, < 3.0)
128
- rubocop-ast (1.24.1)
129
- parser (>= 3.1.1.0)
130
- rubocop-performance (1.15.2)
132
+ unicode-display_width (>= 2.4.0, < 3.0)
133
+ rubocop-ast (1.29.0)
134
+ parser (>= 3.2.1.0)
135
+ rubocop-performance (1.19.1)
131
136
  rubocop (>= 1.7.0, < 2.0)
132
137
  rubocop-ast (>= 0.4.0)
133
138
  ruby-ole (1.2.12.2)
134
- ruby-progressbar (1.11.0)
139
+ ruby-progressbar (1.13.0)
135
140
  rubyXL (3.4.25)
136
141
  nokogiri (>= 1.10.8)
137
142
  rubyzip (>= 1.3.0)
@@ -149,32 +154,39 @@ GEM
149
154
  socksify (1.7.1)
150
155
  spreadsheet (1.3.0)
151
156
  ruby-ole
152
- standard (1.22.1)
157
+ standard (1.31.1)
153
158
  language_server-protocol (~> 3.17.0.2)
154
- rubocop (= 1.42.0)
155
- rubocop-performance (= 1.15.2)
159
+ lint_roller (~> 1.0)
160
+ rubocop (~> 1.56.2)
161
+ standard-custom (~> 1.0.0)
162
+ standard-performance (~> 1.2)
163
+ standard-custom (1.0.2)
164
+ lint_roller (~> 1.0)
165
+ rubocop (~> 1.50)
166
+ standard-performance (1.2.0)
167
+ lint_roller (~> 1.1)
168
+ rubocop-performance (~> 1.19.0)
156
169
  standardrb (1.0.1)
157
170
  standard
158
- timecop (0.9.6)
171
+ timecop (0.9.8)
159
172
  unf (0.1.4)
160
173
  unf_ext
161
174
  unf_ext (0.0.8.2)
162
- unicode-display_width (2.4.2)
163
- vcr (6.1.0)
175
+ unicode-display_width (2.5.0)
176
+ vcr (6.2.0)
164
177
  wasabi (3.7.0)
165
178
  addressable
166
179
  httpi (~> 2.0)
167
180
  nokogiri (>= 1.4.2)
168
- webmock (3.18.1)
181
+ webmock (3.19.1)
169
182
  addressable (>= 2.8.0)
170
183
  crack (>= 0.3.2)
171
184
  hashdiff (>= 0.4.0, < 2.0.0)
172
- webrick (1.7.0)
185
+ webrick (1.8.1)
173
186
  webrobots (0.1.2)
174
187
  xml-simple (1.1.9)
175
188
  rexml
176
- yard (0.9.28)
177
- webrick (~> 1.7.0)
189
+ yard (0.9.34)
178
190
 
179
191
  PLATFORMS
180
192
  ruby
@@ -195,4 +207,4 @@ DEPENDENCIES
195
207
  webmock
196
208
 
197
209
  BUNDLED WITH
198
- 2.3.26
210
+ 2.3.24
@@ -545,15 +545,50 @@ module Oddb2xml
545
545
  Oddb2xml.log "build_product add_missing_products_from_swissmedic. Added #{corrected_size - size_old} corrected_size #{corrected_size} size_old #{size_old} ean13_to_product."
546
546
  end
547
547
 
548
+ def add_products_from_bag_preparations(add_to_products = false)
549
+ Oddb2xml.log "build_product add_products_from_bag_preparations. Starting with #{@products.size} products and #{@items.size} @items"
550
+ ean13_to_product = {}
551
+ @products.each { |ean13, obj|
552
+ ean13_to_product[ean13] = obj
553
+ obj[:pharmacode] ||= @refdata[ean13][:pharmacode] if @refdata[ean13]
554
+ }
555
+ size_old = ean13_to_product.size
556
+ Oddb2xml.log "build_product add_products_from_bag_preparations. Imported #{size_old} ean13_to_product from @products. Checking #{@items.size} @items"
557
+ @items.each do |ean13, item|
558
+ next if @products[ean13]
559
+ if add_to_products
560
+ @products[ean13] = {
561
+ seq: item,
562
+ pac: nil,
563
+ sequence_name: "",
564
+ desc_de: "#{item[:name_de]}, #{item[:desc_de]}, #{item[:packages][ean13][:desc_de]}",
565
+ desc_fr: "#{item[:name_fr]}, #{item[:desc_fr]}, #{item[:packages][ean13][:desc_fr]}",
566
+ no8: "",
567
+ ean13: ean13,
568
+ atc: item[:atc_code],
569
+ ith: "",
570
+ siz: "",
571
+ eht: "",
572
+ sub: "",
573
+ comp: "",
574
+ drug_index: ""
575
+ }
576
+ end
577
+ ean13_to_product[ean13] = item
578
+ end
579
+ corrected_size = ean13_to_product.size
580
+ Oddb2xml.log "build_product add_products_from_bag_preparations. Added #{corrected_size - size_old} corrected_size #{corrected_size} size_old #{size_old} ean13_to_product."
581
+ end
582
+
548
583
  def build_product
549
584
  self.class.class_eval do
550
585
  def check_name(obj, lang = :de)
551
586
  ean = obj[:ean13]
552
587
  refdata = @refdata[ean]
553
588
  if lang == :de
554
- name = refdata && refdata[:desc_de] ? refdata[:desc_de] : obj[:sequence_name]
589
+ name = refdata && refdata[:desc_de] ? refdata[:desc_de] : (obj[:desc_de] || obj[:sequence_name])
555
590
  elsif lang == :fr
556
- name = refdata && refdata[:desc_fr] ? refdata[:desc_fr] : obj[:sequence_name]
591
+ name = refdata && refdata[:desc_fr] ? refdata[:desc_fr] : (obj[:desc_fr] || obj[:sequence_name])
557
592
  elsif lang == :it
558
593
  name = refdata[:desc_it] if refdata && refdata[:desc_it]
559
594
  else
@@ -568,6 +603,7 @@ module Oddb2xml
568
603
  prepare_interactions
569
604
  prepare_codes
570
605
  add_missing_products_from_swissmedic
606
+ add_products_from_bag_preparations(true)
571
607
  nbr_products = 0
572
608
  Oddb2xml.log "build_product #{@products.size + @missing.size} products"
573
609
  a_builder = Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml|
@@ -1722,6 +1758,7 @@ module Oddb2xml
1722
1758
  prepare_articles
1723
1759
  prepare_products
1724
1760
  add_missing_products_from_swissmedic(true)
1761
+ add_products_from_bag_preparations(true)
1725
1762
  prepare_calc_items(suppress_composition_parsing: true)
1726
1763
  @prepared = true
1727
1764
  @old_rose_size = @infos_zur_rose.size
data/lib/oddb2xml/calc.rb CHANGED
@@ -95,8 +95,8 @@ module Oddb2xml
95
95
  UNKNOWN_GALENIC_FORM = 140
96
96
  UNKNOWN_GALENIC_GROUP = 1
97
97
  DATA_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data"))
98
- @@galenic_groups = YAML.load_file(File.join(DATA_DIR, "gal_groups.yaml"), permitted_classes: [ Oddb2xml::GalenicForm, Oddb2xml::GalenicGroup, Symbol])
99
- @@galenic_forms = YAML.load_file(File.join(DATA_DIR, "gal_forms.yaml"), permitted_classes: [ Oddb2xml::GalenicForm, Oddb2xml::GalenicGroup, Symbol])
98
+ @@galenic_groups = YAML.safe_load_file(File.join(DATA_DIR, "gal_groups.yaml"), permitted_classes: [ Oddb2xml::GalenicForm, Oddb2xml::GalenicGroup, Symbol])
99
+ @@galenic_forms = YAML.safe_load_file(File.join(DATA_DIR, "gal_forms.yaml"), permitted_classes: [ Oddb2xml::GalenicForm, Oddb2xml::GalenicGroup, Symbol])
100
100
  @@new_galenic_forms = []
101
101
  @@names_without_galenic_forms = []
102
102
  @@rules_counter = {}
data/lib/oddb2xml/cli.rb CHANGED
@@ -40,7 +40,7 @@ module Oddb2xml
40
40
  start_time = Time.now
41
41
  files2rm = Dir.glob(File.join(DOWNLOADS, "*"))
42
42
  FileUtils.rm_f(files2rm, verbose: true) if (files2rm.size > 0) && !Oddb2xml.skip_download?
43
- if @options[:calc] && !(@options[:extended])
43
+ if @options[:calc] && !(@options[:extended] || @options[:firstbase])
44
44
  threads << download(:package) # swissmedic
45
45
  elsif @options[:address]
46
46
  [:company, :person].each do |type|
@@ -106,9 +106,9 @@ module Oddb2xml
106
106
  private
107
107
 
108
108
  def build
109
- @the_files = {"calc" => "oddb_calc.xml"} if @options[:calc] && !(@options[:extended] || @options[:artikelstamm])
109
+ @the_files = {"calc" => "oddb_calc.xml"} if @options[:calc] && !(@options[:extended] || @options[:artikelstamm] || @options[:firstbase])
110
110
  builder = Builder.new(@options) do |builder|
111
- if @options[:calc] && !(@options[:extended] || @options[:artikelstamm])
111
+ if @options[:calc] && !(@options[:extended] || @options[:artikelstamm] || @options[:firstbase])
112
112
  builder.packs = @packs
113
113
  elsif @options[:address]
114
114
  builder.companies = @companies
@@ -343,7 +343,9 @@ module Oddb2xml
343
343
  def files
344
344
  unless @the_files
345
345
  @the_files = {}
346
- @the_files[:calc] = "oddb_calc.xml" if @options[:calc]
346
+ if @options[:calc]
347
+ @the_files[:calc] = "oddb_calc.xml"
348
+ end
347
349
  if @options[:artikelstamm]
348
350
  @the_files[:artikelstamm] = "artikelstamm_#{Date.today.strftime("%d%m%Y")}_v5.xml"
349
351
  elsif @options[:address]
@@ -55,6 +55,11 @@ module Oddb2xml
55
55
  @opts.delete(:increment)
56
56
  @opts[:nonpharma] = @opts[:append]
57
57
  @opts.delete(:append)
58
+ if @opts[:firstbase]
59
+ @opts[:nonpharma] = true
60
+ # https://github.com/zdavatz/oddb2xml/issues/76
61
+ @opts[:calc] = true
62
+ end
58
63
  if @opts[:extended]
59
64
  @opts[:nonpharma] = true
60
65
  @opts[:price] = :zurrose
@@ -64,9 +69,6 @@ module Oddb2xml
64
69
  @opts[:extended] = true
65
70
  @opts[:price] = :zurrose
66
71
  end
67
- if @opts[:firstbase]
68
- @opts[:nonpharma] = true
69
- end
70
72
  @opts[:price] = :zurrose if @opts[:price].is_a?(TrueClass)
71
73
  @opts[:price] = @opts[:price].to_sym if @opts[:price]
72
74
  @opts[:ean14] = @opts[:include]
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "2.8.1"
2
+ VERSION = "2.8.3"
3
3
  end
data/spec/builder_spec.rb CHANGED
@@ -458,7 +458,7 @@ NR_LIMITATIONS = 15
458
458
  NR_INTERACTIONS = 2
459
459
  NR_CODES = 5
460
460
  NR_PRODNO = 31
461
- NR_PACKAGES = 47
461
+ NR_PACKAGES = 61
462
462
  NR_PRODUCTS = 40
463
463
  REG_EXP_DESITIN = /1120000000LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk/
464
464
  describe Oddb2xml::Builder do
data/spec/options_spec.rb CHANGED
@@ -15,7 +15,8 @@ Oddb2xml::DEFAULT_OPTS = {
15
15
  skip_download: false,
16
16
  log: false,
17
17
  percent: nil,
18
- use_ra11zip: nil
18
+ use_ra11zip: nil,
19
+ firstbase: false,
19
20
  }
20
21
 
21
22
  describe Oddb2xml::Options do
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.8.1
4
+ version: 2.8.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: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip