kovid 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7d6bfb3cb9be53c0ba94fc9f788705f2878d31686ada02106fd2e5dd296b5fd
4
- data.tar.gz: b1d448270c2fed3bd31fd5f1311f32322bfe096cdec42e9cf7f99af99d5c0793
3
+ metadata.gz: b34798e9212d718e441ff0185598d028662b4e13994ebe7a7354cd0a22a7aef5
4
+ data.tar.gz: 2e23bc917e77996ad1b848aed6340cdb25123ba5bfd976a8d5407c347f05ac25
5
5
  SHA512:
6
- metadata.gz: 175b4e746c10544101a29ce05ba76b28cc5542b95b198afb7584a2188cf570e551c304485ee6d09e464ecb5e81e7534bd3df9d81cfe4d52b6b9dab5368c6452c
7
- data.tar.gz: 2e16b56052821e5d7fbb04caf97ac1b019b5430548990aed576166144a61d24a4763c93589589a034ebe7b08f0f7cf350ba2582605eee8e9a98f66ce3e9ce37c
6
+ metadata.gz: 0c2ce46118ef92380c1c5bd1b4faba1b1e8893225161c7e3c2fe684298db3d830eda22f13854f8a69e8aef6d0ad581cca9b1ee40db8f3ab79bc410db1fce29f7
7
+ data.tar.gz: 9099b7a5e109c567ab7a0b707d991ad53be609ff918b02b6d56bcc45516c1489a9785e931c2814036a415edab69c0f24826bdd9f18ec6ccc6a438dae85c89e86
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.5.8)
4
+ kovid (0.6.0)
5
5
  ascii_charts (~> 0.9.1)
6
6
  rainbow (~> 3.0)
7
7
  terminal-table (~> 1.8)
data/README.md CHANGED
@@ -44,6 +44,7 @@ You can get continental information with the following commands:
44
44
 
45
45
  You can fetch US state-specific data:
46
46
  * `kovid state STATE` OR `kovid state "STATE NAME"`.
47
+ * `kovid aus` for data on all US states.
47
48
 
48
49
  Provinces
49
50
 
@@ -54,6 +54,10 @@ module Kovid
54
54
  Kovid::Request.states(states)
55
55
  end
56
56
 
57
+ def all_us_states
58
+ Kovid::Request.all_us_states
59
+ end
60
+
57
61
  def country_comparison(names_array)
58
62
  Kovid::Request.by_country_comparison(names_array)
59
63
  end
@@ -56,9 +56,19 @@ module Kovid
56
56
 
57
57
  desc 'states STATE STATE', 'Returns full comparison table for the given states. Accepts multiple states.'
58
58
  def states(*states)
59
- puts Kovid.states(states)
59
+ # This ensures this command is case insensitive.
60
+ downcased_states = states.map(&:downcase)
61
+
62
+ puts Kovid.states(downcased_states)
63
+ data_source
64
+ end
65
+
66
+ desc 'all_us_states', 'Returns full comparison table for all US states'
67
+ def all_us_states
68
+ puts Kovid.all_us_states
60
69
  data_source
61
70
  end
71
+ map aus: :all_us_states
62
72
 
63
73
  desc 'world', 'Returns total number of cases, deaths and recoveries.'
64
74
  def world
@@ -117,10 +117,17 @@ module Kovid
117
117
  puts SERVER_DOWN
118
118
  end
119
119
 
120
- def states(list)
121
- array = fetch_states(list)
120
+ def states(states)
121
+ compared_states = fetch_compared_states(states)
122
122
 
123
- Kovid::Tablelize.compare_us_states(array)
123
+ Kovid::Tablelize.compare_us_states(compared_states)
124
+ rescue JSON::ParserError
125
+ puts SERVER_DOWN
126
+ end
127
+
128
+ def all_us_states
129
+ state_data = fetch_state_data
130
+ Kovid::Tablelize.compare_us_states(state_data)
124
131
  rescue JSON::ParserError
125
132
  puts SERVER_DOWN
126
133
  end
@@ -175,22 +182,19 @@ module Kovid
175
182
  end
176
183
 
177
184
  def fetch_countries(list)
178
- array = []
185
+ list.map do |country|
186
+ JSON.parse(Typhoeus.get(COUNTRIES_PATH + "/#{country}", cache_ttl: 900).response_body)
187
+ end.sort_by { |json| -json['cases'] }
188
+ end
179
189
 
180
- list.each do |country|
181
- array << JSON.parse(Typhoeus.get(COUNTRIES_PATH + "/#{country}", cache_ttl: 900).response_body)
182
- end
190
+ def fetch_compared_states(submitted_states)
191
+ state_data = fetch_state_data
183
192
 
184
- array = array.sort_by { |json| -json['cases'] }
193
+ state_data.select { |state| submitted_states.include?(state['state'].downcase) }
185
194
  end
186
195
 
187
- def fetch_states(list)
188
- states_json = JSON.parse(Typhoeus.get(STATES_URL, cache_ttl: 900).response_body)
189
- states_array = []
190
-
191
- states_json.select do |state|
192
- states_array << state if list.include?(state['state'].downcase)
193
- end
196
+ def fetch_state_data
197
+ JSON.parse(Typhoeus.get(STATES_URL, cache_ttl: 900).response_body)
194
198
  end
195
199
 
196
200
  def fetch_country(country_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kovid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ascii_charts