nuva 0.3.1 → 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: 6005455d2bcaf93b115e51352c8d22dda90954c086f0ed5d378f9bbafcca2cf9
4
- data.tar.gz: 7430a09df08aab2786ea0433a51ebc86ca77a2718b26532a7591bed2edb660a3
3
+ metadata.gz: a10259a0f94a7d196b5e120a1c6c6abf3706fc19c94d8bd900655615f38d1ee0
4
+ data.tar.gz: c1ab5a528fc2a790cea4652df5e60e6f60da1558ce9bf16a8cd0e3550d6d7e3a
5
5
  SHA512:
6
- metadata.gz: c5852e5006e7de76aed2a716c8559398eba7eaf67df19ae4bc17b449675b89fee3f4ce0201c3861a80f1de36a3d6fc4d77db237ab6754e7c0ee1a7520cb8c600
7
- data.tar.gz: 1a67a955a8dc79d3219cefdbb7432ce4ad1312356a77e8a13a437a35228739e099bbc11b8dd2462ee6ae157b0349cab88f80e4b1f6e11eaa719ae42d0703e556
6
+ metadata.gz: 6ac19848c06ff44bbf9d8fb81818b81dce4be08f020390e5cfb105ac053cd1e761b072819d7dda35deb5bfb0fc9cc42ae7da0a7efab6f616963852621ab3f44c
7
+ data.tar.gz: 3d0656b6a11a389a3d29242ea790d034b24945e3caee911fbf99846141204ed8b490caafdac56d332febc2f26ce730347325e34cfde7356ebc724098b3e593c3
@@ -1,25 +1,29 @@
1
1
  // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
2
  // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
3
  {
4
- "name": "nuva-ruby",
5
- // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
- "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye",
7
- "features": {
8
- "ghcr.io/devcontainers/features/common-utils:2": {}
9
- }
4
+ "name": "nuva-ruby",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye",
7
+ "features": {
8
+ "ghcr.io/devcontainers/features/common-utils:2": {}
9
+ },
10
10
 
11
- // Features to add to the dev container. More info: https://containers.dev/features.
12
- // "features": {},
11
+ "containerEnv": {
12
+ "APP_ENV": "development"
13
+ }
13
14
 
14
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
15
- // "forwardPorts": [],
15
+ // Features to add to the dev container. More info: https://containers.dev/features.
16
+ // "features": {},
16
17
 
17
- // Use 'postCreateCommand' to run commands after the container is created.
18
- // "postCreateCommand": "ruby --version",
18
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
19
+ // "forwardPorts": [],
19
20
 
20
- // Configure tool-specific properties.
21
- // "customizations": {},
21
+ // Use 'postCreateCommand' to run commands after the container is created.
22
+ // "postCreateCommand": "ruby --version",
22
23
 
23
- // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
24
- // "remoteUser": "root"
24
+ // Configure tool-specific properties.
25
+ // "customizations": {},
26
+
27
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28
+ // "remoteUser": "root"
25
29
  }
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,19 @@ 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
+
14
+ ## [0.4.0] - 2025-01-21
15
+
16
+ ### Added
17
+
18
+ - Add method `Nuva.fetch_latest_version_hash`
19
+ - Support fetching specific nuva version with `Nuva.load`
20
+
8
21
  ## [0.3.1] - 2025-01-17
9
22
 
10
23
  ### Changed
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.3.1"
4
+ VERSION = "0.4.1"
5
5
  end
data/lib/nuva.rb CHANGED
@@ -55,41 +55,48 @@ module Nuva
55
55
  @db.version
56
56
  end
57
57
 
58
- def self.load(lang = "en")
59
- latest_version_uri =
60
- URI "https://cdnnuva.mesvaccins.net/versions/last.json"
61
-
62
- ::Net::HTTP.start(
63
- latest_version_uri.host,
64
- latest_version_uri.port,
65
- use_ssl: latest_version_uri.scheme == "https"
66
- ) do |http|
67
- # Fetch version manifest
68
- req = ::Net::HTTP::Get.new latest_version_uri
58
+ def inspect
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
+ end
69
61
 
70
- res = http.request req
71
- res.value
62
+ class << self
63
+ CDN_URI = URI("https://cdnnuva.mesvaccins.net/")
72
64
 
73
- manifest = JSON.parse(res.body)
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:)
74
69
 
75
- dump_hash = manifest["dump_hash"]
70
+ response = http.get("/proto/#{hash}_en.db")
71
+ ::Nuva::Nuva.new(::Nuva::NuvaDatabase.decode(response.body))
72
+ end
73
+ end
76
74
 
77
- # Fetch latest database
78
- dump_uri = latest_version_uri.dup
79
- dump_uri.path = "/proto/#{dump_hash}_#{lang}.db"
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
80
85
 
81
- req = ::Net::HTTP::Get.new dump_uri
86
+ def load_from_file(path)
87
+ Nuva.new(NuvaDatabase.decode(File.read(path)))
88
+ end
82
89
 
83
- res = http.request req
84
- res.value
90
+ private
85
91
 
86
- # The return value of the block is returned by the start method
87
- ::Nuva::Nuva.new(::Nuva::NuvaDatabase.decode(res.body))
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
+ )
88
99
  end
89
100
  end
90
-
91
- def self.load_from_file(path)
92
- Nuva.new(NuvaDatabase.decode(File.read(path)))
93
- end
94
101
  end
95
102
  end
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.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syadem
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-17 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf