kovid 0.1.9 β 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 +11 -1
- data/kovid.gemspec +1 -0
- data/lib/kovid.rb +1 -0
- data/lib/kovid/cli.rb +11 -6
- data/lib/kovid/nineteen.rb +12 -14
- data/lib/kovid/request.rb +16 -2
- data/lib/kovid/tablelize.rb +14 -7
- data/lib/kovid/version.rb +1 -1
- metadata +15 -1
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
@@ -32,6 +32,9 @@ You can run `kovid --help` to see full list of available commands.
|
|
32
32
|
* `kovid check ghana`
|
33
33
|
* `kovid check ghana -f` OR `kovid check ghana --full`
|
34
34
|
|
35
|
+
πΊπΈ You can fetch US state-specific data with:
|
36
|
+
* `kovid state colorado` OR `kovid state "north carolina"`
|
37
|
+
|
35
38
|
**Comparing**
|
36
39
|
* `kovid compare ghana poland` (sorts by cases DESC)
|
37
40
|
* `kovid compare ghana poland -f` OR `kovid compare ghana poland --full` (sorts by cases DESC)
|
@@ -70,6 +73,12 @@ To compare a countries stats with a full table:
|
|
70
73
|
|
71
74
|
![kovid](https://i.gyazo.com/7ce86c5e93d549e1412fb6104a1d7877.png "Covid data.")
|
72
75
|
|
76
|
+
To fetch state-specific data run:
|
77
|
+
|
78
|
+
`kovid state colorado`
|
79
|
+
|
80
|
+
![kovid](https://i.gyazo.com/133046d9d31c20a8bad1a05b46ba4d3e.png "Covid data.")
|
81
|
+
|
73
82
|
To check for total figures:
|
74
83
|
|
75
84
|
`kovid cases`
|
@@ -80,7 +89,8 @@ To check for total figures:
|
|
80
89
|
|
81
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.
|
82
91
|
|
83
|
-
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
|
+
|
84
94
|
|
85
95
|
## π€² Contributing
|
86
96
|
|
data/kovid.gemspec
CHANGED
data/lib/kovid.rb
CHANGED
data/lib/kovid/cli.rb
CHANGED
@@ -7,32 +7,37 @@ module Kovid
|
|
7
7
|
class CLI < Thor
|
8
8
|
desc 'define', 'Defines COVID-19'
|
9
9
|
def define
|
10
|
-
Kovid::Nineteen.whatis
|
10
|
+
puts Kovid::Nineteen.whatis
|
11
11
|
end
|
12
12
|
|
13
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 'state STATE', 'Return reported data on provided state'
|
24
|
+
def state(state)
|
25
|
+
puts Kovid::Nineteen.state(state)
|
26
|
+
end
|
27
|
+
|
23
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,33 +6,31 @@ module Kovid
|
|
6
6
|
class Nineteen
|
7
7
|
class << self
|
8
8
|
def whatis
|
9
|
-
|
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
|
9
|
+
'Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).'
|
16
10
|
end
|
17
11
|
|
18
12
|
def country(name)
|
19
|
-
|
13
|
+
Kovid::Request.by_country(name)
|
20
14
|
end
|
21
15
|
|
22
16
|
def country_full(name)
|
23
|
-
|
17
|
+
Kovid::Request.by_country_full(name)
|
24
18
|
end
|
25
19
|
|
26
|
-
def
|
27
|
-
|
20
|
+
def state(state)
|
21
|
+
Kovid::Request.state(state)
|
28
22
|
end
|
29
23
|
|
30
|
-
def
|
31
|
-
|
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)
|
32
30
|
end
|
33
31
|
|
34
32
|
def cases
|
35
|
-
|
33
|
+
Kovid::Request.cases
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
data/lib/kovid/request.rb
CHANGED
@@ -9,7 +9,6 @@ module Kovid
|
|
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)
|
@@ -50,7 +55,7 @@ module Kovid
|
|
50
55
|
rows = []
|
51
56
|
rows << ["Thankfully, there are no reported cases in #{country.capitalize}!"]
|
52
57
|
table = Terminal::Table.new headings: [country.capitalize.to_s], rows: rows
|
53
|
-
|
58
|
+
table
|
54
59
|
end
|
55
60
|
|
56
61
|
def fetch_countries(list)
|
@@ -72,6 +77,15 @@ module Kovid
|
|
72
77
|
|
73
78
|
JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
74
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
|
88
|
+
end
|
75
89
|
end
|
76
90
|
end
|
77
91
|
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,7 +53,7 @@ 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)
|
@@ -75,7 +82,7 @@ module Kovid
|
|
75
82
|
]
|
76
83
|
end
|
77
84
|
|
78
|
-
|
85
|
+
Terminal::Table.new(headings: headings, rows: rows)
|
79
86
|
end
|
80
87
|
|
81
88
|
def cases(cases)
|
@@ -84,7 +91,7 @@ module Kovid
|
|
84
91
|
rows = []
|
85
92
|
|
86
93
|
rows << [cases['cases'], cases['deaths'], cases['recovered']]
|
87
|
-
|
94
|
+
Terminal::Table.new(title: 'Total # of incidents', headings: headings, rows: rows)
|
88
95
|
end
|
89
96
|
end
|
90
97
|
end
|
data/lib/kovid/version.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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
@@ -94,6 +94,20 @@ 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
|