kovid 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29a085cad77bc261e7c65efbddbff9af592c328e2e980ce785a868ce1f7dd88d
4
- data.tar.gz: 310c0a2f5139cc26fa0a20159d8fb5ad3b141722f4e28360e67ad89afd9a6763
3
+ metadata.gz: 6704e68fddf1650cddcc75fcaafebc00116ff3f77fa65d3564a276a3bbd0f464
4
+ data.tar.gz: 276f9690e3066acb36c9a8dda80e8cd018b64f311028293083fd9735e0d422a2
5
5
  SHA512:
6
- metadata.gz: 4225dbced44ac4a1c6cde1c5aea535a626f9df380e06cc2960c8c9c2be104508ca5b8818b44470f0b1af605714a168e2ef3ad73cbd5524fe80bc455558b85c75
7
- data.tar.gz: b890a173fca7a3c34f103954d6f3f97c43e286d4b99dc57dffadbb772dd4dd487743bf81db32e36b938534698465a7fe51d6995d480407b8a7edecd22c081f4b
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
- rows = []
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
- path = "/countries/#{name}"
38
- fetch_url = BASE_URL + path
27
+ begin
28
+ path = "/countries/#{name}"
29
+ fetch_url = BASE_URL + path
39
30
 
40
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
41
- Kovid::Tablelize.full_country_table(response)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
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.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford