kovid 0.6.6 β†’ 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6abc6282e6ec84a393eee2b5383d70f88643d7633f8bd7537c207dae341ead1b
4
- data.tar.gz: a93e83c437e3b1f740fe7471cca72ad2e83c837d0a637c5fe8c71636bdd545dd
3
+ metadata.gz: a77d1ad2686877dfe810f0df3cbc817b46c287f2a6025ce999108213ad0e54c8
4
+ data.tar.gz: 888dab7db56dc55241512e24bef98fb9f9117abd9e09790a19894630d691e0c2
5
5
  SHA512:
6
- metadata.gz: dbc95ba0e85745d9369e15b0e81b6f5d36a7199b1227aaaec56eb57b8aac067750e4e2c71f937a97b333fdf57693547d6f98a09e70d214a5300b5b09cd5eeb25
7
- data.tar.gz: a2a458068aefa1f001ad85426ef5eba0317ba23a0320fab970eed818a9009186cc966f757c0a4f1b693a85cf668098ffa477acc3587849ed5864dcfc53a3b5fe
6
+ metadata.gz: 6394d6904a073fef5c4fa1d6429c3789a84dfc329a519346dd90e53b082b22284405a044a13c984cf231f7cdd02fb790c49450c47c1d6c0fecb124fbc67783e5
7
+ data.tar.gz: 7c45571d9683f723068c6d17a97427348c5d3f8ed64db76e2bd71db72af322f3611bd0d66af8dc3732d4a251f1253d2ea0d49c0db34f8c905739f7cc7dd885cc
@@ -2,3 +2,6 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
4
  TargetRubyVersion: 2.6
5
+
6
+ Style/Documentation:
7
+ Enabled: false
data/Gemfile CHANGED
@@ -7,3 +7,6 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 12.0'
9
9
  gem 'rspec', '~> 3.0'
10
+
11
+ # Repo of geogrpahic locations
12
+ gem 'carmen', '~> 1.1.3'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.6.5)
4
+ kovid (0.6.6)
5
5
  ascii_charts (~> 0.9.1)
6
6
  rainbow (~> 3.0)
7
7
  terminal-table (~> 1.8)
@@ -11,12 +11,24 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
+ activesupport (6.0.2.2)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.2)
14
20
  ascii_charts (0.9.1)
21
+ carmen (1.1.3)
22
+ activesupport (>= 3.0.0)
23
+ concurrent-ruby (1.1.6)
15
24
  diff-lcs (1.3)
16
25
  docile (1.3.2)
17
26
  ethon (0.12.0)
18
27
  ffi (>= 1.3.0)
19
28
  ffi (1.12.2)
29
+ i18n (1.8.2)
30
+ concurrent-ruby (~> 1.0)
31
+ minitest (5.14.0)
20
32
  rainbow (3.0.0)
21
33
  rake (12.3.3)
22
34
  rspec (3.9.0)
@@ -39,14 +51,19 @@ GEM
39
51
  terminal-table (1.8.0)
40
52
  unicode-display_width (~> 1.1, >= 1.1.1)
41
53
  thor (1.0.1)
54
+ thread_safe (0.3.6)
42
55
  typhoeus (1.3.1)
43
56
  ethon (>= 0.9.0)
57
+ tzinfo (1.2.7)
58
+ thread_safe (~> 0.1)
44
59
  unicode-display_width (1.7.0)
60
+ zeitwerk (2.3.0)
45
61
 
46
62
  PLATFORMS
47
63
  ruby
48
64
 
49
65
  DEPENDENCIES
66
+ carmen (~> 1.1.3)
50
67
  kovid!
51
68
  rake (~> 12.0)
52
69
  rspec (~> 3.0)
data/README.md CHANGED
@@ -46,6 +46,8 @@ You can fetch US state-specific data:
46
46
  * `kovid state STATE` OR `kovid state "STATE NAME"`.
47
47
  * `kovid states --all` or `kovid states -a` for data on all US states.
48
48
 
49
+ You can also use USPS abbreviations. Example: `kovid state me`
50
+
49
51
  Provinces
50
52
 
51
53
  You can fetch province specific data:
