nuva 0.3.1 → 0.4.0

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: afbabc0a255bd36f3b3b9d4a9df5b0ea139651c620a4884f6366f7d4d70cd221
4
+ data.tar.gz: 8a58a082d0d3a11815cbfb47aa985c2114d42e5e0c0e198eb8642bbb57224a64
5
5
  SHA512:
6
- metadata.gz: c5852e5006e7de76aed2a716c8559398eba7eaf67df19ae4bc17b449675b89fee3f4ce0201c3861a80f1de36a3d6fc4d77db237ab6754e7c0ee1a7520cb8c600
7
- data.tar.gz: 1a67a955a8dc79d3219cefdbb7432ce4ad1312356a77e8a13a437a35228739e099bbc11b8dd2462ee6ae157b0349cab88f80e4b1f6e11eaa719ae42d0703e556
6
+ metadata.gz: 5dfadcffe9da8ffded45109e4fb803f35ec416279660480550981541ac63e87044382d36464a71a32663ac977b295afe35b1a86a728570012eac28052b80015c
7
+ data.tar.gz: 934776897a3fd617bdfbd9012b3ae0e539eb918d7ab85ac2453157b06478dda9ea919f779f386e2501affa473e46df32ed4000a1431bb427119bca966eb8cfb6
@@ -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/Changelog.md CHANGED
@@ -5,6 +5,13 @@ 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.0] - 2025-01-21
9
+
10
+ ### Added
11
+
12
+ - Add method `Nuva.fetch_latest_version_hash`
13
+ - Support fetching specific nuva version with `Nuva.load`
14
+
8
15
  ## [0.3.1] - 2025-01-17
9
16
 
10
17
  ### 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.0"
5
5
  end
data/lib/nuva.rb CHANGED
@@ -55,39 +55,34 @@ 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"
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
61
+
62
+ LATEST_VERSION_URI =
63
+ URI("https://cdnnuva.mesvaccins.net/versions/last.json")
61
64
 
65
+ def self.load(lang: "en", hash: nil)
62
66
  ::Net::HTTP.start(
63
- latest_version_uri.host,
64
- latest_version_uri.port,
65
- use_ssl: latest_version_uri.scheme == "https"
67
+ LATEST_VERSION_URI.host,
68
+ LATEST_VERSION_URI.port,
69
+ use_ssl: LATEST_VERSION_URI.scheme == "https"
66
70
  ) do |http|
67
- # Fetch version manifest
68
- req = ::Net::HTTP::Get.new latest_version_uri
69
-
70
- res = http.request req
71
- res.value
72
-
73
- manifest = JSON.parse(res.body)
74
-
75
- dump_hash = manifest["dump_hash"]
71
+ # Fetch version manifest if necessary
72
+ hash ||= fetch_latest_version_hash(http:)
76
73
 
77
- # Fetch latest database
78
- dump_uri = latest_version_uri.dup
79
- dump_uri.path = "/proto/#{dump_hash}_#{lang}.db"
80
-
81
- req = ::Net::HTTP::Get.new dump_uri
82
-
83
- res = http.request req
84
- res.value
85
-
86
- # The return value of the block is returned by the start method
87
- ::Nuva::Nuva.new(::Nuva::NuvaDatabase.decode(res.body))
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))
88
78
  end
89
79
  end
90
80
 
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
85
+
91
86
  def self.load_from_file(path)
92
87
  Nuva.new(NuvaDatabase.decode(File.read(path)))
93
88
  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.0
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