nuva 0.4.0 → 0.5.1
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/.rubocop.yml +1 -1
- data/Changelog.md +18 -0
- data/lib/nuva/version.rb +1 -1
- data/lib/nuva.rb +33 -21
- 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: a5d1d66d1f5d5b9b5e770c71d441e14663dd379dcd6cf976fff239db9df601e0
|
4
|
+
data.tar.gz: 5908983a10c103910cf0505b3a60df9f918d87d60cd4bd5f1578a07da18f5ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91c1bbfaef7424ad18043c051f8176eb492b56c848d6a36ca9c1701d3bd1351b798aede58c1dad50cbd36cbbe254be3dc8380e76cbe660270466e007794b4e8e
|
7
|
+
data.tar.gz: c967dfb3a4e30a95cfabe02d6a43d64d853a7b096045e17d00a657cacd2990f9641c23a4046851826066160e33e456c0df38587fd3c40666c5dc6318fbe1d892
|
data/.rubocop.yml
CHANGED
data/Changelog.md
CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.5.1] - 2025-01-21
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Change default URL (use Scaleway CDN instead of KeyCDN)
|
13
|
+
|
14
|
+
## [0.5.0] - 2025-01-21
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- New kwarg `cdn_uri` enables fetching nuva data from a custom cdn
|
19
|
+
|
20
|
+
## [0.4.1] - 2025-01-21
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- Fix `Nuva.fetch_latest_version_hash` (http error)
|
25
|
+
|
8
26
|
## [0.4.0] - 2025-01-21
|
9
27
|
|
10
28
|
### Added
|
data/lib/nuva/version.rb
CHANGED
data/lib/nuva.rb
CHANGED
@@ -59,32 +59,44 @@ module Nuva
|
|
59
59
|
"#<Nuva::Nuva version=#{version.major}.#{version.minor}.#{version.patch} diseaseCount=#{repositories.diseases.all.count} vaccineCount=#{repositories.vaccines.all.count} valenceCount=#{repositories.valences.all.count}>"
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
URI("https://
|
62
|
+
class << self
|
63
|
+
DEFAULT_CDN_URI = URI("https://nuva.svc.edge.scw.cloud")
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
use_ssl: LATEST_VERSION_URI.scheme == "https"
|
70
|
-
) do |http|
|
71
|
-
# Fetch version manifest if necessary
|
72
|
-
hash ||= fetch_latest_version_hash(http:)
|
65
|
+
def load(cdn_uri: DEFAULT_CDN_URI, lang: "en", hash: nil)
|
66
|
+
init_http(cdn_uri) do |http|
|
67
|
+
# Fetch version manifest if necessary
|
68
|
+
hash ||= fetch_latest_version_hash(http:)
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
::Nuva::Nuva.new(::Nuva::NuvaDatabase.decode(response.body))
|
70
|
+
response = http.get("/proto/#{hash}_en.db")
|
71
|
+
::Nuva::Nuva.new(::Nuva::NuvaDatabase.decode(response.body))
|
72
|
+
end
|
78
73
|
end
|
79
|
-
end
|
80
74
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
def fetch_latest_version_hash(cdn_uri: DEFAULT_CDN_URI, http: nil)
|
76
|
+
if http.nil?
|
77
|
+
http = init_http(cdn_uri)
|
78
|
+
passed_http = false
|
79
|
+
end
|
80
|
+
response = http.get("/versions/last.json")
|
81
|
+
hash = JSON.parse(response.body)["dump_hash"]
|
82
|
+
http.finish unless passed_http
|
83
|
+
hash
|
84
|
+
end
|
85
85
|
|
86
|
-
|
87
|
-
|
86
|
+
def load_from_file(path)
|
87
|
+
Nuva.new(NuvaDatabase.decode(File.read(path)))
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def init_http(cdn_uri, &block)
|
93
|
+
Net::HTTP.start(
|
94
|
+
cdn_uri.host,
|
95
|
+
cdn_uri.port,
|
96
|
+
use_ssl: cdn_uri.scheme == "https",
|
97
|
+
&block
|
98
|
+
)
|
99
|
+
end
|
88
100
|
end
|
89
101
|
end
|
90
102
|
end
|