nuva 0.4.0 → 0.4.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: a10259a0f94a7d196b5e120a1c6c6abf3706fc19c94d8bd900655615f38d1ee0
4
+ data.tar.gz: c1ab5a528fc2a790cea4652df5e60e6f60da1558ce9bf16a8cd0e3550d6d7e3a
5
5
  SHA512:
6
- metadata.gz: 5dfadcffe9da8ffded45109e4fb803f35ec416279660480550981541ac63e87044382d36464a71a32663ac977b295afe35b1a86a728570012eac28052b80015c
7
- data.tar.gz: 934776897a3fd617bdfbd9012b3ae0e539eb918d7ab85ac2453157b06478dda9ea919f779f386e2501affa473e46df32ed4000a1431bb427119bca966eb8cfb6
6
+ metadata.gz: 6ac19848c06ff44bbf9d8fb81818b81dce4be08f020390e5cfb105ac053cd1e761b072819d7dda35deb5bfb0fc9cc42ae7da0a7efab6f616963852621ab3f44c
7
+ data.tar.gz: 3d0656b6a11a389a3d29242ea790d034b24945e3caee911fbf99846141204ed8b490caafdac56d332febc2f26ce730347325e34cfde7356ebc724098b3e593c3
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,12 @@ 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.4.1] - 2025-01-21
9
+
10
+ ### Changed
11
+
12
+ - Fix `Nuva.fetch_latest_version_hash` (http error)
13
+
8
14
  ## [0.4.0] - 2025-01-21
9
15
 
10
16
  ### 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.4.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
+ CDN_URI = URI("https://cdnnuva.mesvaccins.net/")
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(lang: "en", hash: nil)
66
+ init_http 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(http: nil)
76
+ if http.nil?
77
+ http = init_http
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(&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.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syadem