covid19 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +34 -2
- data/README.md +19 -16
- data/VERSION.txt +1 -0
- data/covid19.gemspec +4 -2
- data/exe/covid19 +198 -56
- data/lib/covid19.rb +118 -15
- data/lib/covid19/version.rb +1 -1
- data/testing/covid19 +199 -56
- metadata +36 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54c2f063cc71dc3e9ec63ab9ddd9eea2624200bd9fbb990d1bb39f10b895f237
|
4
|
+
data.tar.gz: b02df5941fd7a738bd8010d3c2e9f9d14c753481b4bce702f2a516bedf9b73f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e992490f053504185258c64c83b54f4316f5d6d28b38a9971741651fa20c83448783525f2059f26160cf30e4ac4d117ee7aa8efcf579b7d37b00e98bc24b6a7f
|
7
|
+
data.tar.gz: 54f49fa6f69e441628b66030d65c9e071178dbb393b4c0b8e597d79b129fad43bebc800ef2ae5183be4118776e084934c0702618437ca86e9333c6ea98c9ce56
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.5
|
3
3
|
|
4
|
+
Layout/CaseIndentation:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Layout/HashAlignment:
|
8
|
+
EnforcedHashRocketStyle: table
|
9
|
+
|
4
10
|
Layout/IndentationWidth:
|
5
11
|
Width: 4
|
6
12
|
|
7
13
|
Layout/LineLength:
|
8
14
|
Enabled: false
|
9
15
|
|
16
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
17
|
+
Enabled: false
|
18
|
+
|
10
19
|
Layout/SpaceAroundOperators:
|
11
20
|
Enabled: false
|
12
21
|
|
@@ -28,9 +37,18 @@ Metrics/MethodLength:
|
|
28
37
|
Metrics/PerceivedComplexity:
|
29
38
|
Enabled: false
|
30
39
|
|
40
|
+
Style/FormatString:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/FormatStringToken:
|
44
|
+
Enabled: false
|
45
|
+
|
31
46
|
Style/FrozenStringLiteralComment:
|
32
47
|
Enabled: false
|
33
48
|
|
49
|
+
Style/GlobalVars:
|
50
|
+
Enabled: false
|
51
|
+
|
34
52
|
Style/HashEachMethods:
|
35
53
|
Enabled: false
|
36
54
|
|
@@ -58,5 +76,8 @@ Style/RedundantReturn:
|
|
58
76
|
Style/SpecialGlobalVars:
|
59
77
|
Enabled: false
|
60
78
|
|
79
|
+
Style/StringLiterals:
|
80
|
+
Enabled: false
|
81
|
+
|
61
82
|
Style/WordArray:
|
62
83
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -5,9 +5,41 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
|
6
6
|
This changelog was automatically generated using [Caretaker](https://github.com/WolfAtheneum/covid19) by [Wolf Software](https://github.com/WolfSoftware)
|
7
7
|
|
8
|
-
### [
|
8
|
+
### [v1.0.1](https://github.com/WolfAtheneum/covid19/compare/v1.0.0...v1.0.1)
|
9
9
|
|
10
|
-
|
10
|
+
> Released on June, 15th 2020
|
11
|
+
|
12
|
+
- Minor tweak to change 'cases per million' to an integer instead of a float [`[84fd86f]`](https://github.com/WolfAtheneum/covid19/commit/84fd86fc25b835a8f6a04fede5b3c05605f14ac3) [`[TGWolf]`](https://github.com/TGWolf)
|
13
|
+
|
14
|
+
- Update the description in the gemspec [`[135f79c]`](https://github.com/WolfAtheneum/covid19/commit/135f79c12e32566a79319ba5c3a2beea39b5882d) [`[TGWolf]`](https://github.com/TGWolf)
|
15
|
+
|
16
|
+
### [v1.0.0](https://github.com/WolfAtheneum/covid19/compare/v0.1.3...v1.0.0)
|
17
|
+
|
18
|
+
> Released on June, 14th 2020
|
19
|
+
|
20
|
+
- Update the gem version [`[8e8c619]`](https://github.com/WolfAtheneum/covid19/commit/8e8c619b856f360c5d02aadcf8954096695a1d24) [`[TGWolf]`](https://github.com/TGWolf)
|
21
|
+
|
22
|
+
- Complete rewrite using a new faster API [`[2bed745]`](https://github.com/WolfAtheneum/covid19/commit/2bed7459acdee4036c1f31e585cf65fdee704d4e) [`[TGWolf]`](https://github.com/TGWolf)
|
23
|
+
|
24
|
+
### [v0.1.3](https://github.com/WolfAtheneum/covid19/compare/v0.1.2...v0.1.3)
|
25
|
+
|
26
|
+
> Released on March, 26th 2020
|
27
|
+
|
28
|
+
- Minor tweak to the output death rate percentage [`[24fdf44]`](https://github.com/WolfAtheneum/covid19/commit/24fdf44a1eb22499b47044e580d9a52ff298bfc0) [`[TGWolf]`](https://github.com/TGWolf)
|
29
|
+
|
30
|
+
### [v0.1.2](https://github.com/WolfAtheneum/covid19/compare/v0.1.0...v0.1.2)
|
31
|
+
|
32
|
+
> Released on March, 23rd 2020
|
33
|
+
|
34
|
+
- Add the new code to the binary as it was only added to the testing binary [`[dc3cce4]`](https://github.com/WolfAtheneum/covid19/commit/dc3cce4d8e0d61efea2a49271bba43b17ca42103) [`[TGWolf]`](https://github.com/TGWolf)
|
35
|
+
|
36
|
+
- Add a death rate as a percentage of confirmed cases [`[348efbf]`](https://github.com/WolfAtheneum/covid19/commit/348efbf2c1ca5bdffbd369595c670acc7cadeaf8) [`[TGWolf]`](https://github.com/TGWolf)
|
37
|
+
|
38
|
+
### [v0.1.0](https://github.com/WolfAtheneum/covid19/releases/v0.1.0)
|
39
|
+
|
40
|
+
> Released on March, 19th 2020
|
41
|
+
|
42
|
+
- Fix links and other travis issues [`[95c1073]`](https://github.com/WolfAtheneum/covid19/commit/95c1073fb1043515bbf150e99d080a96f7f58bd2) [`[TGWolf]`](https://github.com/TGWolf)
|
11
43
|
|
12
44
|
- Initial commit [`[e83777b]`](https://github.com/WolfAtheneum/covid19/commit/e83777b4b3462b5d31f507a86de3448478d7adb4) [`[TGWolf]`](https://github.com/TGWolf)
|
13
45
|
|
data/README.md
CHANGED
@@ -33,28 +33,22 @@ gem install covid19
|
|
33
33
|
|
34
34
|
## Usage
|
35
35
|
|
36
|
-
Get the latest
|
36
|
+
Get the latest stats by in summary form and broken down country by country.
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
Covid19.
|
39
|
+
Covid19.latest_stats_all
|
40
40
|
```
|
41
41
|
|
42
|
-
Get
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
Covid19.latest_stats_split_by_country
|
46
|
-
```
|
47
|
-
|
48
|
-
Find case data by country code with an optional argument to include timelines:
|
42
|
+
Get the latest stats by in summary form.
|
49
43
|
|
50
44
|
```ruby
|
51
|
-
Covid19.
|
45
|
+
Covid19.latest_stats_global
|
52
46
|
```
|
53
47
|
|
54
|
-
|
48
|
+
Get case data for all locations with reported cases:
|
55
49
|
|
56
50
|
```ruby
|
57
|
-
Covid19.
|
51
|
+
Covid19.latest_stats_split_by_country
|
58
52
|
```
|
59
53
|
|
60
54
|
## Error Handling
|
@@ -68,10 +62,19 @@ The gem also comes with a command line tool called covid19.
|
|
68
62
|
```
|
69
63
|
Usage: covid19
|
70
64
|
-h, --help Display this screen
|
71
|
-
-s, --
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
65
|
+
-s, --summary Show a summary of the totals [Default]
|
66
|
+
-l, --latest Show the latest (todays) totals split by country (same as -t)
|
67
|
+
-t, --today Show the latest (todays) totals split by country (same as -l)
|
68
|
+
-T, --totals Show the full totals split by country
|
69
|
+
|
70
|
+
Coloumn Sorting Options:
|
71
|
+
-c, --confirmed Order the output based on 'Confirmed' column
|
72
|
+
-r, --recovered Order the output based on 'Recovered' column
|
73
|
+
-d, --deaths Order the output based on 'Deaths' column
|
74
|
+
-a, --active Order the output based on 'Active' column
|
75
|
+
-D, --death-rate Order the output based on 'Death Rate' column
|
76
|
+
-R, --recovery-rate Order the output based on 'Recovery Rate' column
|
77
|
+
-C, --cases-per-million Order the output based on 'Cases P/M' column
|
75
78
|
|
76
79
|
```
|
77
80
|
|
data/VERSION.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
data/covid19.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Tim Gurney aka Wolf']
|
9
9
|
spec.email = ['wolf@tgwolf.com']
|
10
10
|
|
11
|
-
spec.summary = 'A wrapper for the coronavirus API at https://
|
12
|
-
spec.description = 'A wrapper for the coronavirus API at https://
|
11
|
+
spec.summary = 'A wrapper for the coronavirus API at https://corona-api.com/.'
|
12
|
+
spec.description = 'A wrapper for the coronavirus API at https://corona-api.com/.'
|
13
13
|
spec.homepage = 'https://github.com/WolfAtheneum/covid19'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.required_ruby_version = '>= 2.5'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 2'
|
25
|
+
spec.add_development_dependency 'colorize', '~> 0.8'
|
25
26
|
spec.add_development_dependency 'rake', '~> 13.0'
|
26
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
28
|
spec.add_development_dependency 'terminal-table', '~> 1.8'
|
28
29
|
|
30
|
+
spec.add_runtime_dependency 'colorize', '~> 0.8'
|
29
31
|
spec.add_runtime_dependency 'terminal-table', '~> 1.8'
|
30
32
|
end
|
data/exe/covid19
CHANGED
@@ -2,69 +2,187 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift('./lib')
|
4
4
|
|
5
|
+
require 'colorize'
|
5
6
|
require 'optparse'
|
6
7
|
require 'covid19'
|
7
8
|
require 'terminal-table'
|
8
9
|
|
9
10
|
# -------------------------------------------------------------------------------- #
|
10
|
-
#
|
11
|
+
# Global Variables #
|
11
12
|
# -------------------------------------------------------------------------------- #
|
12
|
-
#
|
13
|
+
# A simple set of global variables to avoid having to do multiple string compares #
|
14
|
+
# as one typo can cause weird things to happen. #
|
13
15
|
# -------------------------------------------------------------------------------- #
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
$_confirmed = 1
|
18
|
+
$_recovered = 2
|
19
|
+
$_deaths = 3
|
20
|
+
$_active = 4
|
21
|
+
$_death_rate = 5
|
22
|
+
$_recovery_rate = 6
|
23
|
+
$_cases_pm = 7
|
24
|
+
|
25
|
+
# -------------------------------------------------------------------------------- #
|
26
|
+
# Get Hash Value #
|
27
|
+
# -------------------------------------------------------------------------------- #
|
28
|
+
# Simple wrapper to locate a value from a hash and handle error states. #
|
29
|
+
# -------------------------------------------------------------------------------- #
|
30
|
+
|
31
|
+
def get_hash_value(hash, name, default_val = 0)
|
32
|
+
return default_val unless hash.is_a?(Hash)
|
33
|
+
|
34
|
+
return hash.fetch(name, default_val)
|
35
|
+
end
|
36
|
+
|
37
|
+
# -------------------------------------------------------------------------------- #
|
38
|
+
# Commify #
|
39
|
+
# -------------------------------------------------------------------------------- #
|
40
|
+
# Simple wrapper to make numbers a little more human readable. #
|
41
|
+
# -------------------------------------------------------------------------------- #
|
42
|
+
|
43
|
+
def commify(number)
|
44
|
+
return number.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
|
45
|
+
end
|
46
|
+
|
47
|
+
# -------------------------------------------------------------------------------- #
|
48
|
+
# Add Heading #
|
49
|
+
# -------------------------------------------------------------------------------- #
|
50
|
+
# Simple wrapper to generate a heading entry with optional alignment override. #
|
51
|
+
# -------------------------------------------------------------------------------- #
|
52
|
+
|
53
|
+
def add_heading(name, alignment = :center)
|
54
|
+
return { :value => name, :alignment => alignment }
|
55
|
+
end
|
56
|
+
|
57
|
+
# -------------------------------------------------------------------------------- #
|
58
|
+
# Show Summary Data #
|
59
|
+
# -------------------------------------------------------------------------------- #
|
60
|
+
# Create a nice table view of the latest global statistics. #
|
61
|
+
# -------------------------------------------------------------------------------- #
|
62
|
+
|
63
|
+
def show_summary_data(results)
|
64
|
+
title = 'Global Statistics Summary'
|
65
|
+
headings = []
|
66
|
+
rows = []
|
67
|
+
|
68
|
+
headings << ''
|
69
|
+
headings << add_heading('Today')
|
70
|
+
headings << add_heading('Total')
|
71
|
+
|
72
|
+
rows << [ 'Confirmed Cases', commify(get_hash_value(results, 'ConfirmedToday')), commify(get_hash_value(results, 'ConfirmedTotal')) ]
|
73
|
+
rows << [ 'Recovered', commify(get_hash_value(results, 'RecoveredToday')), commify(get_hash_value(results, 'RecoveredTotal')) ]
|
74
|
+
rows << [ 'Deaths', commify(get_hash_value(results, 'DeathsToday')), commify(get_hash_value(results, 'DeathsTotal')) ]
|
75
|
+
rows << [ 'Active', '', commify(get_hash_value(results, 'ActiveTotal')) ]
|
76
|
+
|
77
|
+
table = Terminal::Table.new :title => title.colorize(:light_green), :headings => headings, :rows => rows, :style => { :padding_left => 2, :padding_right => 2 }
|
78
|
+
table.align_column(1, :right)
|
79
|
+
table.align_column(2, :right)
|
80
|
+
puts table
|
21
81
|
end
|
22
82
|
|
23
83
|
# -------------------------------------------------------------------------------- #
|
24
|
-
#
|
84
|
+
# Show Todays Totals By Country #
|
25
85
|
# -------------------------------------------------------------------------------- #
|
26
|
-
# Create a nice table view of
|
86
|
+
# Create a nice table view of todays totals available per country. #
|
27
87
|
# -------------------------------------------------------------------------------- #
|
28
|
-
def format_latest_country_stats(results, options = {})
|
29
|
-
processed = {}
|
30
88
|
|
31
|
-
|
32
|
-
|
89
|
+
def show_todays_totals_by_country(results, options = {})
|
90
|
+
title = 'Latest Totals by Country'
|
91
|
+
headings = []
|
92
|
+
rows = []
|
33
93
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
94
|
+
headings << add_heading('Country', :left)
|
95
|
+
headings << add_heading('Confirmed')
|
96
|
+
headings << add_heading('Recovered')
|
97
|
+
headings << add_heading('Deaths')
|
98
|
+
|
99
|
+
unless results.nil? && results.length.positive?
|
100
|
+
case options[:order]
|
101
|
+
when $_confirmed
|
102
|
+
results = results.sort_by { |k| k['ConfirmedToday'] }.reverse
|
103
|
+
title += ' Ordered by \'Confirmed\''
|
104
|
+
when $_recovered
|
105
|
+
results = results.sort_by { |k| k['RecoveredToday'] }.reverse
|
106
|
+
title += ' Ordered by \'Recovered\''
|
107
|
+
when $_deaths
|
108
|
+
results = results.sort_by { |k| k['DeathsToday'] }.reverse
|
109
|
+
title += ' Ordered by \'Deaths\''
|
110
|
+
else
|
111
|
+
results = results.sort_by { |k| k['Country'] }
|
42
112
|
end
|
43
|
-
processed[country_code] = { 'country' => item['country'], 'country_code' => country_code, 'id' => item['id'], 'confirmed' => confirmed, 'deaths' => deaths, 'recovered' => recovered }
|
44
|
-
end
|
45
113
|
|
46
|
-
|
47
|
-
|
48
|
-
|
114
|
+
results.each do |value|
|
115
|
+
rows << [ value['Country'], commify(value['ConfirmedToday']), commify(value['RecoveredToday']), commify(value['DeathsToday']) ]
|
116
|
+
end
|
49
117
|
end
|
50
118
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
119
|
+
table = Terminal::Table.new :title => title.colorize(:light_green), :headings => headings, :rows => rows, :style => { :padding_left => 2, :padding_right => 2 }
|
120
|
+
table.align_column(1, :right)
|
121
|
+
table.align_column(2, :right)
|
122
|
+
table.align_column(3, :right)
|
123
|
+
puts table
|
124
|
+
end
|
125
|
+
|
126
|
+
# -------------------------------------------------------------------------------- #
|
127
|
+
# Show Grand Totals By Country #
|
128
|
+
# -------------------------------------------------------------------------------- #
|
129
|
+
# Create a nice table view of the grand totals available per country. #
|
130
|
+
# -------------------------------------------------------------------------------- #
|
131
|
+
|
132
|
+
def show_grand_totals_by_country(results, options = {})
|
133
|
+
title = 'Grand Totals by Country'
|
134
|
+
headings = []
|
135
|
+
rows = []
|
136
|
+
|
137
|
+
headings << add_heading('Country', :left)
|
138
|
+
headings << add_heading('Confirmed')
|
139
|
+
headings << add_heading('Recovered')
|
140
|
+
headings << add_heading('Deaths')
|
141
|
+
headings << add_heading('Active')
|
142
|
+
headings << add_heading('Death Rate')
|
143
|
+
headings << add_heading('Recovery Rate')
|
144
|
+
headings << add_heading('Cases P/M')
|
145
|
+
|
146
|
+
unless results.nil? && results.length.positive?
|
147
|
+
case options[:order]
|
148
|
+
when $_confirmed
|
149
|
+
results = results.sort_by { |k| k['ConfirmedTotal'] }.reverse
|
150
|
+
title += ' Ordered by \'Confirmed\''
|
151
|
+
when $_recovered
|
152
|
+
results = results.sort_by { |k| k['RecoveredTotal'] }.reverse
|
153
|
+
title += ' Ordered by \'Recovered\''
|
154
|
+
when $_deaths
|
155
|
+
results = results.sort_by { |k| k['DeathsTotal'] }.reverse
|
156
|
+
title += ' Ordered by \'Deaths\''
|
157
|
+
when $_active
|
158
|
+
results = results.sort_by { |k| k['ActiveTotal'] }.reverse
|
159
|
+
title += ' Ordered by \'Active\''
|
160
|
+
when $_death_rate
|
161
|
+
results = results.sort_by { |k| k['DeathRate'] }.reverse
|
162
|
+
title += ' Ordered by \'Death Rate\''
|
163
|
+
when $_recovery_rate
|
164
|
+
results = results.sort_by { |k| k['RecoveryRate'] }.reverse
|
165
|
+
title += ' Ordered by \'Recovery Rate\''
|
166
|
+
when $_cases_pm
|
167
|
+
results = results.sort_by { |k| k['CasesPerMillion'] }.reverse
|
168
|
+
title += ' Ordered by \'Cases Per Million\''
|
169
|
+
else
|
170
|
+
results = results.sort_by { |k| k['Country'] }
|
171
|
+
end
|
55
172
|
|
56
|
-
|
57
|
-
|
58
|
-
|
173
|
+
results.each do |value|
|
174
|
+
rows << [ value['Country'], commify(value['ConfirmedTotal']), commify(value['RecoveredTotal']), commify(value['DeathsTotal']), commify(value['ActiveTotal']), "%.2f %%" % value['DeathRate'], "%.2f %%" % value['RecoveryRate'], commify(value['CasesPerMillion']) ]
|
175
|
+
end
|
59
176
|
end
|
60
177
|
|
61
|
-
table = Terminal::Table.new :title =>
|
62
|
-
table.align_column(1, :
|
178
|
+
table = Terminal::Table.new :title => title.colorize(:light_green), :headings => headings, :rows => rows, :style => { :padding_left => 2, :padding_right => 2 }
|
179
|
+
table.align_column(1, :right)
|
63
180
|
table.align_column(2, :right)
|
64
181
|
table.align_column(3, :right)
|
65
182
|
table.align_column(4, :right)
|
66
183
|
table.align_column(5, :right)
|
67
|
-
|
184
|
+
table.align_column(6, :right)
|
185
|
+
table.align_column(7, :right)
|
68
186
|
puts table
|
69
187
|
end
|
70
188
|
|
@@ -76,8 +194,9 @@ end
|
|
76
194
|
|
77
195
|
def get_covid19_stats(options)
|
78
196
|
begin
|
79
|
-
|
80
|
-
|
197
|
+
show_summary_data(Covid19.latest_stats_global) if options[:summary]
|
198
|
+
show_todays_totals_by_country(Covid19.latest_stats_split_by_country, options) if options[:latest]
|
199
|
+
show_grand_totals_by_country(Covid19.latest_stats_split_by_country, options) if options[:totals]
|
81
200
|
rescue StandardError => e
|
82
201
|
puts "Error: #{e}"
|
83
202
|
puts e.backtrace
|
@@ -95,7 +214,7 @@ end
|
|
95
214
|
# -------------------------------------------------------------------------------- #
|
96
215
|
|
97
216
|
def process_arguments
|
98
|
-
options = { :
|
217
|
+
options = { :summary => true }
|
99
218
|
# Enforce the presence of
|
100
219
|
mandatory = %I[]
|
101
220
|
|
@@ -106,27 +225,50 @@ def process_arguments
|
|
106
225
|
puts opts
|
107
226
|
exit(1)
|
108
227
|
end
|
109
|
-
|
110
|
-
|
228
|
+
opts.on('-s', '--summary', 'Show a summary of the totals [Default]') do
|
229
|
+
options[:summary] = true
|
111
230
|
options[:latest] = false
|
231
|
+
options[:totals] = false
|
112
232
|
end
|
113
|
-
|
114
|
-
|
115
|
-
options[:
|
116
|
-
options[:
|
117
|
-
options[:recovered] = false
|
233
|
+
opts.on('-l', '--latest', 'Show the latest (todays) totals split by country (same as -t)') do
|
234
|
+
options[:summary] = false
|
235
|
+
options[:latest] = true
|
236
|
+
options[:totals] = false
|
118
237
|
end
|
119
|
-
|
120
|
-
|
121
|
-
options[:
|
122
|
-
options[:
|
123
|
-
|
238
|
+
opts.on('-t', '--today', 'Show the latest (todays) totals split by country (same as -l)') do
|
239
|
+
options[:summary] = false
|
240
|
+
options[:latest] = true
|
241
|
+
options[:totals] = false
|
242
|
+
end
|
243
|
+
opts.on('-T', '--totals', 'Show the full totals split by country') do
|
244
|
+
options[:summary] = false
|
245
|
+
options[:latest] = false
|
246
|
+
options[:totals] = true
|
124
247
|
end
|
125
248
|
|
126
|
-
opts.
|
127
|
-
|
128
|
-
|
129
|
-
|
249
|
+
opts.separator('')
|
250
|
+
opts.separator('Coloumn Sorting Options:')
|
251
|
+
|
252
|
+
opts.on('-c', '--confirmed', 'Order the output based on \'Confirmed\' column') do
|
253
|
+
options[:order] = $_confirmed
|
254
|
+
end
|
255
|
+
opts.on('-r', '--recovered', 'Order the output based on \'Recovered\' column') do
|
256
|
+
options[:order] = $_recovered
|
257
|
+
end
|
258
|
+
opts.on('-d', '--deaths', 'Order the output based on \'Deaths\' column') do
|
259
|
+
options[:order] = $_deaths
|
260
|
+
end
|
261
|
+
opts.on('-a', '--active', 'Order the output based on \'Active\' column') do
|
262
|
+
options[:order] = $_active
|
263
|
+
end
|
264
|
+
opts.on('-D', '--death-rate', 'Order the output based on \'Death Rate\' column') do
|
265
|
+
options[:order] = $_death_rate
|
266
|
+
end
|
267
|
+
opts.on('-R', '--recovery-rate', 'Order the output based on \'Recovery Rate\' column') do
|
268
|
+
options[:order] = $_recovery_rate
|
269
|
+
end
|
270
|
+
opts.on('-C', '--cases-per-million', 'Order the output based on \'Cases P/M\' column') do
|
271
|
+
options[:order] = $_cases_pm
|
130
272
|
end
|
131
273
|
end
|
132
274
|
|
data/lib/covid19.rb
CHANGED
@@ -1,40 +1,143 @@
|
|
1
1
|
require 'covid19/version'
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'uri'
|
4
5
|
require 'net/http'
|
5
6
|
|
6
7
|
#
|
7
8
|
# To Follow
|
8
9
|
#
|
9
10
|
class Covid19
|
10
|
-
API_URL = 'https://
|
11
|
+
API_URL = 'https://corona-api.com/countries?include=timeline'.freeze
|
11
12
|
|
12
13
|
class << self
|
13
|
-
def
|
14
|
-
return
|
14
|
+
def latest_stats_all
|
15
|
+
return create_live_data_set
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
return
|
18
|
+
def latest_stats_global
|
19
|
+
return create_live_data_set['Global']
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
-
|
23
|
-
return retrieve_api_data("locations?country_code=#{country_code.upcase}#{timelines}")
|
22
|
+
def latest_stats_split_by_country
|
23
|
+
return create_live_data_set['Countries']
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
private
|
27
|
+
|
28
|
+
def get_max(left, right)
|
29
|
+
return (left <=> right) >= 0 ? left : right
|
28
30
|
end
|
29
31
|
|
30
|
-
|
32
|
+
def create_live_data_set
|
33
|
+
global = { 'todays_confirmed' => 0, 'todays_recovered' => 0, 'todays_deaths' => 0, 'total_confirmed' => 0, 'total_recovered' => 0, 'total_deaths' => 0, 'total_active' => 0 }
|
34
|
+
country_list = []
|
35
|
+
|
36
|
+
data = retrieve_api_data['data']
|
37
|
+
|
38
|
+
data.each do |country|
|
39
|
+
todays_data = get_hash_value(country, 'today', [])
|
40
|
+
latest_data = get_hash_value(country, 'latest_data', [])
|
41
|
+
calculated_data = get_hash_value(latest_data, 'calculated', [])
|
42
|
+
timeline_data = get_hash_value(country, 'timeline', [])
|
43
|
+
|
44
|
+
#
|
45
|
+
# If we have timeline data then lets grab the most recent (current row)
|
46
|
+
#
|
47
|
+
current_data = if timeline_data.empty?
|
48
|
+
[]
|
49
|
+
else
|
50
|
+
timeline_data.first
|
51
|
+
end
|
52
|
+
|
53
|
+
timeline_confirmed = get_hash_value(current_data, 'new_confirmed')
|
54
|
+
timeline_recovered = get_hash_value(current_data, 'new_recovered')
|
55
|
+
timeline_deaths = get_hash_value(current_data, 'new_deaths')
|
56
|
+
timeline_total_confirmed = get_hash_value(current_data, 'confirmed')
|
57
|
+
timeline_total_recovered = get_hash_value(current_data, 'recovered')
|
58
|
+
timeline_total_deaths = get_hash_value(current_data, 'deaths')
|
59
|
+
timeline_total_active = get_hash_value(current_data, 'active')
|
60
|
+
|
61
|
+
#
|
62
|
+
# Get todays data from the todays data set
|
63
|
+
#
|
64
|
+
todays_confirmed = get_hash_value(todays_data, 'confirmed')
|
65
|
+
todays_recovered = get_hash_value(todays_data, 'recovered')
|
66
|
+
todays_deaths = get_hash_value(todays_data, 'deaths')
|
31
67
|
|
32
|
-
|
33
|
-
|
68
|
+
#
|
69
|
+
# Get the latest data from the latest dataset
|
70
|
+
#
|
71
|
+
total_confirmed = get_hash_value(latest_data, 'confirmed')
|
72
|
+
total_recovered = get_hash_value(latest_data, 'recovered')
|
73
|
+
total_deaths = get_hash_value(latest_data, 'deaths')
|
74
|
+
total_active = total_confirmed - (total_deaths + total_recovered)
|
75
|
+
|
76
|
+
#
|
77
|
+
# Use the biggest value - as timeline is updated at a different rate
|
78
|
+
#
|
79
|
+
todays_confirmed = get_max(timeline_confirmed, todays_confirmed)
|
80
|
+
todays_recovered = get_max(timeline_recovered, todays_recovered)
|
81
|
+
todays_deaths = get_max(timeline_deaths, todays_deaths)
|
82
|
+
total_confirmed = get_max(timeline_total_confirmed, total_confirmed)
|
83
|
+
total_recovered = get_max(timeline_total_recovered, total_recovered)
|
84
|
+
total_deaths = get_max(timeline_total_deaths, total_deaths)
|
85
|
+
total_active = get_max(timeline_total_active, total_active)
|
86
|
+
|
87
|
+
# This normally means the country has stopped given updates on recoveries
|
88
|
+
if get_hash_value(latest_data, 'recovered').zero?
|
89
|
+
todays_recovered = 0
|
90
|
+
total_recovered = 0
|
91
|
+
total_active = 0
|
92
|
+
end
|
93
|
+
|
94
|
+
global['todays_confirmed'] += todays_confirmed
|
95
|
+
global['todays_recovered'] += todays_recovered
|
96
|
+
global['todays_deaths'] += todays_deaths
|
97
|
+
global['total_confirmed'] += total_confirmed
|
98
|
+
global['total_recovered'] += total_recovered
|
99
|
+
global['total_deaths'] += total_deaths
|
100
|
+
global['total_active'] += total_active
|
101
|
+
|
102
|
+
row = {
|
103
|
+
'Country' => country['name'],
|
104
|
+
'Population' => get_hash_value(country, 'population', 'unknown'),
|
105
|
+
'ConfirmedToday' => todays_confirmed,
|
106
|
+
'RecoveredToday' => todays_recovered,
|
107
|
+
'DeathsToday' => todays_deaths,
|
108
|
+
'ConfirmedTotal' => total_confirmed,
|
109
|
+
'RecoveredTotal' => total_recovered,
|
110
|
+
'DeathsTotal' => total_deaths,
|
111
|
+
'ActiveTotal' => total_active,
|
112
|
+
'DeathRate' => get_hash_value(calculated_data, 'death_rate').to_f,
|
113
|
+
'RecoveryRate' => get_hash_value(calculated_data, 'recovery_rate').to_f,
|
114
|
+
'CasesPerMillion' => get_hash_value(calculated_data, 'cases_per_million_population')
|
115
|
+
}
|
116
|
+
|
117
|
+
country_list << row
|
118
|
+
end
|
119
|
+
|
120
|
+
global = {
|
121
|
+
'ConfirmedToday' => global['todays_confirmed'],
|
122
|
+
'RecoveredToday' => global['todays_recovered'],
|
123
|
+
'DeathsToday' => global['todays_deaths'],
|
124
|
+
'ConfirmedTotal' => global['total_confirmed'],
|
125
|
+
'RecoveredTotal' => global['total_recovered'],
|
126
|
+
'DeathsTotal' => global['total_deaths'],
|
127
|
+
'ActiveTotal' => global['total_active']
|
128
|
+
}
|
129
|
+
|
130
|
+
results = { 'Global' => global, 'Countries' => country_list }
|
131
|
+
|
132
|
+
return results
|
133
|
+
end
|
34
134
|
|
135
|
+
def retrieve_api_data
|
35
136
|
begin
|
36
|
-
|
37
|
-
|
137
|
+
# encoded_url = URI.encode(API_URL)
|
138
|
+
uri = URI.parse(API_URL)
|
139
|
+
response = Net::HTTP.get_response(uri)
|
140
|
+
return JSON.parse(response.body)
|
38
141
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
39
142
|
raise StandardError.new(e.to_s)
|
40
143
|
end
|
data/lib/covid19/version.rb
CHANGED
data/testing/covid19
CHANGED
@@ -3,69 +3,188 @@
|
|
3
3
|
$LOAD_PATH.unshift('./lib')
|
4
4
|
|
5
5
|
require 'bundler/setup'
|
6
|
+
|
7
|
+
require 'colorize'
|
6
8
|
require 'optparse'
|
7
9
|
require 'covid19'
|
8
10
|
require 'terminal-table'
|
9
11
|
|
10
12
|
# -------------------------------------------------------------------------------- #
|
11
|
-
#
|
13
|
+
# Global Variables #
|
12
14
|
# -------------------------------------------------------------------------------- #
|
13
|
-
#
|
15
|
+
# A simple set of global variables to avoid having to do multiple string compares #
|
16
|
+
# as one typo can cause weird things to happen. #
|
14
17
|
# -------------------------------------------------------------------------------- #
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
$_confirmed = 1
|
20
|
+
$_recovered = 2
|
21
|
+
$_deaths = 3
|
22
|
+
$_active = 4
|
23
|
+
$_death_rate = 5
|
24
|
+
$_recovery_rate = 6
|
25
|
+
$_cases_pm = 7
|
26
|
+
|
27
|
+
# -------------------------------------------------------------------------------- #
|
28
|
+
# Get Hash Value #
|
29
|
+
# -------------------------------------------------------------------------------- #
|
30
|
+
# Simple wrapper to locate a value from a hash and handle error states. #
|
31
|
+
# -------------------------------------------------------------------------------- #
|
32
|
+
|
33
|
+
def get_hash_value(hash, name, default_val = 0)
|
34
|
+
return default_val unless hash.is_a?(Hash)
|
35
|
+
|
36
|
+
return hash.fetch(name, default_val)
|
37
|
+
end
|
38
|
+
|
39
|
+
# -------------------------------------------------------------------------------- #
|
40
|
+
# Commify #
|
41
|
+
# -------------------------------------------------------------------------------- #
|
42
|
+
# Simple wrapper to make numbers a little more human readable. #
|
43
|
+
# -------------------------------------------------------------------------------- #
|
44
|
+
|
45
|
+
def commify(number)
|
46
|
+
return number.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
|
47
|
+
end
|
48
|
+
|
49
|
+
# -------------------------------------------------------------------------------- #
|
50
|
+
# Add Heading #
|
51
|
+
# -------------------------------------------------------------------------------- #
|
52
|
+
# Simple wrapper to generate a heading entry with optional alignment override. #
|
53
|
+
# -------------------------------------------------------------------------------- #
|
54
|
+
|
55
|
+
def add_heading(name, alignment = :center)
|
56
|
+
return { :value => name, :alignment => alignment }
|
57
|
+
end
|
58
|
+
|
59
|
+
# -------------------------------------------------------------------------------- #
|
60
|
+
# Show Summary Data #
|
61
|
+
# -------------------------------------------------------------------------------- #
|
62
|
+
# Create a nice table view of the latest global statistics. #
|
63
|
+
# -------------------------------------------------------------------------------- #
|
64
|
+
|
65
|
+
def show_summary_data(results)
|
66
|
+
title = 'Global Statistics Summary'
|
67
|
+
headings = []
|
68
|
+
rows = []
|
69
|
+
|
70
|
+
headings << ''
|
71
|
+
headings << add_heading('Today')
|
72
|
+
headings << add_heading('Total')
|
73
|
+
|
74
|
+
rows << [ 'Confirmed Cases', commify(get_hash_value(results, 'ConfirmedToday')), commify(get_hash_value(results, 'ConfirmedTotal')) ]
|
75
|
+
rows << [ 'Recovered', commify(get_hash_value(results, 'RecoveredToday')), commify(get_hash_value(results, 'RecoveredTotal')) ]
|
76
|
+
rows << [ 'Deaths', commify(get_hash_value(results, 'DeathsToday')), commify(get_hash_value(results, 'DeathsTotal')) ]
|
77
|
+
rows << [ 'Active', '', commify(get_hash_value(results, 'ActiveTotal')) ]
|
78
|
+
|
79
|
+
table = Terminal::Table.new :title => title.colorize(:light_green), :headings => headings, :rows => rows, :style => { :padding_left => 2, :padding_right => 2 }
|
80
|
+
table.align_column(1, :right)
|
81
|
+
table.align_column(2, :right)
|
82
|
+
puts table
|
22
83
|
end
|
23
84
|
|
24
85
|
# -------------------------------------------------------------------------------- #
|
25
|
-
#
|
86
|
+
# Show Todays Totals By Country #
|
26
87
|
# -------------------------------------------------------------------------------- #
|
27
|
-
# Create a nice table view of
|
88
|
+
# Create a nice table view of todays totals available per country. #
|
28
89
|
# -------------------------------------------------------------------------------- #
|
29
|
-
def format_latest_country_stats(results, options = {})
|
30
|
-
processed = {}
|
31
90
|
|
32
|
-
|
33
|
-
|
91
|
+
def show_todays_totals_by_country(results, options = {})
|
92
|
+
title = 'Latest Totals by Country'
|
93
|
+
headings = []
|
94
|
+
rows = []
|
95
|
+
|
96
|
+
headings << add_heading('Country', :left)
|
97
|
+
headings << add_heading('Confirmed')
|
98
|
+
headings << add_heading('Recovered')
|
99
|
+
headings << add_heading('Deaths')
|
34
100
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
101
|
+
unless results.nil? && results.length.positive?
|
102
|
+
case options[:order]
|
103
|
+
when $_confirmed
|
104
|
+
results = results.sort_by { |k| k['ConfirmedToday'] }.reverse
|
105
|
+
title += ' Ordered by \'Confirmed\''
|
106
|
+
when $_recovered
|
107
|
+
results = results.sort_by { |k| k['RecoveredToday'] }.reverse
|
108
|
+
title += ' Ordered by \'Recovered\''
|
109
|
+
when $_deaths
|
110
|
+
results = results.sort_by { |k| k['DeathsToday'] }.reverse
|
111
|
+
title += ' Ordered by \'Deaths\''
|
112
|
+
else
|
113
|
+
results = results.sort_by { |k| k['Country'] }
|
43
114
|
end
|
44
|
-
processed[country_code] = { 'country' => item['country'], 'country_code' => country_code, 'id' => item['id'], 'confirmed' => confirmed, 'deaths' => deaths, 'recovered' => recovered }
|
45
|
-
end
|
46
115
|
|
47
|
-
|
48
|
-
|
49
|
-
|
116
|
+
results.each do |value|
|
117
|
+
rows << [ value['Country'], commify(value['ConfirmedToday']), commify(value['RecoveredToday']), commify(value['DeathsToday']) ]
|
118
|
+
end
|
50
119
|
end
|
51
120
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
121
|
+
table = Terminal::Table.new :title => title.colorize(:light_green), :headings => headings, :rows => rows, :style => { :padding_left => 2, :padding_right => 2 }
|
122
|
+
table.align_column(1, :right)
|
123
|
+
table.align_column(2, :right)
|
124
|
+
table.align_column(3, :right)
|
125
|
+
puts table
|
126
|
+
end
|
127
|
+
|
128
|
+
# -------------------------------------------------------------------------------- #
|
129
|
+
# Show Grand Totals By Country #
|
130
|
+
# -------------------------------------------------------------------------------- #
|
131
|
+
# Create a nice table view of the grand totals available per country. #
|
132
|
+
# -------------------------------------------------------------------------------- #
|
133
|
+
|
134
|
+
def show_grand_totals_by_country(results, options = {})
|
135
|
+
title = 'Grand Totals by Country'
|
136
|
+
headings = []
|
137
|
+
rows = []
|
138
|
+
|
139
|
+
headings << add_heading('Country', :left)
|
140
|
+
headings << add_heading('Confirmed')
|
141
|
+
headings << add_heading('Recovered')
|
142
|
+
headings << add_heading('Deaths')
|
143
|
+
headings << add_heading('Active')
|
144
|
+
headings << add_heading('Death Rate')
|
145
|
+
headings << add_heading('Recovery Rate')
|
146
|
+
headings << add_heading('Cases P/M')
|
147
|
+
|
148
|
+
unless results.nil? && results.length.positive?
|
149
|
+
case options[:order]
|
150
|
+
when $_confirmed
|
151
|
+
results = results.sort_by { |k| k['ConfirmedTotal'] }.reverse
|
152
|
+
title += ' Ordered by \'Confirmed\''
|
153
|
+
when $_recovered
|
154
|
+
results = results.sort_by { |k| k['RecoveredTotal'] }.reverse
|
155
|
+
title += ' Ordered by \'Recovered\''
|
156
|
+
when $_deaths
|
157
|
+
results = results.sort_by { |k| k['DeathsTotal'] }.reverse
|
158
|
+
title += ' Ordered by \'Deaths\''
|
159
|
+
when $_active
|
160
|
+
results = results.sort_by { |k| k['ActiveTotal'] }.reverse
|
161
|
+
title += ' Ordered by \'Active\''
|
162
|
+
when $_death_rate
|
163
|
+
results = results.sort_by { |k| k['DeathRate'] }.reverse
|
164
|
+
title += ' Ordered by \'Death Rate\''
|
165
|
+
when $_recovery_rate
|
166
|
+
results = results.sort_by { |k| k['RecoveryRate'] }.reverse
|
167
|
+
title += ' Ordered by \'Recovery Rate\''
|
168
|
+
when $_cases_pm
|
169
|
+
results = results.sort_by { |k| k['CasesPerMillion'] }.reverse
|
170
|
+
title += ' Ordered by \'Cases Per Million\''
|
171
|
+
else
|
172
|
+
results = results.sort_by { |k| k['Country'] }
|
173
|
+
end
|
56
174
|
|
57
|
-
|
58
|
-
|
59
|
-
|
175
|
+
results.each do |value|
|
176
|
+
rows << [ value['Country'], commify(value['ConfirmedTotal']), commify(value['RecoveredTotal']), commify(value['DeathsTotal']), commify(value['ActiveTotal']), "%.2f %%" % value['DeathRate'], "%.2f %%" % value['RecoveryRate'], commify(value['CasesPerMillion']) ]
|
177
|
+
end
|
60
178
|
end
|
61
179
|
|
62
|
-
table = Terminal::Table.new :title =>
|
63
|
-
table.align_column(1, :
|
180
|
+
table = Terminal::Table.new :title => title.colorize(:light_green), :headings => headings, :rows => rows, :style => { :padding_left => 2, :padding_right => 2 }
|
181
|
+
table.align_column(1, :right)
|
64
182
|
table.align_column(2, :right)
|
65
183
|
table.align_column(3, :right)
|
66
184
|
table.align_column(4, :right)
|
67
185
|
table.align_column(5, :right)
|
68
|
-
|
186
|
+
table.align_column(6, :right)
|
187
|
+
table.align_column(7, :right)
|
69
188
|
puts table
|
70
189
|
end
|
71
190
|
|
@@ -77,8 +196,9 @@ end
|
|
77
196
|
|
78
197
|
def get_covid19_stats(options)
|
79
198
|
begin
|
80
|
-
|
81
|
-
|
199
|
+
show_summary_data(Covid19.latest_stats_global) if options[:summary]
|
200
|
+
show_todays_totals_by_country(Covid19.latest_stats_split_by_country, options) if options[:latest]
|
201
|
+
show_grand_totals_by_country(Covid19.latest_stats_split_by_country, options) if options[:totals]
|
82
202
|
rescue StandardError => e
|
83
203
|
puts "Error: #{e}"
|
84
204
|
puts e.backtrace
|
@@ -96,7 +216,7 @@ end
|
|
96
216
|
# -------------------------------------------------------------------------------- #
|
97
217
|
|
98
218
|
def process_arguments
|
99
|
-
options = { :
|
219
|
+
options = { :summary => true }
|
100
220
|
# Enforce the presence of
|
101
221
|
mandatory = %I[]
|
102
222
|
|
@@ -107,27 +227,50 @@ def process_arguments
|
|
107
227
|
puts opts
|
108
228
|
exit(1)
|
109
229
|
end
|
110
|
-
|
111
|
-
|
230
|
+
opts.on('-s', '--summary', 'Show a summary of the totals [Default]') do
|
231
|
+
options[:summary] = true
|
112
232
|
options[:latest] = false
|
233
|
+
options[:totals] = false
|
113
234
|
end
|
114
|
-
|
115
|
-
|
116
|
-
options[:
|
117
|
-
options[:
|
118
|
-
options[:recovered] = false
|
235
|
+
opts.on('-l', '--latest', 'Show the latest (todays) totals split by country (same as -t)') do
|
236
|
+
options[:summary] = false
|
237
|
+
options[:latest] = true
|
238
|
+
options[:totals] = false
|
119
239
|
end
|
120
|
-
|
121
|
-
|
122
|
-
options[:
|
123
|
-
options[:
|
124
|
-
|
240
|
+
opts.on('-t', '--today', 'Show the latest (todays) totals split by country (same as -l)') do
|
241
|
+
options[:summary] = false
|
242
|
+
options[:latest] = true
|
243
|
+
options[:totals] = false
|
244
|
+
end
|
245
|
+
opts.on('-T', '--totals', 'Show the full totals split by country') do
|
246
|
+
options[:summary] = false
|
247
|
+
options[:latest] = false
|
248
|
+
options[:totals] = true
|
125
249
|
end
|
126
250
|
|
127
|
-
opts.
|
128
|
-
|
129
|
-
|
130
|
-
|
251
|
+
opts.separator('')
|
252
|
+
opts.separator('Coloumn Sorting Options:')
|
253
|
+
|
254
|
+
opts.on('-c', '--confirmed', 'Order the output based on \'Confirmed\' column') do
|
255
|
+
options[:order] = $_confirmed
|
256
|
+
end
|
257
|
+
opts.on('-r', '--recovered', 'Order the output based on \'Recovered\' column') do
|
258
|
+
options[:order] = $_recovered
|
259
|
+
end
|
260
|
+
opts.on('-d', '--deaths', 'Order the output based on \'Deaths\' column') do
|
261
|
+
options[:order] = $_deaths
|
262
|
+
end
|
263
|
+
opts.on('-a', '--active', 'Order the output based on \'Active\' column') do
|
264
|
+
options[:order] = $_active
|
265
|
+
end
|
266
|
+
opts.on('-D', '--death-rate', 'Order the output based on \'Death Rate\' column') do
|
267
|
+
options[:order] = $_death_rate
|
268
|
+
end
|
269
|
+
opts.on('-R', '--recovery-rate', 'Order the output based on \'Recovery Rate\' column') do
|
270
|
+
options[:order] = $_recovery_rate
|
271
|
+
end
|
272
|
+
opts.on('-C', '--cases-per-million', 'Order the output based on \'Cases P/M\' column') do
|
273
|
+
options[:order] = $_cases_pm
|
131
274
|
end
|
132
275
|
end
|
133
276
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covid19
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Gurney aka Wolf
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '1.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: colorize
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: terminal-table
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +108,7 @@ dependencies:
|
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '1.8'
|
83
|
-
description: A wrapper for the coronavirus API at https://
|
111
|
+
description: A wrapper for the coronavirus API at https://corona-api.com/.
|
84
112
|
email:
|
85
113
|
- wolf@tgwolf.com
|
86
114
|
executables:
|
@@ -99,6 +127,7 @@ files:
|
|
99
127
|
- LICENSE.md
|
100
128
|
- README.md
|
101
129
|
- Rakefile
|
130
|
+
- VERSION.txt
|
102
131
|
- bin/console
|
103
132
|
- bin/setup
|
104
133
|
- covid19.gemspec
|
@@ -113,7 +142,7 @@ homepage: https://github.com/WolfAtheneum/covid19
|
|
113
142
|
licenses:
|
114
143
|
- MIT
|
115
144
|
metadata: {}
|
116
|
-
post_install_message:
|
145
|
+
post_install_message:
|
117
146
|
rdoc_options: []
|
118
147
|
require_paths:
|
119
148
|
- lib
|
@@ -129,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
158
|
version: '0'
|
130
159
|
requirements: []
|
131
160
|
rubygems_version: 3.0.3
|
132
|
-
signing_key:
|
161
|
+
signing_key:
|
133
162
|
specification_version: 4
|
134
|
-
summary: A wrapper for the coronavirus API at https://
|
163
|
+
summary: A wrapper for the coronavirus API at https://corona-api.com/.
|
135
164
|
test_files: []
|