nuva 0.6.0 → 0.7.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/Changelog.md +11 -0
- data/lib/nuva/version.rb +1 -1
- data/lib/nuva/version_watcher.rb +53 -0
- data/lib/nuva.rb +35 -43
- data/nuva.gemspec +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ee207a48f475b7d608be8c0e044e83b304841c18bb480d7b76ee9fbf234a547
|
|
4
|
+
data.tar.gz: 489b90f689fc66608cb7c48372898bb4e8d778c0d7d8a81999100ed9f4080c0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a527ae401a066a78deb7d7c1b55caec65376506ab9004f871c06c4b8252a519805e757cc8f1e1db5a11c4ae844d4850723721f9c53d2b6cdc26013bb31e44b82
|
|
7
|
+
data.tar.gz: b14d72734d86b26a1ec5a8b91af6ac5bd54ff5bb45a59535b4ff715983f0245cd14041370cda4f606d06e7d42c65608cbfe6cbca2c525531fc3c71009317c1f5
|
data/Changelog.md
CHANGED
|
@@ -5,6 +5,17 @@ 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.7.0] - 2026-11-18
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `Nuva::Nuva.watch_latest_version`, which polls the CDN version manifest and calls `on_update` with the new dump hash when a new version is published. Failures are reported to the optional `on_error` callback and the update is retried on the next poll.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- `Nuva::Nuva.load` no longer closes its HTTP connection before downloading the dump.
|
|
17
|
+
- Declare the `ostruct` dependency, no longer a default gem since Ruby 4.0.
|
|
18
|
+
|
|
8
19
|
## [0.6.0] - 2026-09-18
|
|
9
20
|
|
|
10
21
|
### Changed
|
data/lib/nuva/version.rb
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nuva
|
|
4
|
+
class VersionWatcher
|
|
5
|
+
attr_reader :current_version_hash
|
|
6
|
+
|
|
7
|
+
def initialize(fetch_latest_version_hash:, polling_interval:, on_update:, on_error: nil)
|
|
8
|
+
raise ArgumentError, "polling_interval must be positive" unless polling_interval.positive?
|
|
9
|
+
raise ArgumentError, "on_update must respond to #call" unless on_update.respond_to?(:call)
|
|
10
|
+
raise ArgumentError, "on_error must respond to #call" unless on_error.nil? || on_error.respond_to?(:call)
|
|
11
|
+
|
|
12
|
+
@fetch_latest_version_hash = fetch_latest_version_hash
|
|
13
|
+
@polling_interval = polling_interval
|
|
14
|
+
@on_update = on_update
|
|
15
|
+
@on_error = on_error
|
|
16
|
+
@current_version_hash = @fetch_latest_version_hash.call
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def start
|
|
20
|
+
@thread = Thread.new do
|
|
21
|
+
loop do
|
|
22
|
+
sleep(@polling_interval)
|
|
23
|
+
check_for_update
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
self
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def stop
|
|
31
|
+
@thread&.kill
|
|
32
|
+
@thread&.join
|
|
33
|
+
|
|
34
|
+
self
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def check_for_update
|
|
38
|
+
latest_version_hash = @fetch_latest_version_hash.call
|
|
39
|
+
|
|
40
|
+
return if latest_version_hash == @current_version_hash
|
|
41
|
+
|
|
42
|
+
@on_update.call(latest_version_hash)
|
|
43
|
+
|
|
44
|
+
@current_version_hash = latest_version_hash
|
|
45
|
+
rescue StandardError => e
|
|
46
|
+
@on_error&.call(e)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def running?
|
|
50
|
+
@thread&.alive? || false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
data/lib/nuva.rb
CHANGED
|
@@ -4,6 +4,7 @@ require_relative "nuva/version"
|
|
|
4
4
|
require_relative "nuva/NuvaDatabase_pb"
|
|
5
5
|
require_relative "nuva/repository"
|
|
6
6
|
require_relative "nuva/queries"
|
|
7
|
+
require_relative "nuva/version_watcher"
|
|
7
8
|
require "net/http"
|
|
8
9
|
require "json"
|
|
9
10
|
require "ostruct"
|
|
@@ -14,40 +15,28 @@ module Nuva
|
|
|
14
15
|
attr_reader :queries
|
|
15
16
|
|
|
16
17
|
def initialize(db)
|
|
17
|
-
@db
|
|
18
|
-
|
|
18
|
+
@db = db
|
|
19
19
|
@repositories = OpenStruct.new
|
|
20
|
-
@
|
|
21
|
-
|
|
22
|
-
@repositories.
|
|
23
|
-
@repositories.
|
|
20
|
+
@queries = OpenStruct.new
|
|
21
|
+
|
|
22
|
+
@repositories.vaccines = VaccineRepository.new(db.vaccines)
|
|
23
|
+
@repositories.valences = ValenceRepository.new(db.valences)
|
|
24
|
+
@repositories.diseases = DiseaseRepository.new(db.diseases)
|
|
24
25
|
|
|
25
|
-
@queries
|
|
26
|
-
@queries.
|
|
27
|
-
|
|
28
|
-
@queries.
|
|
29
|
-
|
|
30
|
-
@queries.
|
|
31
|
-
::Nuva::Queries::
|
|
32
|
-
@queries.
|
|
33
|
-
|
|
34
|
-
@queries.
|
|
35
|
-
|
|
36
|
-
@queries.
|
|
37
|
-
|
|
38
|
-
@
|
|
39
|
-
::Nuva::Queries::VaccineFuzzySearchQuery.new @repositories
|
|
40
|
-
@queries.lookup_vaccine_by_code =
|
|
41
|
-
::Nuva::Queries::LookupVaccineByCodeQuery.new @repositories
|
|
42
|
-
@queries.lookup_equivalent_vaccines =
|
|
43
|
-
::Nuva::Queries::LookupEquivalentVaccinesQuery.new @repositories
|
|
44
|
-
@queries.lookup_generalized_vaccines =
|
|
45
|
-
::Nuva::Queries::LookupGeneralizedVaccinesQuery.new @repositories,
|
|
46
|
-
@queries.valences_by_vaccine
|
|
47
|
-
@queries.all_nomenclatures =
|
|
48
|
-
::Nuva::Queries::AllNomenclaturesQuery.new @repositories
|
|
49
|
-
@queries.all_code_by_nomenclature =
|
|
50
|
-
::Nuva::Queries::AllCodeByNomenclatureQuery.new @repositories
|
|
26
|
+
@queries.valences_by_vaccine = ::Nuva::Queries::ValencesByVaccineQuery.new(@repositories)
|
|
27
|
+
@queries.vaccines_by_valence = ::Nuva::Queries::VaccinesByValenceQuery.new(@repositories)
|
|
28
|
+
@queries.vaccines_by_disease = ::Nuva::Queries::VaccinesByDiseaseQuery.new(@repositories)
|
|
29
|
+
@queries.valences_by_disease = ::Nuva::Queries::ValencesByDiseaseQuery.new(@repositories)
|
|
30
|
+
@queries.diseases_by_vaccine = ::Nuva::Queries::DiseasesByVaccineQuery.new(@repositories)
|
|
31
|
+
@queries.diseases_by_valence = ::Nuva::Queries::DiseasesByValenceQuery.new(@repositories)
|
|
32
|
+
@queries.vaccine_fuzzy_search = ::Nuva::Queries::VaccineFuzzySearchQuery.new(@repositories)
|
|
33
|
+
@queries.lookup_vaccine_by_code = ::Nuva::Queries::LookupVaccineByCodeQuery.new(@repositories)
|
|
34
|
+
@queries.lookup_equivalent_vaccines = ::Nuva::Queries::LookupEquivalentVaccinesQuery.new(@repositories)
|
|
35
|
+
@queries.lookup_generalized_vaccines = ::Nuva::Queries::LookupGeneralizedVaccinesQuery.new(@repositories, @queries.valences_by_vaccine)
|
|
36
|
+
@queries.all_nomenclatures = ::Nuva::Queries::AllNomenclaturesQuery.new(@repositories)
|
|
37
|
+
@queries.all_code_by_nomenclature = ::Nuva::Queries::AllCodeByNomenclatureQuery.new(@repositories)
|
|
38
|
+
|
|
39
|
+
@repositories.freeze
|
|
51
40
|
@queries.freeze
|
|
52
41
|
end
|
|
53
42
|
|
|
@@ -64,23 +53,26 @@ module Nuva
|
|
|
64
53
|
|
|
65
54
|
def load(cdn_uri: DEFAULT_CDN_URI, lang: "en", hash: nil, proxy_addr: nil, proxy_port: nil)
|
|
66
55
|
init_http(cdn_uri, proxy_addr, proxy_port) do |http|
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
hash ||= fetch_latest_version_hash(http:)
|
|
57
|
+
response = http.get("/proto/#{hash}_#{lang}.db")
|
|
69
58
|
|
|
70
|
-
response = http.get("/proto/#{hash}_#{lang}.db")
|
|
71
59
|
::Nuva::Nuva.new(::Nuva::NuvaDatabase.decode(response.body))
|
|
72
60
|
end
|
|
73
61
|
end
|
|
74
62
|
|
|
75
63
|
def fetch_latest_version_hash(cdn_uri: DEFAULT_CDN_URI, proxy_addr: nil, proxy_port: nil, http: nil)
|
|
76
|
-
if http.nil?
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
return init_http(cdn_uri, proxy_addr, proxy_port) { |h| fetch_latest_version_hash(http: h) } if http.nil?
|
|
65
|
+
|
|
66
|
+
JSON.parse(http.get("/versions/last.json").body)["dump_hash"]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def watch_latest_version(cdn_uri: DEFAULT_CDN_URI, polling_interval: 60, on_update:, on_error: nil, proxy_addr: nil, proxy_port: nil)
|
|
70
|
+
VersionWatcher.new(
|
|
71
|
+
fetch_latest_version_hash: -> { fetch_latest_version_hash(cdn_uri:, proxy_addr:, proxy_port:) },
|
|
72
|
+
polling_interval:,
|
|
73
|
+
on_update:,
|
|
74
|
+
on_error:
|
|
75
|
+
).start
|
|
84
76
|
end
|
|
85
77
|
|
|
86
78
|
def load_from_file(path)
|
data/nuva.gemspec
CHANGED
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
|
|
32
32
|
spec.add_dependency 'google-protobuf', '>= 4.35.1', '< 5'
|
|
33
33
|
spec.add_dependency 'fuzzy_match', '~> 2.1'
|
|
34
|
+
spec.add_dependency 'ostruct'
|
|
34
35
|
|
|
35
36
|
# For more information and examples about making a new gem, check out our
|
|
36
37
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nuva
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Syadem
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: google-protobuf
|
|
@@ -44,6 +44,20 @@ dependencies:
|
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: '2.1'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: ostruct
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
47
61
|
description: nuva library aims to simplify working and interacting with the NUVA nomenclature
|
|
48
62
|
through queries and repositories.
|
|
49
63
|
email:
|
|
@@ -72,6 +86,7 @@ files:
|
|
|
72
86
|
- lib/nuva/repositories/valence_repository.rb
|
|
73
87
|
- lib/nuva/repository.rb
|
|
74
88
|
- lib/nuva/version.rb
|
|
89
|
+
- lib/nuva/version_watcher.rb
|
|
75
90
|
- nuva.gemspec
|
|
76
91
|
- sig/nuva.rbs
|
|
77
92
|
homepage: https://docs.nuva.mesvaccins.net
|
|
@@ -93,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
108
|
- !ruby/object:Gem::Version
|
|
94
109
|
version: '0'
|
|
95
110
|
requirements: []
|
|
96
|
-
rubygems_version: 3.
|
|
111
|
+
rubygems_version: 3.5.22
|
|
97
112
|
signing_key:
|
|
98
113
|
specification_version: 4
|
|
99
114
|
summary: NUVA
|