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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afbabc0a255bd36f3b3b9d4a9df5b0ea139651c620a4884f6366f7d4d70cd221
4
- data.tar.gz: 8a58a082d0d3a11815cbfb47aa985c2114d42e5e0c0e198eb8642bbb57224a64
3
+ metadata.gz: a5d1d66d1f5d5b9b5e770c71d441e14663dd379dcd6cf976fff239db9df601e0
4
+ data.tar.gz: 5908983a10c103910cf0505b3a60df9f918d87d60cd4bd5f1578a07da18f5ce1
5
5
  SHA512:
6
- metadata.gz: 5dfadcffe9da8ffded45109e4fb803f35ec416279660480550981541ac63e87044382d36464a71a32663ac977b295afe35b1a86a728570012eac28052b80015c
7
- data.tar.gz: 934776897a3fd617bdfbd9012b3ae0e539eb918d7ab85ac2453157b06478dda9ea919f779f386e2501affa473e46df32ed4000a1431bb427119bca966eb8cfb6
6
+ metadata.gz: 91c1bbfaef7424ad18043c051f8176eb492b56c848d6a36ca9c1701d3bd1351b798aede58c1dad50cbd36cbbe254be3dc8380e76cbe660270466e007794b4e8e
7
+ data.tar.gz: c967dfb3a4e30a95cfabe02d6a43d64d853a7b096045e17d00a657cacd2990f9641c23a4046851826066160e33e456c0df38587fd3c40666c5dc6318fbe1d892
data/.rubocop.yml CHANGED
@@ -59,7 +59,7 @@ Lint/RequireParentheses:
59
59
  Enabled: true
60
60
 
61
61
  Lint/ShadowingOuterLocalVariable:
62
- Enabled: true
62
+ Enabled: false
63
63
 
64
64
  Lint/RedundantStringCoercion:
65
65
  Enabled: true
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nuva
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.1"
5
5
  end
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
- LATEST_VERSION_URI =
63
- URI("https://cdnnuva.mesvaccins.net/versions/last.json")
62
+ class << self
63
+ DEFAULT_CDN_URI = URI("https://nuva.svc.edge.scw.cloud")
64
64
 
65
- def self.load(lang: "en", hash: nil)
66
- ::Net::HTTP.start(
67
- LATEST_VERSION_URI.host,
68
- LATEST_VERSION_URI.port,
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
- dump_uri = LATEST_VERSION_URI.dup
75
- dump_uri.path = "/proto/#{hash}_en.db"
76
- response = http.get(dump_uri)
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
- def self.fetch_latest_version_hash(http: Net::HTTP)
82
- response = http.get(LATEST_VERSION_URI)
83
- JSON.parse(response.body)["dump_hash"]
84
- end
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
- def self.load_from_file(path)
87
- Nuva.new(NuvaDatabase.decode(File.read(path)))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuva
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syadem