kovid 0.1.9 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -1
- data/README.md +30 -14
- data/{bin/kovid → exe/covid} +0 -0
- data/exe/kovid +4 -0
- data/kovid.gemspec +6 -4
- data/lib/kovid.rb +31 -1
- data/lib/kovid/cache.rb +21 -0
- data/lib/kovid/cli.rb +19 -10
- data/lib/kovid/painter.rb +21 -0
- data/lib/kovid/request.rb +22 -9
- data/lib/kovid/tablelize.rb +57 -30
- data/lib/kovid/version.rb +1 -1
- metadata +38 -10
- data/lib/kovid/nineteen.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af922cf964393c54e9e754d0e292e28b273d8879f6d01a26098036dfaf833028
|
4
|
+
data.tar.gz: 0f13b97fc89501ba2e874c7812dbe2b0b5f7c3a5002a8ee428ee4c645f551dac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd75365e81cfe99be195117bc8f0c5d9babac43896f80929922bbe255f4c0052753d6fb078a71c8b7c428877297f3fd6e4997d74d17c525d2657a58112e3acc7
|
7
|
+
data.tar.gz: 580ca440ce3a0fddd3d3e3879ffa5b6617304a1036bd3cfada69e7de952bf543ea02cf7deb8af810065a883ea2256736191e8ecec8453acbc8c3a47ca58dc439
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kovid (0.1.
|
4
|
+
kovid (0.1.13)
|
5
|
+
colorize
|
5
6
|
terminal-table
|
6
7
|
thor
|
7
8
|
typhoeus
|
@@ -20,6 +21,7 @@ GEM
|
|
20
21
|
builder (3.2.4)
|
21
22
|
childprocess (3.0.0)
|
22
23
|
coderay (1.1.2)
|
24
|
+
colorize (0.8.1)
|
23
25
|
contracts (0.16.0)
|
24
26
|
cucumber (3.1.2)
|
25
27
|
builder (>= 2.1.2)
|
@@ -38,6 +40,7 @@ GEM
|
|
38
40
|
cucumber-tag_expressions (1.1.1)
|
39
41
|
cucumber-wire (0.0.1)
|
40
42
|
diff-lcs (1.3)
|
43
|
+
docile (1.3.2)
|
41
44
|
ethon (0.12.0)
|
42
45
|
ffi (>= 1.3.0)
|
43
46
|
ffi (1.12.2)
|
@@ -62,6 +65,10 @@ GEM
|
|
62
65
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
66
|
rspec-support (~> 3.9.0)
|
64
67
|
rspec-support (3.9.2)
|
68
|
+
simplecov (0.18.5)
|
69
|
+
docile (~> 1.1)
|
70
|
+
simplecov-html (~> 0.11)
|
71
|
+
simplecov-html (0.12.2)
|
65
72
|
terminal-table (1.8.0)
|
66
73
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
67
74
|
thor (1.0.1)
|
@@ -79,6 +86,7 @@ DEPENDENCIES
|
|
79
86
|
pry
|
80
87
|
rake (~> 12.0)
|
81
88
|
rspec (~> 3.0)
|
89
|
+
simplecov
|
82
90
|
|
83
91
|
BUNDLED WITH
|
84
92
|
2.1.2
|
data/README.md
CHANGED
@@ -19,26 +19,31 @@ After installing:
|
|
19
19
|
|
20
20
|
☝️ Avoid touching your eyes, nose and mouth with unwashed hands later.
|
21
21
|
|
22
|
-
✌️ Disinfect your phones, keys, doorknobs and anything you touch often than you should.
|
22
|
+
✌️ Disinfect your phones, keys, doorknobs and anything you touch more 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.
|
28
|
+
You can run `kovid --help` to see the full list of available commands.
|
29
|
+
|
30
|
+
**NOTE:** If you find it irritating to have to type `kovid state michigan`, `covid state michigan` works as well.
|
29
31
|
|
30
32
|
#### Commands Overview
|
31
|
-
**Fetching**
|
33
|
+
😷 **Fetching**
|
32
34
|
* `kovid check ghana`
|
33
35
|
* `kovid check ghana -f` OR `kovid check ghana --full`
|
34
36
|
|
35
|
-
|
37
|
+
🇺🇸You can fetch US state-specific data 🇺🇸
|
38
|
+
* `kovid state colorado` OR `kovid state "north carolina"`
|
39
|
+
|
40
|
+
😷 **Comparing**
|
36
41
|
* `kovid compare ghana poland` (sorts by cases DESC)
|
37
|
-
* `kovid compare
|
42
|
+
* `kovid compare germany poland -f` OR `kovid compare germany poland --full` (sorts by cases DESC)
|
38
43
|
|
39
44
|
You can compare as many countries as you want.
|
40
45
|
|
41
|
-
**Total figures**
|
46
|
+
😷 **Total figures**
|
42
47
|
* `kovid cases`
|
43
48
|
|
44
49
|
|
@@ -50,41 +55,52 @@ To fetch basic data on a country run:
|
|
50
55
|
|
51
56
|
If the location contains spaces: `kovid check "Diamond Princess"`
|
52
57
|
|
53
|
-
![kovid](https://i.gyazo.com/
|
58
|
+
![kovid](https://i.gyazo.com/ab779c3fc838ac279bae5b9d6d10d617.png "Covid data.")
|
54
59
|
|
55
60
|
For full table info on a country:
|
56
61
|
|
57
62
|
`kovid check ghana -f` OR `kovid check ghana --full`
|
58
63
|
|
59
|
-
![kovid](https://i.gyazo.com/
|
64
|
+
![kovid](https://i.gyazo.com/151c8e7ac55a7b4efd27b734720863f1.png "Covid data.")
|
60
65
|
|
61
66
|
To compare country stats:
|
62
67
|
|
63
|
-
`kovid compare
|
68
|
+
`kovid compare germany poland`
|
64
69
|
|
65
|
-
![kovid](https://i.gyazo.com/
|
70
|
+
![kovid](https://i.gyazo.com/be3bcba3d2943c60618b59ae82a3c586.png "Covid data.")
|
66
71
|
|
67
72
|
To compare a countries stats with a full table:
|
68
73
|
|
69
74
|
`kovid compare poland italy usa china -f` OR `kovid compare poland italy usa china --full`
|
70
75
|
|
71
|
-
![kovid](https://i.gyazo.com/
|
76
|
+
![kovid](https://i.gyazo.com/79ad61c33114a0bee0a9e2ab94a3d46e.png "Covid data.")
|
77
|
+
|
78
|
+
To fetch state-specific data run:
|
79
|
+
|
80
|
+
`kovid state colorado`
|
81
|
+
|
82
|
+
![kovid](https://i.gyazo.com/d00b1c5bbb6251cbd517f801c856ba66.png "Covid data.")
|
72
83
|
|
73
84
|
To check for total figures:
|
74
85
|
|
75
86
|
`kovid cases`
|
76
87
|
|
77
|
-
![kovid](https://i.gyazo.com/
|
88
|
+
![kovid](https://i.gyazo.com/323f0f10d444e2ee629d05a90488adba.png "Covid data.")
|
89
|
+
|
90
|
+
## Information Source
|
91
|
+
> https://www.worldometers.info/coronavirus/ via [NovelCOVID/API](https://github.com/novelcovid/api)
|
92
|
+
|
78
93
|
|
79
94
|
## 👨💻 Development
|
80
95
|
|
81
96
|
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.
|
82
97
|
|
83
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
98
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
99
|
+
|
84
100
|
|
85
101
|
## 🤲 Contributing
|
86
102
|
|
87
|
-
There are multiple areas in this repo that can be improved
|
103
|
+
There are multiple areas in this repo that can be improved or use some refactoring(there's a lot to be refactorted in fact!). For that reason, bug reports and pull requests are welcome! 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).
|
88
104
|
|
89
105
|
|
90
106
|
## 🔖 License
|
data/{bin/kovid → exe/covid}
RENAMED
File without changes
|
data/exe/kovid
ADDED
data/kovid.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Emmanuel Hayford"]
|
7
7
|
spec.email = ["siawmensah@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary = %q{
|
10
|
-
spec.description = %q{A CLI
|
9
|
+
spec.summary = %q{A CLI to fetch and compare the 2019 coronavirus pandemic statistics.}
|
10
|
+
spec.description = %q{A CLI to fetch and compare the 2019 coronavirus pandemic statistics.}
|
11
11
|
spec.homepage = "https://github.com/siaw23/kovid"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
@@ -23,15 +23,17 @@ 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 = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
spec.add_dependency "thor"
|
31
31
|
spec.add_dependency "terminal-table"
|
32
32
|
spec.add_dependency "typhoeus"
|
33
|
+
spec.add_dependency "colorize"
|
33
34
|
|
34
35
|
spec.add_development_dependency "pry"
|
35
36
|
spec.add_development_dependency "cucumber"
|
36
37
|
spec.add_development_dependency "aruba"
|
38
|
+
spec.add_development_dependency "simplecov"
|
37
39
|
end
|
data/lib/kovid.rb
CHANGED
@@ -1,8 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kovid/version'
|
4
|
-
require 'kovid/
|
4
|
+
require 'kovid/request'
|
5
5
|
|
6
6
|
module Kovid
|
7
7
|
class Error < StandardError; end
|
8
|
+
|
9
|
+
module_function
|
10
|
+
|
11
|
+
def whatis
|
12
|
+
'Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).'
|
13
|
+
end
|
14
|
+
|
15
|
+
def country(name)
|
16
|
+
Kovid::Request.by_country(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def country_full(name)
|
20
|
+
Kovid::Request.by_country_full(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def state(state)
|
24
|
+
Kovid::Request.state(state)
|
25
|
+
end
|
26
|
+
|
27
|
+
def country_comparison(names_array)
|
28
|
+
Kovid::Request.by_country_comparison(names_array)
|
29
|
+
end
|
30
|
+
|
31
|
+
def country_comparison_full(names_array)
|
32
|
+
Kovid::Request.by_country_comparison_full(names_array)
|
33
|
+
end
|
34
|
+
|
35
|
+
def cases
|
36
|
+
Kovid::Request.cases
|
37
|
+
end
|
8
38
|
end
|
data/lib/kovid/cache.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'typhoeus'
|
4
|
+
|
5
|
+
module Kovid
|
6
|
+
class Cache
|
7
|
+
def initialize
|
8
|
+
@memory = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(request)
|
12
|
+
@memory[request]
|
13
|
+
end
|
14
|
+
|
15
|
+
def set(request, response)
|
16
|
+
@memory[request] = response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Typhoeus::Config.cache = Cache.new
|
21
|
+
end
|
data/lib/kovid/cli.rb
CHANGED
@@ -5,34 +5,43 @@ require 'kovid'
|
|
5
5
|
|
6
6
|
module Kovid
|
7
7
|
class CLI < Thor
|
8
|
+
FULL_FLAG = %w[-f --full].freeze
|
9
|
+
|
8
10
|
desc 'define', 'Defines COVID-19'
|
9
11
|
def define
|
10
|
-
Kovid
|
12
|
+
puts Kovid.whatis
|
11
13
|
end
|
12
14
|
|
13
|
-
desc 'check COUNTRY', 'Returns reported data on provided country'
|
15
|
+
desc 'check COUNTRY or check "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid check "hong kong".'
|
14
16
|
method_option :full, aliases: '-f'
|
15
17
|
def check(name)
|
16
18
|
if options[:full]
|
17
|
-
Kovid
|
19
|
+
puts Kovid.country_full(name)
|
18
20
|
else
|
19
|
-
Kovid
|
21
|
+
puts Kovid.country(name)
|
20
22
|
end
|
21
23
|
end
|
24
|
+
desc 'country COUNTRY or country "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid country "hong kong".'
|
25
|
+
alias country check
|
26
|
+
|
27
|
+
desc 'state STATE', 'Return reported data on provided state.'
|
28
|
+
def state(state)
|
29
|
+
puts Kovid.state(state)
|
30
|
+
end
|
22
31
|
|
23
|
-
desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries'
|
32
|
+
desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries.'
|
24
33
|
def compare(*name)
|
25
|
-
if name
|
34
|
+
if FULL_FLAG.include?(name.fetch(-1))
|
26
35
|
name = name.reverse.drop(1).reverse
|
27
|
-
Kovid
|
36
|
+
puts Kovid.country_comparison_full(name)
|
28
37
|
else
|
29
|
-
Kovid
|
38
|
+
puts Kovid.country_comparison(name)
|
30
39
|
end
|
31
40
|
end
|
32
41
|
|
33
|
-
desc 'cases', 'Returns total number of cases, deaths and recoveries'
|
42
|
+
desc 'cases', 'Returns total number of cases, deaths and recoveries.'
|
34
43
|
def cases
|
35
|
-
Kovid
|
44
|
+
puts Kovid.cases
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
class String
|
6
|
+
def paint_white
|
7
|
+
colorize(:white).colorize(background: :black).colorize(mode: :bold)
|
8
|
+
end
|
9
|
+
|
10
|
+
def paint_red
|
11
|
+
colorize(:red).colorize(background: :black).colorize(mode: :bold)
|
12
|
+
end
|
13
|
+
|
14
|
+
def paint_green
|
15
|
+
colorize(:green).colorize(background: :black).colorize(mode: :bold)
|
16
|
+
end
|
17
|
+
|
18
|
+
def paint_yellow
|
19
|
+
colorize(:yellow).colorize(background: :black).colorize(mode: :bold)
|
20
|
+
end
|
21
|
+
end
|
data/lib/kovid/request.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'typhoeus'
|
4
3
|
require 'json'
|
5
4
|
require_relative 'tablelize'
|
5
|
+
require_relative 'cache'
|
6
6
|
|
7
7
|
module Kovid
|
8
8
|
class Request
|
9
9
|
BASE_URL = 'https://corona.lmao.ninja'
|
10
10
|
|
11
11
|
class << self
|
12
|
-
require 'pry'
|
13
12
|
def by_country(country_name)
|
14
13
|
response = fetch_country(country_name)
|
15
14
|
|
@@ -26,6 +25,12 @@ module Kovid
|
|
26
25
|
no_case_in(country_name)
|
27
26
|
end
|
28
27
|
|
28
|
+
def state(state)
|
29
|
+
response = fetch_state(state)
|
30
|
+
|
31
|
+
Kovid::Tablelize.full_state_table(response)
|
32
|
+
end
|
33
|
+
|
29
34
|
def by_country_comparison(list)
|
30
35
|
array = fetch_countries(list)
|
31
36
|
Kovid::Tablelize.compare_countries_table(array)
|
@@ -40,17 +45,16 @@ module Kovid
|
|
40
45
|
path = '/all'
|
41
46
|
fetch_url = BASE_URL + path
|
42
47
|
|
43
|
-
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl:
|
48
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 900).response_body)
|
49
|
+
|
44
50
|
Kovid::Tablelize.cases(response)
|
45
51
|
end
|
46
52
|
|
47
53
|
private
|
48
54
|
|
49
55
|
def no_case_in(country)
|
50
|
-
rows = []
|
51
|
-
|
52
|
-
table = Terminal::Table.new headings: [country.capitalize.to_s], rows: rows
|
53
|
-
puts table
|
56
|
+
rows = [["Thankfully, there are no reported cases in #{country.capitalize}!"]]
|
57
|
+
Terminal::Table.new headings: [country.capitalize.to_s], rows: rows
|
54
58
|
end
|
55
59
|
|
56
60
|
def fetch_countries(list)
|
@@ -60,7 +64,7 @@ module Kovid
|
|
60
64
|
path = "/countries/#{country}"
|
61
65
|
fetch_url = BASE_URL + path
|
62
66
|
|
63
|
-
array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl:
|
67
|
+
array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 900).response_body)
|
64
68
|
end
|
65
69
|
|
66
70
|
array = array.sort_by { |json| -json['cases'] }
|
@@ -70,7 +74,16 @@ module Kovid
|
|
70
74
|
path = "/countries/#{country_name}"
|
71
75
|
fetch_url = BASE_URL + path
|
72
76
|
|
73
|
-
JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl:
|
77
|
+
JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 900).response_body)
|
78
|
+
end
|
79
|
+
|
80
|
+
def fetch_state(state)
|
81
|
+
path = '/states'
|
82
|
+
fetch_url = BASE_URL + path
|
83
|
+
|
84
|
+
states_array = JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 900).response_body)
|
85
|
+
|
86
|
+
states_array.select { |state_name| state_name['state'] == state.split.map(&:capitalize).join(' ') }.first
|
74
87
|
end
|
75
88
|
end
|
76
89
|
end
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -1,26 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'terminal-table'
|
4
|
+
require_relative 'painter'
|
4
5
|
|
5
6
|
module Kovid
|
6
7
|
class Tablelize
|
7
8
|
class << self
|
9
|
+
CASES_DEATHS_RECOVERED = [
|
10
|
+
'Cases'.paint_white,
|
11
|
+
'Deaths'.paint_red,
|
12
|
+
'Recovered'.paint_green
|
13
|
+
].freeze
|
14
|
+
|
8
15
|
def country_table(data)
|
9
|
-
headings =
|
10
|
-
rows = []
|
11
|
-
|
12
|
-
|
16
|
+
headings = CASES_DEATHS_RECOVERED
|
17
|
+
rows = [[data['cases'], data['deaths'], data['recovered']]]
|
18
|
+
|
19
|
+
Terminal::Table.new(title: data['country'], headings: headings, rows: rows)
|
13
20
|
end
|
14
21
|
|
15
22
|
def full_country_table(data)
|
16
23
|
headings = [
|
17
|
-
'Cases',
|
18
|
-
'Deaths',
|
19
|
-
'Recovered',
|
20
|
-
'Cases Today',
|
21
|
-
'Deaths Today',
|
22
|
-
'Critical',
|
23
|
-
'Cases/Million'
|
24
|
+
'Cases'.paint_white,
|
25
|
+
'Deaths'.paint_red,
|
26
|
+
'Recovered'.paint_green,
|
27
|
+
'Cases Today'.paint_white,
|
28
|
+
'Deaths Today'.paint_red,
|
29
|
+
'Critical'.paint_yellow,
|
30
|
+
'Cases/Million'.paint_white
|
24
31
|
]
|
25
32
|
|
26
33
|
rows = []
|
@@ -33,33 +40,55 @@ module Kovid
|
|
33
40
|
data['critical'],
|
34
41
|
data['casesPerOneMillion']
|
35
42
|
]
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
Terminal::Table.new(title: data['country'],
|
44
|
+
headings: headings,
|
45
|
+
rows: rows)
|
46
|
+
end
|
47
|
+
|
48
|
+
def full_state_table(state)
|
49
|
+
headings = [
|
50
|
+
'Cases'.paint_white,
|
51
|
+
'Cases Today',
|
52
|
+
'Deaths'.paint_red,
|
53
|
+
'Deaths Today'.paint_red,
|
54
|
+
'Reovered'.paint_green,
|
55
|
+
'Active'.paint_yellow
|
56
|
+
]
|
57
|
+
|
58
|
+
rows = []
|
59
|
+
rows << [state['cases'], state['todayCases'], state['deaths'], state['todayDeaths'], state['recovered'], state['active']]
|
60
|
+
Terminal::Table.new(title: state['state'], headings: headings, rows: rows)
|
39
61
|
end
|
40
62
|
|
41
63
|
def compare_countries_table(data)
|
42
|
-
headings =
|
64
|
+
headings = [
|
65
|
+
'Country'.paint_white,
|
66
|
+
'Cases'.paint_white,
|
67
|
+
'Deaths'.paint_red,
|
68
|
+
'Recovered'.paint_green
|
69
|
+
]
|
70
|
+
|
43
71
|
rows = []
|
44
72
|
|
45
73
|
data.each do |country|
|
46
74
|
rows << [country['country'], country['cases'], country['deaths'], country['recovered']]
|
47
75
|
end
|
48
76
|
|
49
|
-
|
77
|
+
Terminal::Table.new(headings: headings, rows: rows)
|
50
78
|
end
|
51
79
|
|
52
80
|
def compare_countries_table_full(data)
|
53
81
|
headings = [
|
54
|
-
'Country',
|
55
|
-
'Cases',
|
56
|
-
'Deaths',
|
57
|
-
'Recovered',
|
58
|
-
'Cases Today',
|
59
|
-
'Deaths Today',
|
60
|
-
'Critical',
|
61
|
-
'Cases/Million'
|
82
|
+
'Country'.paint_white,
|
83
|
+
'Cases'.paint_white,
|
84
|
+
'Deaths'.paint_red,
|
85
|
+
'Recovered'.paint_green,
|
86
|
+
'Cases Today'.paint_white,
|
87
|
+
'Deaths Today'.paint_red,
|
88
|
+
'Critical'.paint_yellow,
|
89
|
+
'Cases/Million'.paint_white
|
62
90
|
]
|
91
|
+
|
63
92
|
rows = []
|
64
93
|
|
65
94
|
data.each do |country|
|
@@ -75,16 +104,14 @@ module Kovid
|
|
75
104
|
]
|
76
105
|
end
|
77
106
|
|
78
|
-
|
107
|
+
Terminal::Table.new(headings: headings, rows: rows)
|
79
108
|
end
|
80
109
|
|
81
110
|
def cases(cases)
|
82
|
-
headings =
|
83
|
-
|
84
|
-
rows = []
|
111
|
+
headings = CASES_DEATHS_RECOVERED
|
112
|
+
rows = [[cases['cases'], cases['deaths'], cases['recovered']]]
|
85
113
|
|
86
|
-
|
87
|
-
puts Terminal::Table.new(title: 'Total # of incidents', headings: headings, rows: rows)
|
114
|
+
Terminal::Table.new(title: 'Total # of incidents', headings: headings, rows: rows)
|
88
115
|
end
|
89
116
|
end
|
90
117
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,13 +108,26 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
|
-
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A CLI to fetch and compare the 2019 coronavirus pandemic statistics.
|
98
126
|
email:
|
99
127
|
- siawmensah@gmail.com
|
100
128
|
executables:
|
101
|
-
-
|
129
|
+
- covid
|
102
130
|
- kovid
|
103
|
-
- setup
|
104
131
|
extensions: []
|
105
132
|
extra_rdoc_files: []
|
106
133
|
files:
|
@@ -114,12 +141,14 @@ files:
|
|
114
141
|
- README.md
|
115
142
|
- Rakefile
|
116
143
|
- bin/console
|
117
|
-
- bin/kovid
|
118
144
|
- bin/setup
|
145
|
+
- exe/covid
|
146
|
+
- exe/kovid
|
119
147
|
- kovid.gemspec
|
120
148
|
- lib/kovid.rb
|
149
|
+
- lib/kovid/cache.rb
|
121
150
|
- lib/kovid/cli.rb
|
122
|
-
- lib/kovid/
|
151
|
+
- lib/kovid/painter.rb
|
123
152
|
- lib/kovid/request.rb
|
124
153
|
- lib/kovid/tablelize.rb
|
125
154
|
- lib/kovid/version.rb
|
@@ -149,6 +178,5 @@ requirements: []
|
|
149
178
|
rubygems_version: 3.1.2
|
150
179
|
signing_key:
|
151
180
|
specification_version: 4
|
152
|
-
summary:
|
153
|
-
numbers."
|
181
|
+
summary: A CLI to fetch and compare the 2019 coronavirus pandemic statistics.
|
154
182
|
test_files: []
|
data/lib/kovid/nineteen.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'request'
|
4
|
-
|
5
|
-
module Kovid
|
6
|
-
class Nineteen
|
7
|
-
class << self
|
8
|
-
def whatis
|
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
|
16
|
-
end
|
17
|
-
|
18
|
-
def country(name)
|
19
|
-
puts Kovid::Request.by_country(name)
|
20
|
-
end
|
21
|
-
|
22
|
-
def country_full(name)
|
23
|
-
puts Kovid::Request.by_country_full(name)
|
24
|
-
end
|
25
|
-
|
26
|
-
def country_comparison(name)
|
27
|
-
puts Kovid::Request.by_country_comparison(name)
|
28
|
-
end
|
29
|
-
|
30
|
-
def country_comparison_full(name)
|
31
|
-
puts Kovid::Request.by_country_comparison_full(name)
|
32
|
-
end
|
33
|
-
|
34
|
-
def cases
|
35
|
-
puts Kovid::Request.cases
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|