kovid 0.3.12 → 0.3.13
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/Gemfile.lock +1 -1
- data/kovid.gemspec +2 -0
- data/lib/kovid/cli.rb +6 -7
- data/lib/kovid/request.rb +12 -8
- data/lib/kovid/tablelize.rb +25 -4
- data/lib/kovid/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56eeb79f768cff4c007129a7b4a085d9f356c637122d8f3dd51aa927ed4d4c3c
|
4
|
+
data.tar.gz: 76f27f3a84fbb91ef7dab5f08e859f4ecf53dc0d9287c39969f3300cd8b966a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 533436702c4980deef2082f66a9639d1ff9d6813b4cf5872f328533624257fbdcf695574e938d52c05867c8f1fd133be76c1c0e2ea1e3066319b7d2956bb844d
|
7
|
+
data.tar.gz: cbaf6fa830834bbef006783fc0b6a47c979a5a28a5fbc1a9486b6c5facd38a65148fe6c4e8d690898c052338a304aabdf9693e6b0508c371166224fea6c6299f
|
data/Gemfile.lock
CHANGED
data/kovid.gemspec
CHANGED
@@ -54,6 +54,8 @@ Gem::Specification.new do |spec|
|
|
54
54
|
Data Sources:
|
55
55
|
* JHU CSSE GISand Data
|
56
56
|
* https://www.worldometers.info/coronavirus/
|
57
|
+
|
58
|
+
PS: Please update often, contribute code/ideas, report issues 🙏.
|
57
59
|
============================================================================
|
58
60
|
}
|
59
61
|
end
|
data/lib/kovid/cli.rb
CHANGED
@@ -7,12 +7,6 @@ module Kovid
|
|
7
7
|
class CLI < Thor
|
8
8
|
FULL_FLAG = %w[-f --full].freeze
|
9
9
|
|
10
|
-
desc 'eu', 'Returns aggregated data on the EU.'
|
11
|
-
def eu
|
12
|
-
puts Kovid.eu_aggregate
|
13
|
-
data_source
|
14
|
-
end
|
15
|
-
|
16
10
|
desc 'check COUNTRY or check "COUNTRY NAME"', 'Returns reported data on provided country. eg: "kovid check "hong kong".'
|
17
11
|
method_option :full, aliases: '-f'
|
18
12
|
def check(name)
|
@@ -59,6 +53,12 @@ module Kovid
|
|
59
53
|
data_source
|
60
54
|
end
|
61
55
|
|
56
|
+
desc 'eu', 'Returns aggregated data on the EU.'
|
57
|
+
def eu
|
58
|
+
puts Kovid.eu_aggregate
|
59
|
+
data_source
|
60
|
+
end
|
61
|
+
|
62
62
|
private
|
63
63
|
|
64
64
|
def fetch_country_stats(country)
|
@@ -74,7 +74,6 @@ module Kovid
|
|
74
74
|
Sources:
|
75
75
|
* JHU CSSE GISand Data
|
76
76
|
* https://www.worldometers.info/coronavirus/
|
77
|
-
Please update often, contribute, report issues 🙏.
|
78
77
|
TEXT
|
79
78
|
puts source
|
80
79
|
puts
|
data/lib/kovid/request.rb
CHANGED
@@ -33,17 +33,21 @@ module Kovid
|
|
33
33
|
def by_country(country_name)
|
34
34
|
response = fetch_country(country_name)
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
if response.values.first.include?('not found')
|
37
|
+
not_found(country_name)
|
38
|
+
else
|
39
|
+
Kovid::Tablelize.country_table(response)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def by_country_full(country_name)
|
42
44
|
response = fetch_country(country_name)
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
if response.values.first.include?('not found')
|
47
|
+
not_found(country_name)
|
48
|
+
else
|
49
|
+
Kovid::Tablelize.full_country_table(response)
|
50
|
+
end
|
47
51
|
end
|
48
52
|
|
49
53
|
def state(state)
|
@@ -77,8 +81,8 @@ module Kovid
|
|
77
81
|
|
78
82
|
private
|
79
83
|
|
80
|
-
def
|
81
|
-
rows = [["Wrong spelling
|
84
|
+
def not_found(country)
|
85
|
+
rows = [["Wrong spelling/No reported cases on #{country.upcase}."]]
|
82
86
|
Terminal::Table.new title: "You checked: #{country.upcase}", rows: rows
|
83
87
|
end
|
84
88
|
|
data/lib/kovid/tablelize.rb
CHANGED
@@ -10,7 +10,9 @@ module Kovid
|
|
10
10
|
CASES_DEATHS_RECOVERED = [
|
11
11
|
'Cases'.paint_white,
|
12
12
|
'Deaths'.paint_red,
|
13
|
-
'Recovered'.paint_green
|
13
|
+
'Recovered'.paint_green,
|
14
|
+
'Cases Today'.paint_white,
|
15
|
+
'Deaths Today'.paint_red
|
14
16
|
].freeze
|
15
17
|
|
16
18
|
DATE_CASES_DEATHS = [
|
@@ -34,7 +36,17 @@ module Kovid
|
|
34
36
|
|
35
37
|
def country_table(data)
|
36
38
|
headings = CASES_DEATHS_RECOVERED
|
37
|
-
rows = [
|
39
|
+
rows = [
|
40
|
+
[
|
41
|
+
data['cases'],
|
42
|
+
data['deaths'],
|
43
|
+
data['recovered'],
|
44
|
+
check_if_positve(data['todayCases']),
|
45
|
+
check_if_positve(data['todayDeaths'])
|
46
|
+
]
|
47
|
+
]
|
48
|
+
|
49
|
+
# binding.irb
|
38
50
|
|
39
51
|
if iso = data['countryInfo']['iso2']
|
40
52
|
Terminal::Table.new(title: data['country'].upcase.to_s, headings: headings, rows: rows)
|
@@ -99,13 +111,22 @@ module Kovid
|
|
99
111
|
'Country'.paint_white,
|
100
112
|
'Cases'.paint_white,
|
101
113
|
'Deaths'.paint_red,
|
102
|
-
'Recovered'.paint_green
|
114
|
+
'Recovered'.paint_green,
|
115
|
+
'Cases Today'.paint_white,
|
116
|
+
'Deaths Today'.paint_red
|
103
117
|
]
|
104
118
|
|
105
119
|
rows = []
|
106
120
|
|
107
121
|
data.each do |country|
|
108
|
-
rows << [
|
122
|
+
rows << [
|
123
|
+
country['country'].upcase,
|
124
|
+
comma_delimit(country['cases']),
|
125
|
+
comma_delimit(country['deaths']),
|
126
|
+
comma_delimit(country['recovered']),
|
127
|
+
check_if_positve(country['todayCases']),
|
128
|
+
check_if_positve(country['todayDeaths'])
|
129
|
+
]
|
109
130
|
end
|
110
131
|
|
111
132
|
Terminal::Table.new(headings: headings, rows: rows)
|
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.3.
|
4
|
+
version: 0.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
@@ -126,7 +126,8 @@ post_install_message: "\n ===================================================
|
|
126
126
|
\ * Limiting our movements, how much we touch our faces & social distancing.\n
|
127
127
|
\ * Disinfecting our phones, keys, doorknobs, keyboards, etc.\n * Being
|
128
128
|
there for each other.\n\n Stay safe!\n Emmanuel Hayford.\n https://emmanuelhayford.com/\n\n
|
129
|
-
\ Data Sources:\n * JHU CSSE GISand Data\n * https://www.worldometers.info/coronavirus/\n
|
129
|
+
\ Data Sources:\n * JHU CSSE GISand Data\n * https://www.worldometers.info/coronavirus/\n\n
|
130
|
+
\ PS: Please update often, contribute code/ideas, report issues \U0001F64F.\n
|
130
131
|
\ ============================================================================\n
|
131
132
|
\ "
|
132
133
|
rdoc_options: []
|