kovid 0.1.6 → 0.1.7
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/lib/kovid/request.rb +18 -15
- data/lib/kovid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6704e68fddf1650cddcc75fcaafebc00116ff3f77fa65d3564a276a3bbd0f464
|
4
|
+
data.tar.gz: 276f9690e3066acb36c9a8dda80e8cd018b64f311028293083fd9735e0d422a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1046f127ecd5edabc409f59a0df757ddb267405b3909306d811680de6dad7c7a4551b165bbeb88c9bce4bc0b2e8ffccdbea5cc96cb602611073d8ff5144ab7c8
|
7
|
+
data.tar.gz: 0e9e3b798436cc005aa55dafbc4fa219d7144fc7d293c1449ac1519c920a4b3ec09624476ff4b68f2099014ed75bb46aa752e13f88fbace1581fa65031d6b011
|
data/lib/kovid/request.rb
CHANGED
@@ -11,13 +11,6 @@ module Kovid
|
|
11
11
|
class << self
|
12
12
|
require 'pry'
|
13
13
|
def by_country(name)
|
14
|
-
# path = "/countries/#{name}"
|
15
|
-
# fetch_url = BASE_URL + path
|
16
|
-
|
17
|
-
# binding.pry
|
18
|
-
# response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
19
|
-
# Kovid::Tablelize.country_table(response)
|
20
|
-
|
21
14
|
begin
|
22
15
|
path = "/countries/#{name}"
|
23
16
|
fetch_url = BASE_URL + path
|
@@ -26,19 +19,20 @@ module Kovid
|
|
26
19
|
Kovid::Tablelize.country_table(response)
|
27
20
|
|
28
21
|
rescue JSON::ParserError
|
29
|
-
|
30
|
-
rows << ["Thankfully there are no reported cases in #{name.capitalize}!"]
|
31
|
-
table = Terminal::Table.new :headings => ["#{name}",], :rows => rows
|
32
|
-
puts table
|
22
|
+
no_case_in(name)
|
33
23
|
end
|
34
24
|
end
|
35
25
|
|
36
26
|
def by_country_full(name)
|
37
|
-
|
38
|
-
|
27
|
+
begin
|
28
|
+
path = "/countries/#{name}"
|
29
|
+
fetch_url = BASE_URL + path
|
39
30
|
|
40
|
-
|
41
|
-
|
31
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
32
|
+
Kovid::Tablelize.full_country_table(response)
|
33
|
+
rescue JSON::ParserError
|
34
|
+
no_case_in(name)
|
35
|
+
end
|
42
36
|
end
|
43
37
|
|
44
38
|
def by_country_comparison(list)
|
@@ -74,6 +68,15 @@ module Kovid
|
|
74
68
|
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
75
69
|
Kovid::Tablelize.cases(response)
|
76
70
|
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def no_case_in(country)
|
75
|
+
rows = []
|
76
|
+
rows << ["Thankfully there are no reported cases in #{country.capitalize}!"]
|
77
|
+
table = Terminal::Table.new :headings => ["#{country.capitalize}",], :rows => rows
|
78
|
+
puts table
|
79
|
+
end
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
data/lib/kovid/version.rb
CHANGED