@@ -64,7 +66,7 @@ You can compare as many countries as you want; `kovid compare FOO BAR BAZ` OR `k
64
66
  πŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡Έ
65
67
 
66
68
  You can compare US states with:
67
- * `kovid states STATE STATE` Example: `kovid states illinois "new york" california`
69
+ * `kovid states STATE STATE` Example: `kovid states illinois "new york" california` OR `kovid states il ny ca`
68
70
 
69
71
  You can compare provicnes with:
70
72
  * `kovid provinces PROVINCE PROVINCE` Example: `kovid provinces ontario manitoba`
@@ -6,8 +6,6 @@ require 'kovid/request'
6
6
  module Kovid
7
7
  require 'kovid/helpers'
8
8
 
9
- class Error < StandardError; end
10
-
11
9
  module_function
12
10
 
13
11
  def eu_aggregate
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- # Sends info about continents to Tablelize
5
4
  module Aggregators
6
5
  def eu_aggregate(eu_data)
7
6
  aggregated_table(eu_data, 'The EU', Kovid::Request::EU_ISOS, 'πŸ‡ͺπŸ‡Ί')
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'typhoeus'
4
-
5
- # rubocop:disable Style/Documentation
6
4
  module Kovid
7
- # rubocop:enable Style/Documentation
8
- # Caches HTTP requests
9
5
  class Cache
10
6
  def initialize
11
7
  @memory = {}
@@ -4,8 +4,6 @@ require 'thor'
4
4
  require 'kovid'
5
5
 
6
6
  module Kovid
7
- # Describes the commands that can be run by the user
8
- # Descriptions are returned to STDOUT
9
7
  class CLI < Thor
10
8
  def self.exit_on_failure?
11
9
  true
@@ -30,4 +30,10 @@ module Kovid
30
30
  data.map! { |number| Kovid.comma_delimit(number) }
31
31
  end
32
32
  end
33
+
34
+ def lookup_us_state(state)
35
+ us = Carmen::Country.coded('USA')
36
+ lookup = us.subregions.coded(state) || us.subregions.named(state)
37
+ lookup ? lookup.name : state
38
+ end
33
39
  end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- # Constructs history data for specified country
5
4
  module Historians
6
5
  include Constants
7
6
 
8
7
  def history(country, last)
9
- # Write checks for when country is spelt wrong.
10
- headings = DATE_CASES_DEATHS_RECOVERED
8
+ # TODO: Write checks for when country is spelt wrong.
11
9
  rows = []
12
10
 
13
11
  stats = if last
@@ -40,7 +38,7 @@ module Kovid
40
38
 
41
39
  Terminal::Table.new(
42
40
  title: country['country'].upcase,
43
- headings: headings,
41
+ headings: DATE_CASES_DEATHS_RECOVERED,
44
42
  rows: rows
45
43
  )
46
44
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rainbow'
4
-
5
- # Adds text color functionalities to String class
6
4
  class String
7
5
  def paint_white
8
6
  Rainbow(self).white.bg(:black).bold
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
+ require 'carmen'
4
5
  require_relative 'tablelize'
5
6
  require_relative 'cache'
6
7
  require_relative 'uri_builder'
7
8
 
8
9
  module Kovid
9
- # Makes requests to external source to collect cases data
10
10
  class Request
11
11
  COUNTRIES_PATH = UriBuilder.new('/countries').url
12
12
  STATES_URL = UriBuilder.new('/states').url
@@ -110,7 +110,7 @@ module Kovid
110
110
  end
111
111
 
112
112
  def state(state)
113
- response = fetch_state(state)
113
+ response = fetch_state(Kovid.lookup_us_state(state))
114
114
  if response.nil?
115
115
  not_found(state)
116
116
  else
@@ -122,7 +122,6 @@ module Kovid
122
122
 
123
123
  def states(states)
124
124
  compared_states = fetch_compared_states(states)
125
-
126
125
  Kovid::Tablelize.compare_us_states(compared_states)
127
126
  rescue JSON::ParserError
128
127
  puts SERVER_DOWN
@@ -205,10 +204,10 @@ module Kovid
205
204
  end
206
205
 
207
206
  def fetch_compared_states(submitted_states)
208
- state_data = fetch_state_data
207
+ submitted_states.map! { |s| Kovid.lookup_us_state(s) }
209
208
 
210
- state_data.select do |state|
211
- submitted_states.include?(state['state'].downcase)
209
+ fetch_state_data.select do |state|
210
+ submitted_states.include?(state['state'])
212
211
  end
213
212
  end
214
213
 
@@ -218,9 +217,7 @@ module Kovid
218
217
 
219
218
  def fetch_country(country_name)
220
219
  # TODO: Match ISOs to full country names
221
- if country_name == "netherlands"
222
- country_name = "nl"
223
- end
220
+ country_name = 'nl' if country_name == 'netherlands'
224
221
  country_url = COUNTRIES_PATH + "/#{country_name}"
225
222
 
226
223
  JSON.parse(Typhoeus.get(country_url, cache_ttl: 900).response_body)
@@ -9,7 +9,6 @@ require_relative 'aggregators'
9
9
  require_relative 'historians'
10
10
 
11
11
  module Kovid
12
- # Constructs the tables according to specified input
13
12
  class Tablelize
14
13
  extend Kovid::Constants
15
14
  extend Kovid::Aggregators
@@ -3,7 +3,6 @@
3
3
  require 'uri'
4
4
 
5
5
  module Kovid
6
- # Prepares base URI before requests
7
6
  class UriBuilder
8
7
  attr_reader :path
9
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.6.6'
4
+ VERSION = '0.6.7'
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.6
4
+ version: 0.6.7
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-11 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ascii_charts