kovid 0.2.0 → 0.2.1
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/README.md +12 -10
- data/kovid.gemspec +2 -1
- data/lib/kovid/cli.rb +5 -0
- data/lib/kovid/request.rb +8 -0
- data/lib/kovid/tablelize.rb +39 -2
- data/lib/kovid/version.rb +1 -1
- data/lib/kovid.rb +4 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc383fce99f91758770cb5df355b7bd0880f7df93e4afe522499340b2bc2130
|
4
|
+
data.tar.gz: e3728a3a48b0c7b7986b70e2dd4aca2bfd245422bf65bc5b0b6ffea7e8f32f81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8604d3d7720a5b904a4cfc025d961ebdef4b7cfc863cb444f3fce2b9e603f4cab2b80f81e768184c7e330973ecd5696b889b783ff4e48af4e8ce2862b499fb39
|
7
|
+
data.tar.gz: 5c408b62c29e811cfda4e1dad700077317dc67812d58d9ca03264bfbdfed39c6793dd079dfb654340643e6c7b4c334ba609281886a067174992fe9f928f7a69b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# 🦠 Kovid
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[gem]: https://rubygems.org/gems/kovid
|
5
4
|
|
5
|
+
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 and since I work mostly in the terminal, like some of you, I thought I'd build this to put the data right at our fingertips.
|
6
6
|
|
7
7
|
Please feel free to contribute or suggest ideas!
|
8
8
|
|
@@ -15,13 +15,6 @@ Before installing:
|
|
15
15
|
✌️ Run `gem install kovid`
|
16
16
|
|
17
17
|
|
18
|
-
After installing:
|
19
|
-
|
20
|
-
☝️ Avoid touching your eyes, nose and mouth with unwashed hands later.
|
21
|
-
|
22
|
-
✌️ Disinfect your phones, keys, doorknobs and anything you touch more often than you should.
|
23
|
-
|
24
|
-
|
25
18
|
|
26
19
|
## ⚒️ Usage
|
27
20
|
|
@@ -43,6 +36,9 @@ You can run `kovid --help` to see the full list of available commands.
|
|
43
36
|
|
44
37
|
You can compare as many countries as you want.
|
45
38
|
|
39
|
+
😷 **History**
|
40
|
+
* `kovid history italy`
|
41
|
+
|
46
42
|
😷 **Total figures**
|
47
43
|
* `kovid cases`
|
48
44
|
|
@@ -59,7 +55,7 @@ If the location contains spaces: `kovid check "Diamond Princess"`
|
|
59
55
|
|
60
56
|
For full table info on a country:
|
61
57
|
|
62
|
-
`kovid check italy -f` OR `kovid check italy
|
58
|
+
`kovid check italy -f` OR `kovid check italy --full`
|
63
59
|
|
64
60
|
![kovid](https://i.gyazo.com/789fa6795d06f529a9b5f37cb51fb516.png "Covid data.")
|
65
61
|
|
@@ -81,6 +77,12 @@ To fetch state-specific data run:
|
|
81
77
|
|
82
78
|
![kovid](https://i.gyazo.com/d00b1c5bbb6251cbd517f801c856ba66.png "Covid data.")
|
83
79
|
|
80
|
+
You can check historical statistics by running
|
81
|
+
|
82
|
+
`kovid history COUNTRY` eg:
|
83
|
+
|
84
|
+
![kovid](https://i.gyazo.com/45d306694cbf793f2e4f7646854cbac8.png "Covid data.")
|
85
|
+
|
84
86
|
To check for total figures:
|
85
87
|
|
86
88
|
`kovid cases`
|
data/kovid.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
There isn't much we can do now aside:
|
24
24
|
|
25
25
|
* Washing our hands with soap frequently.
|
26
|
-
* Limiting our movements
|
26
|
+
* Limiting our movements, how much we touch our faces & social distancing.
|
27
|
+
* Disinfecting our phones, keys, doorknobs, keyboards, etc.
|
27
28
|
* Being there for each other.
|
28
29
|
|
29
30
|
Stay safe!
|
data/lib/kovid/cli.rb
CHANGED
data/lib/kovid/request.rb
CHANGED
@@ -50,6 +50,14 @@ module Kovid
|
|
50
50
|
Kovid::Tablelize.cases(response)
|
51
51
|
end
|
52
52
|
|
53
|
+
def history(country)
|
54
|
+
path = '/historical'
|
55
|
+
fetch_url = BASE_URL + path + "/#{country}"
|
56
|
+
|
57
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 900).response_body)
|
58
|
+
Kovid::Tablelize.history(response)
|
59
|
+
end
|
60
|
+
|
53
61
|
private
|
54
62
|
|
55
63
|
def no_case_in(country)
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'terminal-table'
|
4
4
|
require_relative 'painter'
|
5
|
-
|
5
|
+
require 'pry'
|
6
|
+
require 'date'
|
6
7
|
module Kovid
|
7
8
|
class Tablelize
|
8
9
|
class << self
|
@@ -12,6 +13,13 @@ module Kovid
|
|
12
13
|
'Recovered'.paint_green
|
13
14
|
].freeze
|
14
15
|
|
16
|
+
DATE_CASES_DEATHS_RECOVERED = [
|
17
|
+
'Date'.paint_white,
|
18
|
+
'Cases'.paint_white,
|
19
|
+
'Deaths'.paint_red,
|
20
|
+
'Recovered'.paint_green
|
21
|
+
].freeze
|
22
|
+
|
15
23
|
def country_table(data)
|
16
24
|
headings = CASES_DEATHS_RECOVERED
|
17
25
|
rows = [[data['cases'], data['deaths'], data['recovered']]]
|
@@ -111,8 +119,37 @@ module Kovid
|
|
111
119
|
headings = CASES_DEATHS_RECOVERED
|
112
120
|
rows = [[cases['cases'], cases['deaths'], cases['recovered']]]
|
113
121
|
|
114
|
-
Terminal::Table.new(title: 'Total
|
122
|
+
Terminal::Table.new(title: 'Total Number of Incidents Worldwide', headings: headings, rows: rows)
|
115
123
|
end
|
124
|
+
|
125
|
+
def history(country)
|
126
|
+
headings = DATE_CASES_DEATHS_RECOVERED
|
127
|
+
rows = []
|
128
|
+
stats = country['timeline'].values.map(&:values).transpose.each do |data|
|
129
|
+
data.map! { |number| comma_delimit(number) }
|
130
|
+
end
|
131
|
+
|
132
|
+
dates = country['timeline']['cases'].keys
|
133
|
+
|
134
|
+
data = stats.each_with_index do |val, index|
|
135
|
+
val.unshift(Date.parse(Date.strptime(dates[index], '%m/%d/%y').to_s).strftime('%d %b, %y'))
|
136
|
+
end.each do |row|
|
137
|
+
rows << row
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
rows << ["------------", "------------","------------","------------"]
|
142
|
+
rows << DATE_CASES_DEATHS_RECOVERED
|
143
|
+
|
144
|
+
Terminal::Table.new(title: country['standardizedCountryName'].capitalize.to_s, headings: headings, rows: rows)
|
145
|
+
end
|
146
|
+
|
147
|
+
private def comma_delimit(number)
|
148
|
+
number.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(',').reverse
|
149
|
+
end
|
150
|
+
|
116
151
|
end
|
152
|
+
|
153
|
+
|
117
154
|
end
|
118
155
|
end
|
data/lib/kovid/version.rb
CHANGED
data/lib/kovid.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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
@@ -164,8 +164,10 @@ post_install_message: "\n ===================================================
|
|
164
164
|
\ COVID-19 has devasted the world! But while we're fighting\n with the
|
165
165
|
novel coronavirus, I think stats on the issue should be easily\n reachable.\n\n
|
166
166
|
\ There isn't much we can do now aside:\n\n * Washing our hands with soap
|
167
|
-
frequently.\n * Limiting our movements
|
168
|
-
|
167
|
+
frequently.\n * Limiting our movements, how much we touch our faces & social
|
168
|
+
distancing.\n * Disinfecting our phones, keys, doorknobs, keyboards, etc.\n
|
169
|
+
\ * Being there for each other.\n\n Stay safe!\n Emmanuel Hayford.\n
|
170
|
+
\ ============================================================================\n
|
169
171
|
\ "
|
170
172
|
rdoc_options: []
|
171
173
|
require_paths:
|