kovid 0.3.16 โ 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -1
- data/README.md +18 -3
- data/kovid.gemspec +2 -0
- data/lib/kovid.rb +8 -2
- data/lib/kovid/cli.rb +17 -2
- data/lib/kovid/helpers.rb +11 -0
- data/lib/kovid/request.rb +26 -18
- data/lib/kovid/tablelize.rb +120 -59
- data/lib/kovid/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2bcf9cae235b902baf6388bd509cf8bb7b9445b2bac741713c6f1d60ca830fc
|
4
|
+
data.tar.gz: 91d40e2882577373c5336057dd3a235364b924e276550662bd806075f90e90cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be7fe0fe2d21b477994aa531636b0dde19b350ca3a53e3c985cbe13d9dee5285c32e580bc893877c05599290471aeb7835b5d8a520f1fd8f3ceb0cfae5f3eed6
|
7
|
+
data.tar.gz: 45d45c55e305c76a2393580965cecb39e5227e1d2a8bba8a1ac335524f5535eddd099e13096d2d58e204ee84b40933b27bc5c6fdcbd316154940349bfca5e335
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kovid (0.3
|
4
|
+
kovid (0.4.3)
|
5
|
+
ascii_charts (~> 0.9.1)
|
5
6
|
rainbow (~> 3.0)
|
6
7
|
terminal-table (~> 1.8)
|
7
8
|
thor (~> 1.0)
|
@@ -10,6 +11,7 @@ PATH
|
|
10
11
|
GEM
|
11
12
|
remote: https://rubygems.org/
|
12
13
|
specs:
|
14
|
+
ascii_charts (0.9.1)
|
13
15
|
diff-lcs (1.3)
|
14
16
|
docile (1.3.2)
|
15
17
|
ethon (0.12.0)
|
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/kovid.svg)](https://badge.fury.io/rb/kovid)
|
2
|
+
[![Open Source Helpers](https://www.codetriage.com/siaw23/kovid/badges/users.svg)](https://www.codetriage.com/siaw23/kovid)
|
3
|
+
|
4
|
+
|
1
5
|
# ๐ฆ Kovid
|
2
6
|
|
3
7
|
Kovid is a small CLI app to fetch data surrounding the coronavirus pandemic of 2019. I found myself checking [Wikipedia](https://en.wikipedia.org/wiki/2019%E2%80%9320_coronavirus_pandemic) constantly for information so I thought I'd build this to provide info directly in the terminal. It's where some of us spend time more.
|
@@ -58,10 +62,14 @@ ___
|
|
58
62
|
* `kovid history COUNTRY N` (history in the last N days).
|
59
63
|
___
|
60
64
|
๐ท **Total figures**
|
61
|
-
* `kovid
|
65
|
+
* `kovid world` (summary of reported incidents globally).
|
62
66
|
|
63
67
|
**NOTE:** If you find it irritating to have to type `kovid state STATE`, `covid state STATE` works as well.
|
64
68
|
|
69
|
+
#### Histogram (Experimental) ๐งช
|
70
|
+
|
71
|
+
`kovid histogram COUNTRY M.YY` (draws a histogram of cases in the given month `M` and years `YY`)
|
72
|
+
|
65
73
|
#### Commands Details
|
66
74
|
To fetch basic data on a country run:
|
67
75
|
|
@@ -107,11 +115,18 @@ You can check historical statistics by running
|
|
107
115
|
|
108
116
|
To check for total figures:
|
109
117
|
|
110
|
-
`kovid
|
118
|
+
`kovid world`
|
111
119
|
|
112
120
|
![kovid](https://i.gyazo.com/e01f4769a2b9e31ce50cec212e55810c.png "Covid data.")
|
113
121
|
|
114
|
-
##
|
122
|
+
## ๐ฉ๐พโ๐ฌ Experimental Feature
|
123
|
+
|
124
|
+
`kovid histogram italy 3.20` tries to build a histogram on number of cases. In the example here `3.20` is date in the format of `M.YY`. If you can please play with it and report issues on how this could be improved.
|
125
|
+
|
126
|
+
![kovid](https://i.gyazo.com/35833cba37be8ca10830fad066b85bb3.png "Covid data.")
|
127
|
+
|
128
|
+
|
129
|
+
## Data Source
|
115
130
|
> [JHU CSSE GISand Data](https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6) and https://www.worldometers.info/coronavirus/ via [NovelCOVID/API](https://github.com/novelcovid/api)
|
116
131
|
|
117
132
|
|
data/kovid.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "terminal-table", "~> 1.8"
|
23
23
|
spec.add_dependency "typhoeus", "~> 1.3"
|
24
24
|
spec.add_dependency "rainbow", "~> 3.0"
|
25
|
+
spec.add_dependency "ascii_charts", "~> 0.9.1"
|
26
|
+
|
25
27
|
|
26
28
|
spec.add_development_dependency "simplecov", "~> 0.18"
|
27
29
|
|
data/lib/kovid.rb
CHANGED
@@ -4,6 +4,8 @@ require 'kovid/version'
|
|
4
4
|
require 'kovid/request'
|
5
5
|
|
6
6
|
module Kovid
|
7
|
+
require 'kovid/helpers'
|
8
|
+
|
7
9
|
class Error < StandardError; end
|
8
10
|
|
9
11
|
module_function
|
@@ -24,8 +26,8 @@ module Kovid
|
|
24
26
|
Kovid::Request.state(state)
|
25
27
|
end
|
26
28
|
|
27
|
-
def states(*
|
28
|
-
Kovid::Request.states(
|
29
|
+
def states(*states)
|
30
|
+
Kovid::Request.states(states)
|
29
31
|
end
|
30
32
|
|
31
33
|
def country_comparison(names_array)
|
@@ -43,4 +45,8 @@ module Kovid
|
|
43
45
|
def history(country, last)
|
44
46
|
Kovid::Request.history(country, last)
|
45
47
|
end
|
48
|
+
|
49
|
+
def histogram(country, date)
|
50
|
+
Kovid::Request.histogram(country, date)
|
51
|
+
end
|
46
52
|
end
|
data/lib/kovid/cli.rb
CHANGED
@@ -37,8 +37,8 @@ module Kovid
|
|
37
37
|
data_source
|
38
38
|
end
|
39
39
|
|
40
|
-
desc '
|
41
|
-
def
|
40
|
+
desc 'world', 'Returns total number of cases, deaths and recoveries.'
|
41
|
+
def world
|
42
42
|
puts Kovid.cases
|
43
43
|
data_source
|
44
44
|
end
|
@@ -59,6 +59,21 @@ module Kovid
|
|
59
59
|
data_source
|
60
60
|
end
|
61
61
|
|
62
|
+
desc 'version', 'Returns version of kovid'
|
63
|
+
def version
|
64
|
+
puts Kovid::VERSION
|
65
|
+
end
|
66
|
+
|
67
|
+
desc 'histogram', 'Returns a histogram of incidents.'
|
68
|
+
def histogram(country, date = nil)
|
69
|
+
if date.nil?
|
70
|
+
Kovid.info_table("Please add a month and year in the form 'M.YY'")
|
71
|
+
else
|
72
|
+
puts Kovid.histogram(country, date)
|
73
|
+
data_source
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
62
77
|
private
|
63
78
|
|
64
79
|
def fetch_country_stats(country)
|
data/lib/kovid/request.rb
CHANGED
@@ -10,17 +10,18 @@ module Kovid
|
|
10
10
|
COUNTRIES_PATH = UriBuilder.new('/countries').url
|
11
11
|
STATES_URL = UriBuilder.new('/states').url
|
12
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
|
13
|
+
SERVER_DOWN = 'Server overwhelmed. Please try again in a moment.'
|
13
14
|
|
14
15
|
class << self
|
15
16
|
def eu_aggregate
|
16
17
|
countries_array = JSON.parse(Typhoeus.get(UriBuilder.new('/countries').url, cache_ttl: 900).response_body)
|
17
18
|
|
18
|
-
|
19
|
+
eu_array = countries_array.select do |hash|
|
19
20
|
EU_ISOS.include?(hash['countryInfo']['iso2'])
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
-
eu_data =
|
23
|
+
head, *tail = eu_array
|
24
|
+
eu_data = head.merge(*tail) do |key, left, right|
|
24
25
|
left ||= 0
|
25
26
|
right ||= 0
|
26
27
|
|
@@ -29,7 +30,7 @@ module Kovid
|
|
29
30
|
|
30
31
|
Kovid::Tablelize.eu_aggregate(eu_data)
|
31
32
|
rescue JSON::ParserError
|
32
|
-
puts
|
33
|
+
puts SERVER_DOWN
|
33
34
|
end
|
34
35
|
|
35
36
|
def by_country(country_name)
|
@@ -41,7 +42,7 @@ module Kovid
|
|
41
42
|
Kovid::Tablelize.country_table(response)
|
42
43
|
end
|
43
44
|
rescue JSON::ParserError
|
44
|
-
puts
|
45
|
+
puts SERVER_DOWN
|
45
46
|
end
|
46
47
|
|
47
48
|
def by_country_full(country_name)
|
@@ -53,7 +54,7 @@ module Kovid
|
|
53
54
|
Kovid::Tablelize.full_country_table(response)
|
54
55
|
end
|
55
56
|
rescue JSON::ParserError
|
56
|
-
puts
|
57
|
+
puts SERVER_DOWN
|
57
58
|
end
|
58
59
|
|
59
60
|
def state(state)
|
@@ -61,7 +62,7 @@ module Kovid
|
|
61
62
|
|
62
63
|
Kovid::Tablelize.full_state_table(response)
|
63
64
|
rescue JSON::ParserError
|
64
|
-
puts
|
65
|
+
puts SERVER_DOWN
|
65
66
|
end
|
66
67
|
|
67
68
|
def states(list)
|
@@ -69,38 +70,49 @@ module Kovid
|
|
69
70
|
|
70
71
|
Kovid::Tablelize.compare_us_states(array)
|
71
72
|
rescue JSON::ParserError
|
72
|
-
puts
|
73
|
+
puts SERVER_DOWN
|
73
74
|
end
|
74
75
|
|
75
76
|
def by_country_comparison(list)
|
76
77
|
array = fetch_countries(list)
|
77
78
|
Kovid::Tablelize.compare_countries_table(array)
|
78
79
|
rescue JSON::ParserError
|
79
|
-
puts
|
80
|
+
puts SERVER_DOWN
|
80
81
|
end
|
81
82
|
|
82
83
|
def by_country_comparison_full(list)
|
83
84
|
array = fetch_countries(list)
|
84
85
|
Kovid::Tablelize.compare_countries_table_full(array)
|
85
86
|
rescue JSON::ParserError
|
86
|
-
puts
|
87
|
+
puts SERVER_DOWN
|
87
88
|
end
|
88
89
|
|
89
90
|
def cases
|
90
|
-
response
|
91
|
+
response = JSON.parse(Typhoeus.get(UriBuilder.new('/all').url, cache_ttl: 900).response_body)
|
91
92
|
|
92
93
|
Kovid::Tablelize.cases(response)
|
93
94
|
rescue JSON::ParserError
|
94
|
-
puts
|
95
|
+
puts SERVER_DOWN
|
95
96
|
end
|
96
97
|
|
97
98
|
def history(country, last)
|
98
99
|
history_path = UriBuilder.new('/v2/historical').url
|
99
|
-
response
|
100
|
+
response = JSON.parse(Typhoeus.get(history_path + "/#{country}", cache_ttl: 900).response_body)
|
100
101
|
|
101
102
|
Kovid::Tablelize.history(response, last)
|
102
103
|
rescue JSON::ParserError
|
103
|
-
puts
|
104
|
+
puts SERVER_DOWN
|
105
|
+
end
|
106
|
+
|
107
|
+
def histogram(country, date)
|
108
|
+
history_path = UriBuilder.new('/v2/historical').url
|
109
|
+
response = JSON.parse(Typhoeus.get(history_path + "/#{country}", cache_ttl: 900).response_body)
|
110
|
+
|
111
|
+
Kovid::Tablelize.histogram(response, date)
|
112
|
+
end
|
113
|
+
|
114
|
+
def capitalize_words(string)
|
115
|
+
string.split.map(&:capitalize).join(' ')
|
104
116
|
end
|
105
117
|
|
106
118
|
private
|
@@ -139,10 +151,6 @@ module Kovid
|
|
139
151
|
|
140
152
|
states_array.select { |state_name| state_name['state'] == capitalize_words(state) }.first
|
141
153
|
end
|
142
|
-
|
143
|
-
def capitalize_words(string)
|
144
|
-
string.split.map(&:capitalize).join(' ')
|
145
|
-
end
|
146
154
|
end
|
147
155
|
end
|
148
156
|
end
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -3,11 +3,18 @@
|
|
3
3
|
require 'terminal-table'
|
4
4
|
require 'date'
|
5
5
|
require_relative 'painter'
|
6
|
+
require 'ascii_charts'
|
6
7
|
|
7
8
|
module Kovid
|
8
9
|
class Tablelize
|
9
10
|
class << self
|
10
11
|
CASES_DEATHS_RECOVERED = [
|
12
|
+
'Cases'.paint_white,
|
13
|
+
'Deaths'.paint_red,
|
14
|
+
'Recovered'.paint_green
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
CASES_DEATHS_RECOVERED_CTODAY_DTODAY = [
|
11
18
|
'Cases'.paint_white,
|
12
19
|
'Deaths'.paint_red,
|
13
20
|
'Recovered'.paint_green,
|
@@ -31,30 +38,46 @@ module Kovid
|
|
31
38
|
'Critical'.paint_red
|
32
39
|
].freeze
|
33
40
|
|
41
|
+
COMPARE_COUNTRY_TABLE_FULL = [
|
42
|
+
'Country'.paint_white,
|
43
|
+
'Cases'.paint_white,
|
44
|
+
'Deaths'.paint_red,
|
45
|
+
'Recovered'.paint_green,
|
46
|
+
'Cases Today'.paint_white,
|
47
|
+
'Deaths Today'.paint_red,
|
48
|
+
'Critical'.paint_yellow,
|
49
|
+
'Cases/Million'.paint_white
|
50
|
+
].freeze
|
51
|
+
|
52
|
+
COMPARE_COUNTRIES_TABLE_HEADINGS = [
|
53
|
+
'Country'.paint_white,
|
54
|
+
'Cases'.paint_white,
|
55
|
+
'Cases Today'.paint_white,
|
56
|
+
'Deaths'.paint_red,
|
57
|
+
'Deaths Today'.paint_red,
|
58
|
+
'Recovered'.paint_green
|
59
|
+
].freeze
|
60
|
+
|
34
61
|
FOOTER_LINE = ['------------', '------------', '------------'].freeze
|
35
62
|
COUNTRY_LETTERS = 'A'.upto('Z').with_index(127_462).to_h.freeze
|
36
63
|
|
37
64
|
def country_table(data)
|
38
|
-
headings =
|
65
|
+
headings = CASES_DEATHS_RECOVERED_CTODAY_DTODAY
|
39
66
|
rows = [
|
40
67
|
[
|
41
|
-
data['cases'],
|
42
|
-
data['deaths'],
|
43
|
-
data['recovered'],
|
68
|
+
comma_delimit(data['cases']),
|
69
|
+
comma_delimit(data['deaths']),
|
70
|
+
comma_delimit(data['recovered']),
|
44
71
|
check_if_positve(data['todayCases']),
|
45
72
|
check_if_positve(data['todayDeaths'])
|
46
73
|
]
|
47
74
|
]
|
48
75
|
|
49
|
-
# binding.irb
|
50
|
-
|
51
76
|
if iso = data['countryInfo']['iso2']
|
52
|
-
Terminal::Table.new(title: data['country'].upcase
|
77
|
+
Terminal::Table.new(title: "#{country_emoji(iso)} #{data['country'].upcase}", headings: headings, rows: rows)
|
53
78
|
else
|
54
79
|
Terminal::Table.new(title: data['country'].upcase, headings: headings, rows: rows)
|
55
80
|
end
|
56
|
-
# TODO: Rafactor this
|
57
|
-
# TODO: Fix emoji
|
58
81
|
end
|
59
82
|
|
60
83
|
def full_country_table(data)
|
@@ -79,15 +102,15 @@ module Kovid
|
|
79
102
|
comma_delimit(data['casesPerOneMillion'])
|
80
103
|
]
|
81
104
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
105
|
+
if iso = data['countryInfo']['iso2']
|
106
|
+
Terminal::Table.new(title: "#{country_emoji(iso)} #{data['country'].upcase}",
|
107
|
+
headings: headings,
|
108
|
+
rows: rows)
|
109
|
+
else
|
110
|
+
Terminal::Table.new(title: data['country'].upcase,
|
111
|
+
headings: headings,
|
112
|
+
rows: rows)
|
113
|
+
end
|
91
114
|
# TODO: Rafactor this
|
92
115
|
end
|
93
116
|
|
@@ -107,59 +130,43 @@ module Kovid
|
|
107
130
|
end
|
108
131
|
|
109
132
|
def compare_countries_table(data)
|
110
|
-
headings = [
|
111
|
-
'Country'.paint_white,
|
112
|
-
'Cases'.paint_white,
|
113
|
-
'Deaths'.paint_red,
|
114
|
-
'Recovered'.paint_green,
|
115
|
-
'Cases Today'.paint_white,
|
116
|
-
'Deaths Today'.paint_red
|
117
|
-
]
|
118
|
-
|
119
133
|
rows = []
|
120
134
|
|
121
135
|
data.each do |country|
|
122
|
-
|
123
|
-
country['country'].upcase,
|
136
|
+
base_rows = [
|
124
137
|
comma_delimit(country['cases']),
|
125
|
-
comma_delimit(country['deaths']),
|
126
|
-
comma_delimit(country['recovered']),
|
127
138
|
check_if_positve(country['todayCases']),
|
128
|
-
|
139
|
+
comma_delimit(country['deaths']),
|
140
|
+
check_if_positve(country['todayDeaths']),
|
141
|
+
comma_delimit(country['recovered'])
|
129
142
|
]
|
143
|
+
|
144
|
+
rows << if iso = country['countryInfo']['iso2']
|
145
|
+
base_rows.unshift("#{country_emoji(iso)} #{country['country'].upcase}")
|
146
|
+
else
|
147
|
+
base_rows.unshift(country['country'].upcase.to_s)
|
148
|
+
end
|
130
149
|
end
|
131
150
|
|
132
|
-
Terminal::Table.new(headings:
|
151
|
+
Terminal::Table.new(headings: COMPARE_COUNTRIES_TABLE_HEADINGS, rows: rows)
|
133
152
|
end
|
134
153
|
|
135
154
|
def compare_countries_table_full(data)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
rows = []
|
155
|
+
rows = data.map do |country|
|
156
|
+
[
|
157
|
+
country.fetch('country'),
|
158
|
+
comma_delimit(country.fetch('cases')),
|
159
|
+
comma_delimit(country.fetch('deaths')),
|
160
|
+
comma_delimit(country.fetch('recovered')),
|
161
|
+
check_if_positve(country.fetch('todayCases')),
|
162
|
+
check_if_positve(country.fetch('todayDeaths')),
|
163
|
+
comma_delimit(country.fetch('critical')),
|
164
|
+
comma_delimit(country.fetch('casesPerOneMillion'))
|
148
165
|
|
149
|
-
data.each do |country|
|
150
|
-
rows << [
|
151
|
-
country['country'],
|
152
|
-
comma_delimit(country['cases']),
|
153
|
-
comma_delimit(country['deaths']),
|
154
|
-
comma_delimit(country['recovered']),
|
155
|
-
check_if_positve(country['todayCases']),
|
156
|
-
check_if_positve(country['todayDeaths']),
|
157
|
-
comma_delimit(country['critical']),
|
158
|
-
comma_delimit(country['casesPerOneMillion'])
|
159
166
|
]
|
160
167
|
end
|
161
168
|
|
162
|
-
Terminal::Table.new(headings:
|
169
|
+
Terminal::Table.new(headings: COMPARE_COUNTRY_TABLE_FULL, rows: rows)
|
163
170
|
end
|
164
171
|
|
165
172
|
def cases(cases)
|
@@ -172,7 +179,7 @@ module Kovid
|
|
172
179
|
]
|
173
180
|
]
|
174
181
|
|
175
|
-
Terminal::Table.new(title: 'Total Number of Incidents Worldwide'.upcase, headings: headings, rows: rows)
|
182
|
+
Terminal::Table.new(title: '๐ Total Number of Incidents Worldwide'.upcase, headings: headings, rows: rows)
|
176
183
|
end
|
177
184
|
|
178
185
|
def history(country, last)
|
@@ -215,6 +222,55 @@ module Kovid
|
|
215
222
|
)
|
216
223
|
end
|
217
224
|
|
225
|
+
def histogram(country, date_string)
|
226
|
+
@date = date_string.split('.')
|
227
|
+
|
228
|
+
if @date.last.to_i != 20
|
229
|
+
Kovid.info_table('Only 2020 histgrams are available.')
|
230
|
+
return
|
231
|
+
end
|
232
|
+
|
233
|
+
# From dates where number of !cases.zero?
|
234
|
+
positive_cases_figures = country['timeline']['cases'].values.reject!(&:zero?)
|
235
|
+
dates = country['timeline']['cases'].reject { |_k, v| v.zero? }.keys
|
236
|
+
data = []
|
237
|
+
|
238
|
+
# Improve this later, like everything else.
|
239
|
+
# Returns array of days.to_i from the date param
|
240
|
+
dates = dates.map do |date|
|
241
|
+
date.split('/')
|
242
|
+
end.select do |date|
|
243
|
+
date.last == @date.last
|
244
|
+
end.select do |date|
|
245
|
+
date.first == @date.first
|
246
|
+
end.map do |array|
|
247
|
+
array[1]
|
248
|
+
end.map(&:to_i).last(positive_cases_figures.count)
|
249
|
+
|
250
|
+
# Arranges dates and figures in [x,y] for histogram
|
251
|
+
# With x being day, y being number of cases
|
252
|
+
if dates.empty?
|
253
|
+
if @date.first.to_i > Time.now.month
|
254
|
+
Kovid.info_table('Seriously...??! ๐')
|
255
|
+
else
|
256
|
+
Kovid.info_table('No infections for this month.')
|
257
|
+
end
|
258
|
+
|
259
|
+
else
|
260
|
+
dates.each_with_index do |val, index|
|
261
|
+
data << [val, positive_cases_figures[index]]
|
262
|
+
end
|
263
|
+
y_range = AsciiCharts::Cartesian.new(data, bar: true, hide_zero: true).y_range
|
264
|
+
|
265
|
+
last_two_y = y_range.last 2
|
266
|
+
y_interval = last_two_y.last - last_two_y.first
|
267
|
+
|
268
|
+
scale("Scale on Y: #{y_interval}:#{(y_interval / last_two_y.last.to_f * positive_cases_figures.last).round(2) / y_interval}")
|
269
|
+
|
270
|
+
AsciiCharts::Cartesian.new(data, bar: true, hide_zero: true).draw
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
218
274
|
def eu_aggregate(eu_data)
|
219
275
|
rows = []
|
220
276
|
rows << [
|
@@ -228,7 +284,7 @@ module Kovid
|
|
228
284
|
]
|
229
285
|
|
230
286
|
Terminal::Table.new(
|
231
|
-
title: 'Aggregated EU (27 States) Data'.upcase,
|
287
|
+
title: '๐ช๐บ' + 8203.chr(Encoding::UTF_8) + ' Aggregated EU (27 States) Data'.upcase,
|
232
288
|
headings: EU_AGGREGATE_HEADINGS,
|
233
289
|
rows: rows
|
234
290
|
)
|
@@ -248,7 +304,7 @@ module Kovid
|
|
248
304
|
end
|
249
305
|
|
250
306
|
def country_emoji(iso)
|
251
|
-
COUNTRY_LETTERS.values_at(*iso.chars).pack('U*')
|
307
|
+
COUNTRY_LETTERS.values_at(*iso.chars).pack('U*') + 8203.chr(Encoding::UTF_8)
|
252
308
|
end
|
253
309
|
|
254
310
|
def transpose(load)
|
@@ -256,6 +312,11 @@ module Kovid
|
|
256
312
|
data.map! { |number| comma_delimit(number) }
|
257
313
|
end
|
258
314
|
end
|
315
|
+
|
316
|
+
def scale(msg)
|
317
|
+
rows = [[msg]]
|
318
|
+
puts Terminal::Table.new title: 'SCALE', rows: rows
|
319
|
+
end
|
259
320
|
end
|
260
321
|
end
|
261
322
|
end
|
data/lib/kovid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kovid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ascii_charts
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +120,7 @@ files:
|
|
106
120
|
- lib/kovid.rb
|
107
121
|
- lib/kovid/cache.rb
|
108
122
|
- lib/kovid/cli.rb
|
123
|
+
- lib/kovid/helpers.rb
|
109
124
|
- lib/kovid/painter.rb
|
110
125
|
- lib/kovid/request.rb
|
111
126
|
- lib/kovid/tablelize.rb
|