kovid 0.3.2 β†’ 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4205df6f2e487214f535dda994a132264a9966b6c7527dec22f908f7aad76ed
4
- data.tar.gz: 24b98f27cddcff29ed2a75d02be4af8d81fb2078d138890d75c9fb3541207bdf
3
+ metadata.gz: 9f04b3f270cae0450368cdffa483d4968dfe6e260a19f4ff244dda25765fba32
4
+ data.tar.gz: f9381a8141630f18888ec65ced2c352eee1ddd7cd79c131e839fc77e1d4c9255
5
5
  SHA512:
6
- metadata.gz: 2c5e2f6b14c57dc707d81f5711ea6d2004300d253f8ba7afb0d453d14bd2f73210de62d73d2457caf7ed221ad8d27b192db2e511e749903bb25cd31bbfe3be02
7
- data.tar.gz: 7fc35f3888744cbadcfe131e080ef56a3d9b0055f8437316f5286f364ab71391a6322df951c86c707ab43d3669b839aaed58fa3108913c36d6d252ce3759dca5
6
+ metadata.gz: b09ebeaa677af45d87d3c37f347caaa9668d95e4c4d67c4462c68143b0dbe1c820faf1e50607acf0460d9acc88abc59958aa8390b1f88396c2ed127dac830fb9
7
+ data.tar.gz: 7c8a93f91fa8cc64e55cbb2ea055f2d5edc902dd7a5b1d984e0f5a76e967eaa3c239f63fc7f25d13cce4e22cb4e9e288c53ba8752a5bb5ebf41d39f5cdaca5fe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.3.1)
4
+ kovid (0.3.2)
5
5
  rainbow (~> 3.0)
6
6
  terminal-table (~> 1.8)
7
7
  thor (~> 1.0)
data/README.md CHANGED
@@ -24,6 +24,11 @@ You can run `kovid --help` to see the full list of available commands.
24
24
  * `kovid check COUNTRY` OR `kovid country COUNTRY`.
25
25
  * `kovid check COUNTRY -f` OR `kovid check COUNTRY --full`.
26
26
 
27
+ πŸ‡ͺπŸ‡ΊπŸ‡ͺπŸ‡ΊπŸ‡ͺπŸ‡Ί
28
+
29
+ You can fetch aggregated EU (all 27 countries combined) data:
30
+ * `kovid eu`.
31
+
27
32
  πŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡Έ
28
33
 
29
34
  You can fetch US state-specific data:
@@ -77,6 +82,12 @@ To fetch state-specific data run:
77
82
 
78
83
  ![kovid](https://i.gyazo.com/d00b1c5bbb6251cbd517f801c856ba66.png "Covid data.")
79
84
 
85
+ To fetch EU data run:
86
+
87
+ `kovid eu`
88
+
89
+ ![kovid](https://i.gyazo.com/51d2adcb8e9feb0a0fbe38ff9cf4c550.png "Covid data.")
90
+
80
91
  You can check historical statistics by running
81
92
 
82
93
  `kovid history italy 7` eg:
data/lib/kovid.rb CHANGED
@@ -8,8 +8,8 @@ module Kovid
8
8
 
9
9
  module_function
10
10
 
11
- def whatis
12
- 'Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).'
11
+ def eu_aggregate
12
+ Kovid::Request.eu_aggregate
13
13
  end
14
14
 
15
15
  def country(name)
data/lib/kovid/cli.rb CHANGED
@@ -3,13 +3,16 @@
3
3
  require 'thor'
4
4
  require 'kovid'
5
5
 
6
+ # ["AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "GR", "HR", "HU", "IE", "IT", "LT", "LU", "LV", "MT", "NL", "PL", "PT", "RO", "SE", "SI", "SK"]
7
+
8
+ # Czechia has no code
6
9
  module Kovid
7
10
  class CLI < Thor
8
11
  FULL_FLAG = %w[-f --full].freeze
9
12
 
10
- desc 'define', 'Defines COVID-19'
11
- def define
12
- puts Kovid.whatis
13
+ desc 'check EU', 'Returns aggregated data on the EU.'
14
+ def eu
15
+ puts Kovid.eu_aggregate
13
16
  end
14
17
 
15
18
  desc 'check COUNTRY or check "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid check "hong kong".'
data/lib/kovid/request.rb CHANGED
@@ -9,8 +9,25 @@ module Kovid
9
9
  class Request
10
10
  COUNTRIES_PATH = UriBuilder.new('/countries').url
11
11
  STATES_URL = UriBuilder.new('/states').url
12
+ EU_ISOS = %w[AT BE BG CY CZ DE DK EE ES FI FR GR HR HU IE IT LT LU LV MT NL PL PT RO SE SI SK].freeze
12
13
 
13
14
  class << self
15
+ def eu_aggregate
16
+ countries_array = JSON.parse(Typhoeus.get(UriBuilder.new('/countries').url, cache_ttl: 900).response_body)
17
+
18
+ eu_array = countries_array.select do |hash|
19
+ EU_ISOS.include?(hash['countryInfo']['iso2']) || hash['country'] == 'Czechia'
20
+ # Check API later to see if ISO-Alpha-2 code has been added for Czechia
21
+ end
22
+
23
+ first, *rest = eu_array
24
+ eu_data = first.merge(*rest) do |key, left, right|
25
+ left + right unless %w[country countryInfo].include?(key)
26
+ end .compact
27
+
28
+ Kovid::Tablelize.eu_aggregate(eu_data)
29
+ end
30
+
14
31
  def by_country(country_name)
15
32
  response = fetch_country(country_name)
16
33
 
@@ -179,6 +179,16 @@ module Kovid
179
179
  Terminal::Table.new(title: country['standardizedCountryName'].upcase, headings: headings, rows: rows)
180
180
  end
181
181
 
182
+ def eu_aggregate(eu_data)
183
+ headings = ['Cases'.paint_white, 'Cases Today'.paint_white, 'Deaths'.paint_red, 'Deaths Today'.paint_red, 'Recovered'.paint_green, 'Active'.paint_yellow, 'Critical'.paint_green]
184
+
185
+ rows = []
186
+
187
+ rows << [comma_delimit(eu_data['cases']), check_if_positve(eu_data['todayCases']), comma_delimit(eu_data['deaths']), check_if_positve(eu_data['todayDeaths']), comma_delimit(eu_data['recovered']), comma_delimit(eu_data['active']), comma_delimit(eu_data['critical'])]
188
+
189
+ Terminal::Table.new(title: 'EU Aggragation'.upcase, headings: headings, rows: rows)
190
+ end
191
+
182
192
  private
183
193
 
184
194
  def comma_delimit(number)
data/lib/kovid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kovid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford