kovid 0.1.5 β 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -1
- data/README.md +40 -11
- data/{exe β bin}/kovid +0 -0
- data/kovid.gemspec +3 -2
- data/lib/kovid.rb +1 -0
- data/lib/kovid/cli.rb +15 -10
- data/lib/kovid/nineteen.rb +12 -8
- data/lib/kovid/request.rb +49 -22
- data/lib/kovid/tablelize.rb +34 -9
- data/lib/kovid/version.rb +1 -1
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d88a60762b84316b69f47dc5ba6b5fe8e00369ab5e98ad96685e49d34e833d5d
|
4
|
+
data.tar.gz: d535c09d1ce0eb0d14ee197af7e6b7dc7c771ba147e9863b0293c0c4362f6855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb2b119112c48f59c10d63b03949a589fc5dbdedaa9527021047f1840362108383ef9a6faae072dc915e9e28690d4953c21283a955ade2cb419e8e4f93f3844
|
7
|
+
data.tar.gz: b01e98ef4d23107e9d3922adab7a7b715ff06405ee3891eb485e4df4f31f375c62de4b6fcd577a83c17a558d5ebdc799674d864e0fc226ec6671e430c7e734ac
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kovid (0.1.
|
4
|
+
kovid (0.1.9)
|
5
5
|
terminal-table
|
6
6
|
thor
|
7
7
|
typhoeus
|
@@ -38,6 +38,7 @@ GEM
|
|
38
38
|
cucumber-tag_expressions (1.1.1)
|
39
39
|
cucumber-wire (0.0.1)
|
40
40
|
diff-lcs (1.3)
|
41
|
+
docile (1.3.2)
|
41
42
|
ethon (0.12.0)
|
42
43
|
ffi (>= 1.3.0)
|
43
44
|
ffi (1.12.2)
|
@@ -62,6 +63,10 @@ GEM
|
|
62
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
64
|
rspec-support (~> 3.9.0)
|
64
65
|
rspec-support (3.9.2)
|
66
|
+
simplecov (0.18.5)
|
67
|
+
docile (~> 1.1)
|
68
|
+
simplecov-html (~> 0.11)
|
69
|
+
simplecov-html (0.12.2)
|
65
70
|
terminal-table (1.8.0)
|
66
71
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
67
72
|
thor (1.0.1)
|
@@ -79,6 +84,7 @@ DEPENDENCIES
|
|
79
84
|
pry
|
80
85
|
rake (~> 12.0)
|
81
86
|
rspec (~> 3.0)
|
87
|
+
simplecov
|
82
88
|
|
83
89
|
BUNDLED WITH
|
84
90
|
2.1.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# π¦ Kovid
|
2
2
|
|
3
|
-
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 most of you, I thought I'd build this to
|
3
|
+
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 most of you, I thought I'd build this to put the data right at our fingertips.
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -12,28 +12,50 @@ Before installing:
|
|
12
12
|
|
13
13
|
βοΈ Wash your hands with soap and water for at least 20 seconds.
|
14
14
|
|
15
|
-
βοΈ Run
|
15
|
+
βοΈ Run `gem install kovid`
|
16
16
|
|
17
17
|
|
18
18
|
After installing:
|
19
19
|
|
20
20
|
βοΈ Avoid touching your eyes, nose and mouth with unwashed hands later.
|
21
21
|
|
22
|
-
βοΈ Disinfect your phones, keys,
|
22
|
+
βοΈ Disinfect your phones, keys, doorknobs and anything you touch often than you should.
|
23
23
|
|
24
24
|
|
25
25
|
|
26
26
|
## βοΈ Usage
|
27
27
|
|
28
|
+
You can run `kovid --help` to see full list of available commands.
|
29
|
+
|
30
|
+
#### Commands Overview
|
31
|
+
**Fetching**
|
32
|
+
* `kovid check ghana`
|
33
|
+
* `kovid check ghana -f` OR `kovid check ghana --full`
|
34
|
+
|
35
|
+
πΊπΈ You can fetch US state-specific data with:
|
36
|
+
* `kovid state colorado` OR `kovid state "north carolina"`
|
37
|
+
|
38
|
+
**Comparing**
|
39
|
+
* `kovid compare ghana poland` (sorts by cases DESC)
|
40
|
+
* `kovid compare ghana poland -f` OR `kovid compare ghana poland --full` (sorts by cases DESC)
|
41
|
+
|
42
|
+
You can compare as many countries as you want.
|
43
|
+
|
44
|
+
**Total figures**
|
45
|
+
* `kovid cases`
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
#### Commands Details
|
28
50
|
To fetch basic data on a country run:
|
29
51
|
|
30
|
-
`kovid check ghana
|
52
|
+
`kovid check ghana`
|
31
53
|
|
32
54
|
If the location contains spaces: `kovid check "Diamond Princess"`
|
33
55
|
|
34
56
|
![kovid](https://i.gyazo.com/ca57d9250c7523a921d0d7e1104716be.png "Covid data.")
|
35
57
|
|
36
|
-
For
|
58
|
+
For full table info on a country:
|
37
59
|
|
38
60
|
`kovid check ghana -f` OR `kovid check ghana --full`
|
39
61
|
|
@@ -47,9 +69,15 @@ To compare country stats:
|
|
47
69
|
|
48
70
|
To compare a countries stats with a full table:
|
49
71
|
|
50
|
-
`kovid compare
|
72
|
+
`kovid compare poland italy usa china -f` OR `kovid compare poland italy usa china --full`
|
73
|
+
|
74
|
+
![kovid](https://i.gyazo.com/7ce86c5e93d549e1412fb6104a1d7877.png "Covid data.")
|
51
75
|
|
52
|
-
|
76
|
+
To fetch state-specific data run:
|
77
|
+
|
78
|
+
`kovid state colorado`
|
79
|
+
|
80
|
+
![kovid](https://i.gyazo.com/133046d9d31c20a8bad1a05b46ba4d3e.png "Covid data.")
|
53
81
|
|
54
82
|
To check for total figures:
|
55
83
|
|
@@ -61,17 +89,18 @@ To check for total figures:
|
|
61
89
|
|
62
90
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
63
91
|
|
64
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
92
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
93
|
+
|
65
94
|
|
66
95
|
## π€² Contributing
|
67
96
|
|
68
|
-
|
97
|
+
There are multiple areas in this repo that can be improved or use some refactoring and for thats why bug reports and pull requests are welcome here on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/siaw23/kovid/blob/master/CODE_OF_CONDUCT.md).
|
69
98
|
|
70
99
|
|
71
100
|
## π License
|
72
101
|
|
73
|
-
The gem is available as open
|
102
|
+
The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
74
103
|
|
75
104
|
## β€οΈ Code of Conduct
|
76
105
|
|
77
|
-
Everyone interacting in the Kovid project's codebases
|
106
|
+
Everyone interacting in the Kovid project's codebases and issue trackers is expected to follow the [code of conduct](https://github.com/siaw23/kovid/blob/master/CODE_OF_CONDUCT.md).
|
data/{exe β bin}/kovid
RENAMED
File without changes
|
data/kovid.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
25
|
end
|
26
|
-
spec.bindir = "
|
27
|
-
spec.executables = spec.files.grep(%r{^
|
26
|
+
spec.bindir = "bin"
|
27
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
spec.add_dependency "thor"
|
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "pry"
|
35
35
|
spec.add_development_dependency "cucumber"
|
36
36
|
spec.add_development_dependency "aruba"
|
37
|
+
spec.add_development_dependency "simplecov"
|
37
38
|
end
|
data/lib/kovid.rb
CHANGED
data/lib/kovid/cli.rb
CHANGED
@@ -5,34 +5,39 @@ require 'kovid'
|
|
5
5
|
|
6
6
|
module Kovid
|
7
7
|
class CLI < Thor
|
8
|
-
desc '
|
9
|
-
def
|
10
|
-
Kovid::Nineteen.whatis
|
8
|
+
desc 'define', 'Defines COVID-19'
|
9
|
+
def define
|
10
|
+
puts Kovid::Nineteen.whatis
|
11
11
|
end
|
12
12
|
|
13
|
-
desc 'check', 'Returns data on country'
|
13
|
+
desc 'check COUNTRY', 'Returns reported data on provided country'
|
14
14
|
method_option :full, aliases: '-f'
|
15
15
|
def check(name)
|
16
16
|
if options[:full]
|
17
|
-
Kovid::Nineteen.country_full(name)
|
17
|
+
puts Kovid::Nineteen.country_full(name)
|
18
18
|
else
|
19
|
-
Kovid::Nineteen.country(name)
|
19
|
+
puts Kovid::Nineteen.country(name)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
desc '
|
23
|
+
desc 'state STATE', 'Return reported data on provided state'
|
24
|
+
def state(state)
|
25
|
+
puts Kovid::Nineteen.state(state)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries'
|
24
29
|
def compare(*name)
|
25
30
|
if name[-1] == '-f' || name[-1] == '--full'
|
26
31
|
name = name.reverse.drop(1).reverse
|
27
|
-
Kovid::Nineteen.country_comparison_full(name)
|
32
|
+
puts Kovid::Nineteen.country_comparison_full(name)
|
28
33
|
else
|
29
|
-
Kovid::Nineteen.country_comparison(name)
|
34
|
+
puts Kovid::Nineteen.country_comparison(name)
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
33
38
|
desc 'cases', 'Returns total number of cases, deaths and recoveries'
|
34
39
|
def cases
|
35
|
-
Kovid::Nineteen.cases
|
40
|
+
puts Kovid::Nineteen.cases
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
data/lib/kovid/nineteen.rb
CHANGED
@@ -6,27 +6,31 @@ module Kovid
|
|
6
6
|
class Nineteen
|
7
7
|
class << self
|
8
8
|
def whatis
|
9
|
-
|
9
|
+
'Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).'
|
10
10
|
end
|
11
11
|
|
12
12
|
def country(name)
|
13
|
-
|
13
|
+
Kovid::Request.by_country(name)
|
14
14
|
end
|
15
15
|
|
16
16
|
def country_full(name)
|
17
|
-
|
17
|
+
Kovid::Request.by_country_full(name)
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def state(state)
|
21
|
+
Kovid::Request.state(state)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def country_comparison(names_array)
|
25
|
+
Kovid::Request.by_country_comparison(names_array)
|
26
|
+
end
|
27
|
+
|
28
|
+
def country_comparison_full(names_array)
|
29
|
+
Kovid::Request.by_country_comparison_full(names_array)
|
26
30
|
end
|
27
31
|
|
28
32
|
def cases
|
29
|
-
|
33
|
+
Kovid::Request.cases
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
data/lib/kovid/request.rb
CHANGED
@@ -9,37 +9,56 @@ module Kovid
|
|
9
9
|
BASE_URL = 'https://corona.lmao.ninja'
|
10
10
|
|
11
11
|
class << self
|
12
|
-
|
13
|
-
|
14
|
-
path = "/countries/#{name}"
|
15
|
-
fetch_url = BASE_URL + path
|
12
|
+
def by_country(country_name)
|
13
|
+
response = fetch_country(country_name)
|
16
14
|
|
17
|
-
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
18
15
|
Kovid::Tablelize.country_table(response)
|
16
|
+
rescue JSON::ParserError
|
17
|
+
no_case_in(country_name)
|
19
18
|
end
|
20
19
|
|
21
|
-
def by_country_full(
|
22
|
-
|
23
|
-
fetch_url = BASE_URL + path
|
20
|
+
def by_country_full(country_name)
|
21
|
+
response = fetch_country(country_name)
|
24
22
|
|
25
|
-
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
26
23
|
Kovid::Tablelize.full_country_table(response)
|
24
|
+
rescue JSON::ParserError
|
25
|
+
no_case_in(country_name)
|
27
26
|
end
|
28
27
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
list.each do |country|
|
33
|
-
path = "/countries/#{country}"
|
34
|
-
fetch_url = BASE_URL + path
|
28
|
+
def state(state)
|
29
|
+
response = fetch_state(state)
|
35
30
|
|
36
|
-
|
37
|
-
|
31
|
+
Kovid::Tablelize.full_state_table(response)
|
32
|
+
end
|
38
33
|
|
34
|
+
def by_country_comparison(list)
|
35
|
+
array = fetch_countries(list)
|
39
36
|
Kovid::Tablelize.compare_countries_table(array)
|
40
37
|
end
|
41
38
|
|
42
39
|
def by_country_comparison_full(list)
|
40
|
+
array = fetch_countries(list)
|
41
|
+
Kovid::Tablelize.compare_countries_table_full(array)
|
42
|
+
end
|
43
|
+
|
44
|
+
def cases
|
45
|
+
path = '/all'
|
46
|
+
fetch_url = BASE_URL + path
|
47
|
+
|
48
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
49
|
+
Kovid::Tablelize.cases(response)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def no_case_in(country)
|
55
|
+
rows = []
|
56
|
+
rows << ["Thankfully, there are no reported cases in #{country.capitalize}!"]
|
57
|
+
table = Terminal::Table.new headings: [country.capitalize.to_s], rows: rows
|
58
|
+
table
|
59
|
+
end
|
60
|
+
|
61
|
+
def fetch_countries(list)
|
43
62
|
array = []
|
44
63
|
|
45
64
|
list.each do |country|
|
@@ -49,15 +68,23 @@ module Kovid
|
|
49
68
|
array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
50
69
|
end
|
51
70
|
|
52
|
-
|
71
|
+
array = array.sort_by { |json| -json['cases'] }
|
53
72
|
end
|
54
73
|
|
55
|
-
def
|
56
|
-
path =
|
74
|
+
def fetch_country(country_name)
|
75
|
+
path = "/countries/#{country_name}"
|
57
76
|
fetch_url = BASE_URL + path
|
58
77
|
|
59
|
-
|
60
|
-
|
78
|
+
JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
79
|
+
end
|
80
|
+
|
81
|
+
def fetch_state(state)
|
82
|
+
path = '/states'
|
83
|
+
fetch_url = BASE_URL + path
|
84
|
+
|
85
|
+
states_array = JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
86
|
+
|
87
|
+
states_array.select { |state_name| state_name['state'] == state.split.map(&:capitalize).join(' ') }.first
|
61
88
|
end
|
62
89
|
end
|
63
90
|
end
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -9,7 +9,7 @@ module Kovid
|
|
9
9
|
headings = %w[Cases Deaths Recovered]
|
10
10
|
rows = []
|
11
11
|
rows << [data['cases'], data['deaths'], data['recovered']]
|
12
|
-
|
12
|
+
Terminal::Table.new(title: data['country'], headings: headings, rows: rows)
|
13
13
|
end
|
14
14
|
|
15
15
|
def full_country_table(data)
|
@@ -33,9 +33,16 @@ module Kovid
|
|
33
33
|
data['critical'],
|
34
34
|
data['casesPerOneMillion']
|
35
35
|
]
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
Terminal::Table.new(title: data['country'],
|
37
|
+
headings: headings,
|
38
|
+
rows: rows)
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_state_table(state)
|
42
|
+
headings = ['Cases', 'Cases Today', 'Deaths', 'Deaths Today', 'Reovered', 'Active']
|
43
|
+
rows = []
|
44
|
+
rows << [state['cases'], state['todayCases'], state['deaths'], state['todayDeaths'], state['recovered'], state['active']]
|
45
|
+
Terminal::Table.new(title: state['state'], headings: headings, rows: rows)
|
39
46
|
end
|
40
47
|
|
41
48
|
def compare_countries_table(data)
|
@@ -46,18 +53,36 @@ module Kovid
|
|
46
53
|
rows << [country['country'], country['cases'], country['deaths'], country['recovered']]
|
47
54
|
end
|
48
55
|
|
49
|
-
|
56
|
+
Terminal::Table.new(headings: headings, rows: rows)
|
50
57
|
end
|
51
58
|
|
52
59
|
def compare_countries_table_full(data)
|
53
|
-
headings = [
|
60
|
+
headings = [
|
61
|
+
'Country',
|
62
|
+
'Cases',
|
63
|
+
'Deaths',
|
64
|
+
'Recovered',
|
65
|
+
'Cases Today',
|
66
|
+
'Deaths Today',
|
67
|
+
'Critical',
|
68
|
+
'Cases/Million'
|
69
|
+
]
|
54
70
|
rows = []
|
55
71
|
|
56
72
|
data.each do |country|
|
57
|
-
rows << [
|
73
|
+
rows << [
|
74
|
+
country['country'],
|
75
|
+
country['cases'],
|
76
|
+
country['deaths'],
|
77
|
+
country['recovered'],
|
78
|
+
country['todayCases'],
|
79
|
+
country['todayDeaths'],
|
80
|
+
country['critical'],
|
81
|
+
country['casesPerOneMillion']
|
82
|
+
]
|
58
83
|
end
|
59
84
|
|
60
|
-
|
85
|
+
Terminal::Table.new(headings: headings, rows: rows)
|
61
86
|
end
|
62
87
|
|
63
88
|
def cases(cases)
|
@@ -66,7 +91,7 @@ module Kovid
|
|
66
91
|
rows = []
|
67
92
|
|
68
93
|
rows << [cases['cases'], cases['deaths'], cases['recovered']]
|
69
|
-
|
94
|
+
Terminal::Table.new(title: 'Total # of incidents', headings: headings, rows: rows)
|
70
95
|
end
|
71
96
|
end
|
72
97
|
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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -94,11 +94,27 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: A CLI tool to fetch and compare the 2019 coronavirus pandemic numbers.
|
98
112
|
email:
|
99
113
|
- siawmensah@gmail.com
|
100
114
|
executables:
|
115
|
+
- console
|
101
116
|
- kovid
|
117
|
+
- setup
|
102
118
|
extensions: []
|
103
119
|
extra_rdoc_files: []
|
104
120
|
files:
|
@@ -112,8 +128,8 @@ files:
|
|
112
128
|
- README.md
|
113
129
|
- Rakefile
|
114
130
|
- bin/console
|
131
|
+
- bin/kovid
|
115
132
|
- bin/setup
|
116
|
-
- exe/kovid
|
117
133
|
- kovid.gemspec
|
118
134
|
- lib/kovid.rb
|
119
135
|
- lib/kovid/cli.rb
|