kovid 0.3.4 → 0.3.6

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: 7111caf7871b70f2fc2e35c29013e1d3d24b5c130950a82c90786693af22a4c9
4
- data.tar.gz: 24f9e8bee7b3040a4c181169aa77b8956015db94139d435e95be3339f94facc8
3
+ metadata.gz: 46e28cf1cf2a687ba9844a2a167d64921b7751028b15953db0fa4af9bbfb6942
4
+ data.tar.gz: 373975e720f8c411d3c9232d7c7f8f1c124328c3afc3eb91af5561a7e710f3bb
5
5
  SHA512:
6
- metadata.gz: e27a7c550b05e358f7b2250d98d8a9e129aee40acac585a1e31fe41f7a910e1fc1d590b241ed7febe00162dd67a12d27969e810bc3bd7e0b2ab032914174a4a5
7
- data.tar.gz: 1714bf0e2ab7cd4c928d0700fa146cee5011c4a1858c0b8999f0af206060fb2b73dcb9cb9685d22d7a4389ba10bd574f5dedbb5de7aa34769ad0e160408d4b14
6
+ metadata.gz: 8a9d7ef9d7ce72a11cbef9ed79b741d9018a4be5de76fc471eb3355a70fb2df1e55f80f36cd3363f2b56820b2f4f5e66784c56894d377fb47cbb730c01a04fbb
7
+ data.tar.gz: be354f88e26a00de9924b9c3e719d6ef227d4b5679341c4bc747c2e8134dd85688d0cc767b796a45c5018e7e9d3434dbc1a8d170d3e78e1ae1b871e263151f33
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.3.2)
4
+ kovid (0.3.4)
5
5
  rainbow (~> 3.0)
6
6
  terminal-table (~> 1.8)
7
7
  thor (~> 1.0)
@@ -52,6 +52,10 @@ Gem::Specification.new do |spec|
52
52
 
53
53
  Stay safe!
54
54
  Emmanuel Hayford.
55
+
56
+ Data sources:
57
+ https://www.worldometers.info/coronavirus/
58
+ JHU CSSE GISand Data
55
59
  ============================================================================
56
60
  }
57
61
  end
@@ -3,33 +3,34 @@
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
9
6
  module Kovid
10
7
  class CLI < Thor
11
8
  FULL_FLAG = %w[-f --full].freeze
12
9
 
13
- desc 'check EU', 'Returns aggregated data on the EU.'
10
+ desc 'eu', 'Returns aggregated data on the EU.'
14
11
  def eu
15
12
  puts Kovid.eu_aggregate
13
+ data_source
16
14
  end
17
15
 
18
16
  desc 'check COUNTRY or check "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid check "hong kong".'
19
17
  method_option :full, aliases: '-f'
20
18
  def check(name)
21
19
  fetch_country_stats(name)
20
+ data_source
22
21
  end
23
22
 
24
23
  desc 'country COUNTRY or country "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid country "hong kong".'
25
24
  method_option :full, aliases: '-f'
26
25
  def country(name)
27
26
  fetch_country_stats(name)
27
+ data_source
28
28
  end
29
29
 
30
30
  desc 'state STATE', 'Return reported data on provided state.'
31
31
  def state(state)
32
32
  puts Kovid.state(state)
33
+ data_source
33
34
  end
34
35
 
35
36
  desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries.'
@@ -39,11 +40,13 @@ module Kovid
39
40
  else
40
41
  puts Kovid.country_comparison(name)
41
42
  end
43
+ data_source
42
44
  end
43
45
 
44
46
  desc 'cases', 'Returns total number of cases, deaths and recoveries.'
45
47
  def cases
46
48
  puts Kovid.cases
49
+ data_source
47
50
  end
48
51
 
49
52
  desc 'history COUNTRY or history COUNTRY N', 'Return history of incidents of COUNTRY (in the last N days)'
@@ -53,6 +56,7 @@ module Kovid
53
56
  else
54
57
  puts Kovid.history(params.first, nil)
55
58
  end
59
+ data_source
56
60
  end
57
61
 
58
62
  private
@@ -64,5 +68,15 @@ module Kovid
64
68
  puts Kovid.country(country)
65
69
  end
66
70
  end
71
+
72
+ def data_source
73
+ source = <<~TEXT
74
+ Sources:
75
+ https://www.worldometers.info/coronavirus/
76
+ JHU CSSE GISand Data
77
+ TEXT
78
+ puts source
79
+ puts
80
+ end
67
81
  end
68
82
  end
@@ -67,7 +67,7 @@ module Kovid
67
67
  end
68
68
 
69
69
  def history(country, last)
70
- history_path = UriBuilder.new('/historical').url
70
+ history_path = UriBuilder.new('/v2/historical').url
71
71
  response ||= JSON.parse(Typhoeus.get(history_path + "/#{country}", cache_ttl: 900).response_body)
72
72
 
73
73
  Kovid::Tablelize.history(response, last)
@@ -13,14 +13,13 @@ module Kovid
13
13
  'Recovered'.paint_green
14
14
  ].freeze
15
15
 
16
- DATE_CASES_DEATHS_RECOVERED = [
16
+ DATE_CASES_DEATHS = [
17
17
  'Date'.paint_white,
18
18
  'Cases'.paint_white,
19
- 'Deaths'.paint_red,
20
- 'Recovered'.paint_green
19
+ 'Deaths'.paint_red
21
20
  ].freeze
22
21
 
23
- FOOTER_LINE = ['------------', '------------', '------------', '------------'].freeze
22
+ FOOTER_LINE = ['------------', '------------', '------------'].freeze
24
23
  COUNTRY_LETTERS = 'A'.upto('Z').with_index(127_462).to_h.freeze
25
24
 
26
25
  def country_table(data)
@@ -146,7 +145,7 @@ module Kovid
146
145
  end
147
146
 
148
147
  def history(country, last)
149
- headings = DATE_CASES_DEATHS_RECOVERED
148
+ headings = DATE_CASES_DEATHS
150
149
  rows = []
151
150
 
152
151
  stats = if last
@@ -173,10 +172,10 @@ module Kovid
173
172
 
174
173
  if stats.size > 10
175
174
  rows << FOOTER_LINE
176
- rows << DATE_CASES_DEATHS_RECOVERED
175
+ rows << DATE_CASES_DEATHS
177
176
  end
178
177
 
179
- Terminal::Table.new(title: country['standardizedCountryName'].upcase, headings: headings, rows: rows)
178
+ Terminal::Table.new(title: country['country'].upcase, headings: headings, rows: rows)
180
179
  end
181
180
 
182
181
  def eu_aggregate(eu_data)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.3.4'
4
+ VERSION = '0.3.6'
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.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford
@@ -167,7 +167,9 @@ post_install_message: "\n ===================================================
167
167
  isn't much we can do now aside:\n\n * Washing our hands with soap frequently.\n
168
168
  \ * Limiting our movements, how much we touch our faces & social distancing.\n
169
169
  \ * Disinfecting our phones, keys, doorknobs, keyboards, etc.\n * Being
170
- there for each other.\n\n Stay safe!\n Emmanuel Hayford.\n ============================================================================\n
170
+ there for each other.\n\n Stay safe!\n Emmanuel Hayford.\n\n Data
171
+ sources:\n https://www.worldometers.info/coronavirus/\n JHU CSSE GISand
172
+ Data\n ============================================================================\n
171
173
  \ "
172
174
  rdoc_options: []
173
175
  require_paths: