oddb2xml 3.0.18 → 3.0.19
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 +4 -4
- data/Gemfile.lock +1 -1
- data/History.txt +3 -0
- data/lib/oddb2xml/cli.rb +5 -0
- data/lib/oddb2xml/options.rb +1 -0
- data/lib/oddb2xml/proxy_check.rb +51 -11
- data/lib/oddb2xml/version.rb +1 -1
- data/spec/options_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '081c86c751d4c29fa2ce616abdb6043707e50fab79e3b74a67aab568b2084519'
|
|
4
|
+
data.tar.gz: e3c91770aa8ccd4de0714c45f5a20eb7f87fc989ea84932a8e4cf1a5a3813a7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8a928d127496fb06cba79dc630c19bd5edc3b09dd3df0c0dda6ca058cd1897643818d4a8aa9e2ab125023d0ebb319dddee2ab1be0fcdabc8e4708299a136dee
|
|
7
|
+
data.tar.gz: 27c6ef5bcb9fa0df5b7861496468a88b416209a8b83e7c08e3a995407a75944f0d81849d75399254b7ee404787128ed9e4742ef5f6a78107d90f895845afe707
|
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
=== 3.0.19 / 09.06.2026
|
|
2
|
+
* New option --proxy-check: probe connectivity/proxy reachability for every host oddb2xml could need, print a full OK/BLOCKED/UNREACHABLE report (honouring http(s)_proxy) and exit without downloading or building. Exits 0 if all hosts are reachable, 1 otherwise — handy for cron/deploy preflight on allow-list proxies (e.g. "oddb2xml --proxy-check"). Reuses the 3.0.18 proxy checker; checks run concurrently.
|
|
3
|
+
|
|
1
4
|
=== 3.0.18 / 09.06.2026
|
|
2
5
|
* Bugfix: stop the FHIR downloader from crashing with "Errno::ENOENT @ rb_file_s_size ... foph-sl-export-latest-de.ndjson" when run with --skip-download (issue #121). FhirDownloader#skip_download? returned true on the bare --skip-download flag and then called File.size on a file that was never downloaded. Each oddb2xml run uses its own ./downloads dir, so deploy scripts that download once and then re-run with --skip-download in a fresh dir hit this every time. skip_download? now requires the target NDJSON to actually exist on disk before honouring the flag; a missing file falls through to a normal download instead of crashing.
|
|
3
6
|
* New: proxy / connectivity preflight check (issue #121). At the very start of a run, oddb2xml now probes the outbound hosts it needs (honouring the http(s)_proxy environment) and prints a loud warning if any host is blocked by the proxy (HTTP 407 on an allow-list proxy such as Aspectra's Skyhigh gateway) or otherwise unreachable — surfacing the cause up front instead of a later empty-output/Errno symptom. The probed host set is option-aware (e.g. id.gs1.ch only with --firstbase, epl.bag.admin.ch only with --fhir). It only warns and never aborts the run; downloads still proceed and fail individually as before. Checks run concurrently (~6s worst case) and are skipped during tests; set ODDB2XML_SKIP_PROXY_CHECK=1 to silence it.
|
data/lib/oddb2xml/cli.rb
CHANGED
|
@@ -39,6 +39,11 @@ module Oddb2xml
|
|
|
39
39
|
def run
|
|
40
40
|
threads = []
|
|
41
41
|
start_time = Time.now
|
|
42
|
+
if @options[:proxy_check]
|
|
43
|
+
ok = ProxyCheck.report(@options)
|
|
44
|
+
exit(ok ? 0 : 1) unless defined?(RSpec)
|
|
45
|
+
return ok
|
|
46
|
+
end
|
|
42
47
|
ProxyCheck.run(@options)
|
|
43
48
|
files2rm = Dir.glob(File.join(DOWNLOADS, "*"))
|
|
44
49
|
FileUtils.rm_f(files2rm, verbose: true) if (files2rm.size > 0) && !Oddb2xml.skip_download?
|
data/lib/oddb2xml/options.rb
CHANGED
|
@@ -46,6 +46,7 @@ module Oddb2xml
|
|
|
46
46
|
opt :use_ra11zip, "Use the ra11.zip (a zipped transfer.dat from Galexis)",
|
|
47
47
|
default: File.exist?("ra11.zip") ? "ra11.zip" : nil, type: :string
|
|
48
48
|
opt :firstbase, "Build all NONPHARMA articles on firstbase (GS1 Switzerland CSV from id.gs1.ch)", short: "b", default: false
|
|
49
|
+
opt :proxy_check, "Only probe connectivity/proxy reachability for every required host, print a report and exit (no download/build). Honours http(s)_proxy. Exits 0 if all reachable, 1 otherwise.", short: :none, default: false
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
@opts[:percent] = @opts[:increment]
|
data/lib/oddb2xml/proxy_check.rb
CHANGED
|
@@ -43,6 +43,46 @@ module Oddb2xml
|
|
|
43
43
|
hosts
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# Full union of every host any run could need, regardless of options.
|
|
47
|
+
# Used by --proxy-check so the report covers everything in one go.
|
|
48
|
+
def all_hosts
|
|
49
|
+
BASE_HOSTS.merge(
|
|
50
|
+
"epl.bag.admin.ch" => "BAG FHIR data (--fhir)",
|
|
51
|
+
"id.gs1.ch" => "GS1 NONPHARMA (--firstbase / -b)",
|
|
52
|
+
"www.spezialitaetenliste.ch" => "BAG Spezialitätenliste",
|
|
53
|
+
"www.medregbm.admin.ch" => "Medizinalberuferegister (-x address)"
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Probe every host and print a full OK/BLOCKED/UNREACHABLE table.
|
|
58
|
+
# Returns true when all hosts are reachable. Used by `oddb2xml --proxy-check`.
|
|
59
|
+
def report(_options = {})
|
|
60
|
+
proxy = proxy_uri
|
|
61
|
+
results = all_hosts.map do |host, desc|
|
|
62
|
+
Thread.new { [host, desc, check_host(host, proxy)] }
|
|
63
|
+
end.map(&:value).sort_by { |(host, _desc, _status)| host }
|
|
64
|
+
|
|
65
|
+
header = "oddb2xml connectivity check"
|
|
66
|
+
header += proxy ? " (via proxy #{proxy.host}:#{proxy.port})" : " (no proxy configured)"
|
|
67
|
+
puts header
|
|
68
|
+
results.each do |(host, desc, status)|
|
|
69
|
+
tag = case status
|
|
70
|
+
when :ok then "OK "
|
|
71
|
+
when :blocked then "BLOCKED" # proxy returned 407
|
|
72
|
+
else "UNREACH"
|
|
73
|
+
end
|
|
74
|
+
puts format(" [%s] %-28s %s", tag, host, desc)
|
|
75
|
+
end
|
|
76
|
+
unreachable = results.reject { |(_host, _desc, status)| status == :ok }
|
|
77
|
+
if unreachable.empty?
|
|
78
|
+
puts "All #{results.size} hosts reachable."
|
|
79
|
+
true
|
|
80
|
+
else
|
|
81
|
+
puts "#{unreachable.size} of #{results.size} host(s) NOT reachable -- downloads using them will fail."
|
|
82
|
+
false
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
46
86
|
# Returns :ok, :blocked (proxy 407) or :unreachable for a single host.
|
|
47
87
|
def check_host(host, proxy)
|
|
48
88
|
http =
|
|
@@ -85,24 +125,24 @@ module Oddb2xml
|
|
|
85
125
|
|
|
86
126
|
def warn_about(problems, proxy)
|
|
87
127
|
line = "=" * 72
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
128
|
+
warn line
|
|
129
|
+
warn " oddb2xml CONNECTIVITY WARNING"
|
|
130
|
+
warn " The following hosts could not be reached -- the corresponding"
|
|
131
|
+
warn " downloads will FAIL or produce incomplete data:"
|
|
92
132
|
problems.each do |(host, desc, status)|
|
|
93
133
|
tag = (status == :blocked) ? "BLOCKED by proxy (407)" : "UNREACHABLE "
|
|
94
|
-
|
|
134
|
+
warn format(" [%s] %-26s %s", tag, host, desc)
|
|
95
135
|
end
|
|
96
136
|
if proxy
|
|
97
|
-
|
|
98
|
-
|
|
137
|
+
warn ""
|
|
138
|
+
warn " Proxy in use: #{proxy.host}:#{proxy.port}"
|
|
99
139
|
if problems.any? { |(_h, _d, s)| s == :blocked }
|
|
100
|
-
|
|
101
|
-
|
|
140
|
+
warn " This looks like an allow-list proxy. Ask your admin to allow the"
|
|
141
|
+
warn " hosts above (HTTPS/443), or set credentials in http(s)_proxy."
|
|
102
142
|
end
|
|
103
143
|
end
|
|
104
|
-
|
|
105
|
-
|
|
144
|
+
warn " (Set ODDB2XML_SKIP_PROXY_CHECK=1 to silence this check.)"
|
|
145
|
+
warn line
|
|
106
146
|
end
|
|
107
147
|
end
|
|
108
148
|
end
|
data/lib/oddb2xml/version.rb
CHANGED
data/spec/options_spec.rb
CHANGED
|
@@ -19,6 +19,7 @@ Oddb2xml::DEFAULT_OPTS = {
|
|
|
19
19
|
firstbase: false,
|
|
20
20
|
fhir: false,
|
|
21
21
|
fhir_url: nil,
|
|
22
|
+
proxy_check: false,
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
describe Oddb2xml::Options do
|
|
@@ -75,6 +76,7 @@ describe Oddb2xml::Options do
|
|
|
75
76
|
expected[:nonpharma] = true
|
|
76
77
|
expected[:calc] = true
|
|
77
78
|
expected[:price] = :zurrose
|
|
79
|
+
expected[:fhir] = true
|
|
78
80
|
specify { expect(test_opts).to eq expected }
|
|
79
81
|
end
|
|
80
82
|
|
|
@@ -86,6 +88,7 @@ describe Oddb2xml::Options do
|
|
|
86
88
|
expected[:calc] = true
|
|
87
89
|
expected[:price] = :zurrose
|
|
88
90
|
expected[:percent] = 80
|
|
91
|
+
expected[:fhir] = true
|
|
89
92
|
specify { expect(test_opts).to eq expected }
|
|
90
93
|
end
|
|
91
94
|
|
|
@@ -165,6 +168,7 @@ describe Oddb2xml::Options do
|
|
|
165
168
|
expected[:price] = :zurrose
|
|
166
169
|
expected[:extended] = true
|
|
167
170
|
expected[:artikelstamm] = true
|
|
171
|
+
expected[:fhir] = true
|
|
168
172
|
specify { expect(test_opts).to eq expected }
|
|
169
173
|
end
|
|
170
174
|
|