kovid 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/lib/kovid/cli.rb +4 -4
- data/lib/kovid/nineteen.rb +7 -1
- data/lib/kovid/request.rb +19 -21
- data/lib/kovid/tablelize.rb +1 -1
- data/lib/kovid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62b08f268f6500bd01a16f58e6f723f6cb38c993a462a1c5df7ac3d81bb92124
|
4
|
+
data.tar.gz: 7ce4bf26fc74ef311e456ec9d5e75e0fc8b2f149643153d2afa95a018383a319
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e2acc82bc376fc649469c901b155b81672000ac07debb5c4ad04f51271871528fe320e24b71710165f76d2dd3adde89417011a3e361643a67a9991fc19afb5
|
7
|
+
data.tar.gz: 5b16bbf5ea2cbba4cf2c6eb2944a8dccef026872479c5a14e086e0b6fbe0ca7e0c45d2188b406fa357c7927adc7b69bc7619292e77ca33b590ad37e1fff1f013
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ 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:
|
@@ -25,14 +25,18 @@ After installing:
|
|
25
25
|
|
26
26
|
## ⚒️ Usage
|
27
27
|
|
28
|
+
You can run `kovid --help` to see full list of available commands.
|
29
|
+
|
28
30
|
#### Commands Overview
|
29
31
|
**Fetching**
|
30
|
-
* `kovid check ghana
|
32
|
+
* `kovid check ghana`
|
31
33
|
* `kovid check ghana -f` OR `kovid check ghana --full`
|
32
34
|
|
33
35
|
**Comparing**
|
34
|
-
* `kovid compare ghana poland`
|
35
|
-
* `kovid compare ghana poland -f` OR `kovid compare ghana poland --full`
|
36
|
+
* `kovid compare ghana poland` (sorts by cases DESC)
|
37
|
+
* `kovid compare ghana poland -f` OR `kovid compare ghana poland --full` (sorts by cases DESC)
|
38
|
+
|
39
|
+
You can compare as many countries as you want.
|
36
40
|
|
37
41
|
**Total figures**
|
38
42
|
* `kovid cases`
|
@@ -62,9 +66,9 @@ To compare country stats:
|
|
62
66
|
|
63
67
|
To compare a countries stats with a full table:
|
64
68
|
|
65
|
-
`kovid compare
|
69
|
+
`kovid compare poland italy usa china -f` OR `kovid compare poland italy usa china --full`
|
66
70
|
|
67
|
-
![kovid](https://i.gyazo.com/
|
71
|
+
![kovid](https://i.gyazo.com/7ce86c5e93d549e1412fb6104a1d7877.png "Covid data.")
|
68
72
|
|
69
73
|
To check for total figures:
|
70
74
|
|
@@ -80,7 +84,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
80
84
|
|
81
85
|
## 🤲 Contributing
|
82
86
|
|
83
|
-
|
87
|
+
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).
|
84
88
|
|
85
89
|
|
86
90
|
## 🔖 License
|
@@ -89,4 +93,4 @@ The gem is available as open-source under the terms of the [MIT License](https:/
|
|
89
93
|
|
90
94
|
## ❤️ Code of Conduct
|
91
95
|
|
92
|
-
Everyone interacting in the Kovid project's codebases
|
96
|
+
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/lib/kovid/cli.rb
CHANGED
@@ -5,12 +5,12 @@ require 'kovid'
|
|
5
5
|
|
6
6
|
module Kovid
|
7
7
|
class CLI < Thor
|
8
|
-
desc '
|
9
|
-
def
|
8
|
+
desc 'define', 'Defines COVID-19'
|
9
|
+
def define
|
10
10
|
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]
|
@@ -20,7 +20,7 @@ module Kovid
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
desc 'compare', 'Returns full comparison table for given countries'
|
23
|
+
desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries'
|
24
24
|
def compare(*name)
|
25
25
|
if name[-1] == '-f' || name[-1] == '--full'
|
26
26
|
name = name.reverse.drop(1).reverse
|
data/lib/kovid/nineteen.rb
CHANGED
@@ -6,7 +6,13 @@ module Kovid
|
|
6
6
|
class Nineteen
|
7
7
|
class << self
|
8
8
|
def whatis
|
9
|
-
|
9
|
+
definition = <<-TEXT
|
10
|
+
Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute
|
11
|
+
respiratory syndrome coronavirus 2 (SARS-CoV-2).
|
12
|
+
The disease was first identified in 2019 in Wuhan, China, and has since spread globally,
|
13
|
+
resulting in the 2019–20 coronavirus pandemic.
|
14
|
+
TEXT
|
15
|
+
puts definition
|
10
16
|
end
|
11
17
|
|
12
18
|
def country(name)
|
data/lib/kovid/request.rb
CHANGED
@@ -10,29 +10,24 @@ module Kovid
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
require 'pry'
|
13
|
-
def by_country(
|
14
|
-
|
15
|
-
|
16
|
-
fetch_url = BASE_URL + path
|
17
|
-
|
18
|
-
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
19
|
-
Kovid::Tablelize.country_table(response)
|
13
|
+
def by_country(country_name)
|
14
|
+
path = "/countries/#{country_name}"
|
15
|
+
fetch_url = BASE_URL + path
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
18
|
+
Kovid::Tablelize.country_table(response)
|
19
|
+
rescue JSON::ParserError
|
20
|
+
no_case_in(country_name)
|
24
21
|
end
|
25
22
|
|
26
|
-
def by_country_full(
|
27
|
-
|
28
|
-
|
29
|
-
fetch_url = BASE_URL + path
|
23
|
+
def by_country_full(country_name)
|
24
|
+
path = "/countries/#{country_name}"
|
25
|
+
fetch_url = BASE_URL + path
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
27
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
28
|
+
Kovid::Tablelize.full_country_table(response)
|
29
|
+
rescue JSON::ParserError
|
30
|
+
no_case_in(country_name)
|
36
31
|
end
|
37
32
|
|
38
33
|
def by_country_comparison(list)
|
@@ -45,6 +40,8 @@ module Kovid
|
|
45
40
|
array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
46
41
|
end
|
47
42
|
|
43
|
+
array = array.sort_by { |json| -json['cases'] }
|
44
|
+
|
48
45
|
Kovid::Tablelize.compare_countries_table(array)
|
49
46
|
end
|
50
47
|
|
@@ -57,6 +54,7 @@ module Kovid
|
|
57
54
|
|
58
55
|
array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
59
56
|
end
|
57
|
+
array = array.sort_by { |json| -json['cases'] }
|
60
58
|
|
61
59
|
Kovid::Tablelize.compare_countries_table_full(array)
|
62
60
|
end
|
@@ -73,8 +71,8 @@ module Kovid
|
|
73
71
|
|
74
72
|
def no_case_in(country)
|
75
73
|
rows = []
|
76
|
-
rows << ["Thankfully there are no reported cases in #{country.capitalize}!"]
|
77
|
-
table = Terminal::Table.new :
|
74
|
+
rows << ["Thankfully, there are no reported cases in #{country.capitalize}!"]
|
75
|
+
table = Terminal::Table.new headings: [country.capitalize.to_s], rows: rows
|
78
76
|
puts table
|
79
77
|
end
|
80
78
|
end
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -66,7 +66,7 @@ module Kovid
|
|
66
66
|
rows = []
|
67
67
|
|
68
68
|
rows << [cases['cases'], cases['deaths'], cases['recovered']]
|
69
|
-
puts Terminal::Table.new(title:
|
69
|
+
puts Terminal::Table.new(title: 'Total # of incidents', headings: headings, rows: rows)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
8
8
|
autorequire:
|
9
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
|