kovid 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/kovid.gemspec +4 -0
- data/lib/kovid/cli.rb +18 -4
- data/lib/kovid/request.rb +1 -1
- data/lib/kovid/tablelize.rb +6 -7
- data/lib/kovid/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46e28cf1cf2a687ba9844a2a167d64921b7751028b15953db0fa4af9bbfb6942
|
4
|
+
data.tar.gz: 373975e720f8c411d3c9232d7c7f8f1c124328c3afc3eb91af5561a7e710f3bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9d7ef9d7ce72a11cbef9ed79b741d9018a4be5de76fc471eb3355a70fb2df1e55f80f36cd3363f2b56820b2f4f5e66784c56894d377fb47cbb730c01a04fbb
|
7
|
+
data.tar.gz: be354f88e26a00de9924b9c3e719d6ef227d4b5679341c4bc747c2e8134dd85688d0cc767b796a45c5018e7e9d3434dbc1a8d170d3e78e1ae1b871e263151f33
|
data/Gemfile.lock
CHANGED
data/kovid.gemspec
CHANGED
data/lib/kovid/cli.rb
CHANGED
@@ -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 '
|
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
|
data/lib/kovid/request.rb
CHANGED
@@ -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)
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -13,14 +13,13 @@ module Kovid
|
|
13
13
|
'Recovered'.paint_green
|
14
14
|
].freeze
|
15
15
|
|
16
|
-
|
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 = ['------------', '------------', '------------'
|
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 =
|
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 <<
|
175
|
+
rows << DATE_CASES_DEATHS
|
177
176
|
end
|
178
177
|
|
179
|
-
Terminal::Table.new(title: country['
|
178
|
+
Terminal::Table.new(title: country['country'].upcase, headings: headings, rows: rows)
|
180
179
|
end
|
181
180
|
|
182
181
|
def eu_aggregate(eu_data)
|
data/lib/kovid/version.rb
CHANGED
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
|
+
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
|
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:
|