kovid 0.3.13 → 0.3.14

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: 56eeb79f768cff4c007129a7b4a085d9f356c637122d8f3dd51aa927ed4d4c3c
4
- data.tar.gz: 76f27f3a84fbb91ef7dab5f08e859f4ecf53dc0d9287c39969f3300cd8b966a4
3
+ metadata.gz: 7af46067aa63d1c17b9ad882d984a48b4e2c99e79a83259f451b45f2149b0ee7
4
+ data.tar.gz: 3ee5995695f804a718062713cf57d329e76828e974cfe0cc91fc2a4440848a98
5
5
  SHA512:
6
- metadata.gz: 533436702c4980deef2082f66a9639d1ff9d6813b4cf5872f328533624257fbdcf695574e938d52c05867c8f1fd133be76c1c0e2ea1e3066319b7d2956bb844d
7
- data.tar.gz: cbaf6fa830834bbef006783fc0b6a47c979a5a28a5fbc1a9486b6c5facd38a65148fe6c4e8d690898c052338a304aabdf9693e6b0508c371166224fea6c6299f
6
+ metadata.gz: ab2e838487e5cdd6a8addfeb98599b2c3e3ddd9c1ffdc129e3451d48ec50f87dc5ba96377e48f4dccba22c9498d760ae7309839a87222c9db75fd9c95f3ada9a
7
+ data.tar.gz: 04c3fb552f49e8faedee92bb0f21c816747069a5dc40016d726fbd75443dfdc303b4162e59684f85b29043b81684658af0f1de803e6836f62cb8f366be806a85
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.3.12)
4
+ kovid (0.3.13)
5
5
  rainbow (~> 3.0)
6
6
  terminal-table (~> 1.8)
7
7
  thor (~> 1.0)
data/kovid.gemspec CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
  with the novel coronavirus, I think stats on the issue should be
41
41
  accessible.
42
42
 
43
- There isn't much we can do now aside:
43
+ There isn't much we can do now besides:
44
44
 
45
45
  * Washing our hands with soap frequently.
46
46
  * Limiting our movements, how much we touch our faces & social distancing.
data/lib/kovid/request.rb CHANGED
@@ -28,6 +28,8 @@ module Kovid
28
28
  end.compact
29
29
 
30
30
  Kovid::Tablelize.eu_aggregate(eu_data)
31
+ rescue JSON::ParserError
32
+ puts 'Server overwhelmed. Try again in a moment.'
31
33
  end
32
34
 
33
35
  def by_country(country_name)
@@ -38,6 +40,8 @@ module Kovid
38
40
  else
39
41
  Kovid::Tablelize.country_table(response)
40
42
  end
43
+ rescue JSON::ParserError
44
+ puts 'Server overwhelmed. Try again in a moment.'
41
45
  end
42
46
 
43
47
  def by_country_full(country_name)
@@ -48,28 +52,47 @@ module Kovid
48
52
  else
49
53
  Kovid::Tablelize.full_country_table(response)
50
54
  end
55
+
56
+ rescue JSON::ParserError
57
+ puts 'Server overwhelmed. Try again in a moment.'
51
58
  end
52
59
 
53
60
  def state(state)
54
61
  response = fetch_state(state)
55
62
 
56
63
  Kovid::Tablelize.full_state_table(response)
64
+ rescue JSON::ParserError
65
+ puts 'Server overwhelmed. Try again in a moment.'
66
+ end
67
+
68
+ def states(list)
69
+ array = fetch_states(list)
70
+
71
+ Kovid::Tablelize.compare_us_states(array)
72
+ rescue JSON::ParserError
73
+ puts 'Server overwhelmed. Try again in a moment.'
57
74
  end
58
75
 
59
76
  def by_country_comparison(list)
60
77
  array = fetch_countries(list)
61
78
  Kovid::Tablelize.compare_countries_table(array)
79
+ rescue JSON::ParserError
80
+ puts 'Server overwhelmed. Try again in a moment.'
62
81
  end
63
82
 
64
83
  def by_country_comparison_full(list)
65
84
  array = fetch_countries(list)
66
85
  Kovid::Tablelize.compare_countries_table_full(array)
86
+ rescue JSON::ParserError
87
+ puts 'Server overwhelmed. Try again in a moment.'
67
88
  end
68
89
 
69
90
  def cases
70
91
  response ||= JSON.parse(Typhoeus.get(UriBuilder.new('/all').url, cache_ttl: 900).response_body)
71
92
 
72
93
  Kovid::Tablelize.cases(response)
94
+ rescue JSON::ParserError
95
+ puts 'Server overwhelmed. Try again in a moment.'
73
96
  end
74
97
 
75
98
  def history(country, last)
@@ -77,6 +100,8 @@ module Kovid
77
100
  response ||= JSON.parse(Typhoeus.get(history_path + "/#{country}", cache_ttl: 900).response_body)
78
101
 
79
102
  Kovid::Tablelize.history(response, last)
103
+ rescue JSON::ParserError
104
+ puts 'Server overwhelmed. Try again in a moment.'
80
105
  end
81
106
 
82
107
  private
@@ -96,6 +121,14 @@ module Kovid
96
121
  array = array.sort_by { |json| -json['cases'] }
97
122
  end
98
123
 
124
+ def fetch_states(list)
125
+ array = []
126
+
127
+ list.each do |state|
128
+ array << JSON.parse(Typhoeus.get(COUNTRIES_PATH + "/#{state}", cache_ttl: 900).response_body)
129
+ end
130
+ end
131
+
99
132
  def fetch_country(country_name)
100
133
  country_url = COUNTRIES_PATH + "/#{country_name}"
101
134
 
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.3.13'
4
+ VERSION = '0.3.14'
5
5
  end
data/lib/kovid.rb CHANGED
@@ -24,6 +24,10 @@ module Kovid
24
24
  Kovid::Request.state(state)
25
25
  end
26
26
 
27
+ def states(*_states)
28
+ Kovid::Request.states(state)
29
+ end
30
+
27
31
  def country_comparison(names_array)
28
32
  Kovid::Request.by_country_comparison(names_array)
29
33
  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.3.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford
@@ -122,7 +122,7 @@ metadata:
122
122
  post_install_message: "\n ============================================================================\n
123
123
  \ COVID-19 has devasted the world. But while we're fighting\n with the
124
124
  novel coronavirus, I think stats on the issue should be\n accessible.\n\n There
125
- isn't much we can do now aside:\n\n * Washing our hands with soap frequently.\n
125
+ isn't much we can do now besides:\n\n * Washing our hands with soap frequently.\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