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 +4 -4
- data/Gemfile.lock +1 -1
- data/kovid.gemspec +1 -1
- data/lib/kovid/request.rb +33 -0
- data/lib/kovid/version.rb +1 -1
- data/lib/kovid.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7af46067aa63d1c17b9ad882d984a48b4e2c99e79a83259f451b45f2149b0ee7
|
4
|
+
data.tar.gz: 3ee5995695f804a718062713cf57d329e76828e974cfe0cc91fc2a4440848a98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab2e838487e5cdd6a8addfeb98599b2c3e3ddd9c1ffdc129e3451d48ec50f87dc5ba96377e48f4dccba22c9498d760ae7309839a87222c9db75fd9c95f3ada9a
|
7
|
+
data.tar.gz: 04c3fb552f49e8faedee92bb0f21c816747069a5dc40016d726fbd75443dfdc303b4162e59684f85b29043b81684658af0f1de803e6836f62cb8f366be806a85
|
data/Gemfile.lock
CHANGED
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
|
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
data/lib/kovid.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.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
|
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
|