kovid 0.6.14 โ†’ 0.7.1

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: 2896f04560ac519045555f79fc0d8cdcbcee7ed9069aecd1ebdbcba181584927
4
- data.tar.gz: fe15af9091b1a03ae8ac6a78e712c5a7dc7dd1a7b433e45b9c6bdad05c709f22
3
+ metadata.gz: 4cfebd50118e5a9ef72a66b077d5a35308f346eef761d0cfc243f55ada7ca92c
4
+ data.tar.gz: 0f99a32311c5cb41dfddc89bbc2c1605d2de6a9e5a3e6d828f48bbecba9420ad
5
5
  SHA512:
6
- metadata.gz: 9a4260377fa1d38f2b9dd9f7b94bdcf3527e437f2c89e15d15d1a0b87df11a09934baa56a6d8b13f1e1a588b0590b4a1646f7ca6f9c96a141f1b2178054bc358
7
- data.tar.gz: c9c313cf8982980845c5d73d5da9e9d9cab82738825762bbceb3a07e511f7ccae1d12516cadd80bfb86fa88c8a2dd4b58615db396a0ba901d7fa94fbddcd21c7
6
+ metadata.gz: 605ae8aa65d02bcbef69b311642ef734da4f8671828e368893e756107a48ae3610dcb7bd323f83f8f9f5ab85123f8ef10ba0ab44ed5d2466640beab4acff0993
7
+ data.tar.gz: 35e5693621a1be4cd0f055e0a77a7071e26dc6dec0eb0860aeb278ae22d1d5ac2f200c6942e7628038236db1a84d1b22d46843e14060d4393ebf3839be2f5d67
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.6.13)
5
- carmen (~> 1.1.3)
4
+ kovid (0.7.0)
6
5
  rainbow (~> 3.0)
7
6
  terminal-table (~> 1.8)
8
7
  thor (~> 1.0)
@@ -11,24 +10,12 @@ PATH
11
10
  GEM
12
11
  remote: https://rubygems.org/
13
12
  specs:
14
- activesupport (6.0.3.1)
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, >= 2.2.2)
20
- carmen (1.1.3)
21
- activesupport (>= 3.0.0)
22
- concurrent-ruby (1.1.6)
23
13
  diff-lcs (1.3)
24
14
  docile (1.3.2)
25
- ethon (0.12.0)
26
- ffi (>= 1.3.0)
27
- ffi (1.13.0)
28
- i18n (1.8.3)
29
- concurrent-ruby (~> 1.0)
30
- minitest (5.14.1)
31
- rainbow (3.0.0)
15
+ ethon (0.15.0)
16
+ ffi (>= 1.15.0)
17
+ ffi (1.15.5)
18
+ rainbow (3.1.1)
32
19
  rake (12.3.3)
33
20
  rspec (3.9.0)
34
21
  rspec-core (~> 3.9.0)
@@ -49,14 +36,10 @@ GEM
49
36
  simplecov-html (0.12.2)
50
37
  terminal-table (1.8.0)
51
38
  unicode-display_width (~> 1.1, >= 1.1.1)
52
- thor (1.0.1)
53
- thread_safe (0.3.6)
39
+ thor (1.2.1)
54
40
  typhoeus (1.4.0)
55
41
  ethon (>= 0.9.0)
56
- tzinfo (1.2.7)
57
- thread_safe (~> 0.1)
58
- unicode-display_width (1.7.0)
59
- zeitwerk (2.3.0)
42
+ unicode-display_width (1.8.0)
60
43
 
61
44
  PLATFORMS
62
45
  ruby
@@ -68,4 +51,4 @@ DEPENDENCIES
68
51
  simplecov (~> 0.18)
69
52
 
70
53
  BUNDLED WITH
71
- 2.1.4
54
+ 2.3.9
data/README.md CHANGED
@@ -85,10 +85,6 @@ ___
85
85
 
86
86
  **NOTE:** If you find it irritating to have to type `kovid state STATE`, `covid state STATE` works as well.
87
87
 
88
- #### Histogram (Experimental) ๐Ÿงช
89
-
90
- `kovid histogram COUNTRY M.YY` (draws a histogram of cases in the given month `M` and years `YY`)
91
- (If the histogram appears messy, you might want to resize your window.)
92
88
 
93
89
  #### Commands Details
94
90
  To fetch basic data on a country run:
@@ -171,12 +167,6 @@ To fetch more number of countries or US states you can pass N. eg:
171
167
 
172
168
  ![kovid](https://i.gyazo.com/64663ff25c1ff61701e84871948640f4.png "Covid data.")
173
169
 
174
- ## ๐Ÿ‘ฉ๐Ÿพโ€๐Ÿ”ฌ Experimental Feature
175
-
176
- `kovid histogram italy 3.20` tries to build a histogram on number of cases. In the example here `3.20` is date in the format of `M.YY`. If you can please play with it and report issues on how this could be improved.
177
-
178
- ![kovid](https://i.gyazo.com/35833cba37be8ca10830fad066b85bb3.png "Covid data.")
179
-
180
170
 
181
171
  ## Data Source
182
172
  > [JHU CSSE GISand Data](https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6) and https://www.worldometers.info/coronavirus/ via [NovelCOVID/API](https://github.com/novelcovid/api)
data/kovid.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = summary
15
15
  spec.homepage = 'https://github.com/siaw23/kovid'
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
17
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
18
18
 
19
19
  spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
20
20
 
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.metadata['source_code_uri'] = 'https://github.com/siaw23/kovid'
23
23
  spec.metadata['changelog_uri'] = 'https://github.com/siaw23/kovid'
24
24
 
25
- spec.add_dependency 'carmen', '~> 1.1.3'
26
25
  spec.add_dependency 'rainbow', '~> 3.0'
27
26
  spec.add_dependency 'terminal-table', '~> 1.8'
28
27
  spec.add_dependency 'thor', '~> 1.0'
@@ -40,23 +39,4 @@ Gem::Specification.new do |spec|
40
39
  spec.bindir = 'exe'
41
40
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
42
41
  spec.require_paths = ['lib']
43
-
44
- spec.post_install_message = "
45
- ============================================================================
46
- COVID-19 has devasted the world. While we're fighting
47
- with the novel coronavirus, I think stats on the issue should be
48
- accessible.
49
-
50
- There isn't much we can do now besides following procedures and hoping
51
- for the best.
52
-
53
- Stay safe!
54
- Emmanuel Hayford.
55
- https://emmanuelhayford.com
56
-
57
- PS: I'm in search of a Rails/Ruby job.
58
-
59
- You can hire me (siawmensah@gmail.com).
60
- ============================================================================
61
- "
62
42
  end
@@ -44,11 +44,13 @@ module Kovid
44
44
  COMPARE_COUNTRY_TABLE_FULL = [
45
45
  'Country'.paint_white,
46
46
  'Cases'.paint_white,
47
- 'Deaths'.paint_red,
48
- 'Recovered'.paint_green,
49
47
  'Cases Today'.paint_white,
48
+ 'Deaths'.paint_red,
50
49
  'Deaths Today'.paint_red,
50
+ 'Active'.paint_yellow,
51
+ 'Recovered'.paint_green,
51
52
  'Critical'.paint_yellow,
53
+ 'Tests'.paint_white,
52
54
  'Cases/Million'.paint_white
53
55
  ].freeze
54
56
 
@@ -58,6 +60,7 @@ module Kovid
58
60
  'Cases Today'.paint_white,
59
61
  'Deaths'.paint_red,
60
62
  'Deaths Today'.paint_red,
63
+ 'Active'.paint_yellow,
61
64
  'Recovered'.paint_green,
62
65
  'Tests'.paint_white
63
66
  ].freeze
@@ -69,8 +72,8 @@ module Kovid
69
72
  'Deaths Today'.paint_red,
70
73
  'Active'.paint_yellow,
71
74
  'Recovered'.paint_green,
72
- 'Tests'.paint_white,
73
75
  'Critical'.paint_yellow,
76
+ 'Tests'.paint_white,
74
77
  'Cases/Million'.paint_white
75
78
  ].freeze
76
79
 
@@ -124,5 +127,63 @@ module Kovid
124
127
  compare_us_states: [1, 2, 3, 4, 5],
125
128
  compare_provinces: [1, 2, 3]
126
129
  }.freeze
130
+
131
+ USA_ABBREVIATIONS = {
132
+ "al" => "Alabama",
133
+ "ak" => "Alaska",
134
+ "az" => "Arizona",
135
+ "ar" => "Arkansas",
136
+ "ca" => "California",
137
+ "cz" => "Canal Zone",
138
+ "co" => "Colorado",
139
+ "ct" => "Connecticut",
140
+ "de" => "Delaware",
141
+ "dc" => "District of Columbia",
142
+ "fl" => "Florida",
143
+ "ga" => "Georgia",
144
+ "gu" => "Guam",
145
+ "hi" => "Hawaii",
146
+ "id" => "Idaho",
147
+ "il" => "Illinois",
148
+ "in" => "Indiana",
149
+ "ia" => "Iowa",
150
+ "ks" => "Kansas",
151
+ "ky" => "Kentucky",
152
+ "la" => "Louisiana",
153
+ "me" => "Maine",
154
+ "md" => "Maryland",
155
+ "ma" => "Massachusetts",
156
+ "mi" => "Michigan",
157
+ "mn" => "Minnesota",
158
+ "ms" => "Mississippi",
159
+ "mo" => "Missouri",
160
+ "mt" => "Montana",
161
+ "ne" => "Nebraska",
162
+ "nv" => "Nevada",
163
+ "nh" => "New Hampshire",
164
+ "nj" => "New Jersey",
165
+ "nm" => "New Mexico",
166
+ "ny" => "New York",
167
+ "nc" => "North Carolina",
168
+ "nd" => "North Dakota",
169
+ "oh" => "Ohio",
170
+ "ok" => "Oklahoma",
171
+ "or" => "Oregon",
172
+ "pa" => "Pennsylvania",
173
+ "pr" => "Puerto Rico",
174
+ "ri" => "Rhode Island",
175
+ "sc" => "South Carolina",
176
+ "sd" => "South Dakota",
177
+ "tn" => "Tennessee",
178
+ "tx" => "Texas",
179
+ "ut" => "Utah",
180
+ "vt" => "Vermont",
181
+ "vi" => "Virgin Islands",
182
+ "va" => "Virginia",
183
+ "wa" => "Washington",
184
+ "wv" => "West Virginia",
185
+ "wi" => "Wisconsin",
186
+ "wy" => "Wyoming"
187
+ }
127
188
  end
128
189
  end
data/lib/kovid/helpers.rb CHANGED
@@ -26,8 +26,6 @@ module Kovid
26
26
  end
27
27
 
28
28
  def lookup_us_state(state)
29
- us = Carmen::Country.coded('USA')
30
- lookup = us.subregions.coded(state) || us.subregions.named(state)
31
- lookup ? lookup.name : state
29
+ Kovid::Constants::USA_ABBREVIATIONS.fetch(state.downcase, state)
32
30
  end
33
31
  end
@@ -14,7 +14,7 @@ module Kovid
14
14
  end
15
15
 
16
16
  Terminal::Table.new(
17
- title: data['country'].try(:upcase),
17
+ title: data['country']&.upcase,
18
18
  headings: DATE_CASES_DEATHS_RECOVERED,
19
19
  rows: rows
20
20
  )
@@ -29,7 +29,7 @@ module Kovid
29
29
  end
30
30
 
31
31
  Terminal::Table.new(
32
- title: data['state'].try(:upcase),
32
+ title: data['state']&.upcase,
33
33
  headings: DATE_CASES_DEATHS,
34
34
  rows: rows
35
35
  )
data/lib/kovid/request.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'carmen'
4
+ require 'erb'
5
5
  require_relative 'tablelize'
6
6
  require_relative 'cache'
7
7
  require_relative 'uri_builder'
@@ -266,7 +266,7 @@ module Kovid
266
266
  def fetch_country(country_name)
267
267
  # TODO: Match ISOs to full country names
268
268
  country_name = 'nl' if country_name == 'netherlands'
269
- country_url = COUNTRIES_PATH + "/#{country_name}"
269
+ country_url = COUNTRIES_PATH + "/#{ERB::Util.url_encode(country_name)}"
270
270
 
271
271
  JSON.parse(Typhoeus.get(country_url, cache_ttl: 900).response_body)
272
272
  end
@@ -301,7 +301,7 @@ module Kovid
301
301
  def fetch_history(country)
302
302
  JSON.parse(
303
303
  Typhoeus.get(
304
- HISTORICAL_URL + "/#{country}", cache_ttl: 900
304
+ HISTORICAL_URL + "/#{ERB::Util.url_encode(country)}", cache_ttl: 900
305
305
  ).response_body
306
306
  )
307
307
  end
@@ -309,7 +309,7 @@ module Kovid
309
309
  def fetch_us_history(state)
310
310
  JSON.parse(
311
311
  Typhoeus.get(
312
- HISTORICAL_US_URL + "/#{state}", cache_ttl: 900
312
+ HISTORICAL_US_URL + "/#{ERB::Util.url_encode(state)}", cache_ttl: 900
313
313
  ).response_body
314
314
  )
315
315
  end
@@ -124,7 +124,8 @@ module Kovid
124
124
  end
125
125
 
126
126
  def country_emoji(iso)
127
- COUNTRY_LETTERS.values_at(*iso.chars).pack('U*') + \
127
+ #TODO: FIx ZWSP
128
+ COUNTRY_LETTERS.values_at(*iso.chars).pack('U*') + " " + \
128
129
  8203.chr(Encoding::UTF_8)
129
130
  end
130
131
 
@@ -156,9 +157,8 @@ module Kovid
156
157
  Kovid.add_plus_sign(data['todayDeaths']),
157
158
  Kovid.comma_delimit(data['active']),
158
159
  Kovid.comma_delimit(data['recovered']),
159
- Kovid.comma_delimit(data['tests']),
160
-
161
160
  Kovid.comma_delimit(data['critical']),
161
+ Kovid.comma_delimit(data['tests']),
162
162
  Kovid.comma_delimit(data['casesPerOneMillion'])
163
163
  ]
164
164
  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.6.14'
4
+ VERSION = '0.7.1'
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kovid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.14
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-06 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: carmen
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.1.3
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.1.3
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rainbow
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -140,14 +126,7 @@ metadata:
140
126
  homepage_uri: https://github.com/siaw23/kovid
141
127
  source_code_uri: https://github.com/siaw23/kovid
142
128
  changelog_uri: https://github.com/siaw23/kovid
143
- post_install_message: "\n ============================================================================\n
144
- \ COVID-19 has devasted the world. While we're fighting\n with the novel
145
- coronavirus, I think stats on the issue should be\n accessible.\n\n There
146
- isn't much we can do now besides following procedures and hoping\n for the
147
- best.\n\n Stay safe!\n Emmanuel Hayford.\n https://emmanuelhayford.com\n\n
148
- \ PS: I'm in search of a Rails/Ruby job.\n\n You can hire me (siawmensah@gmail.com).\n
149
- \ ============================================================================\n
150
- \ "
129
+ post_install_message:
151
130
  rdoc_options: []
152
131
  require_paths:
153
132
  - lib
@@ -155,15 +134,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
134
  requirements:
156
135
  - - ">="
157
136
  - !ruby/object:Gem::Version
158
- version: 2.4.0
137
+ version: 2.7.0
159
138
  required_rubygems_version: !ruby/object:Gem::Requirement
160
139
  requirements:
161
140
  - - ">="
162
141
  - !ruby/object:Gem::Version
163
142
  version: '0'
164
143
  requirements: []
165
- rubygems_version: 3.1.2
166
- signing_key:
144
+ rubygems_version: 3.2.32
145
+ signing_key:
167
146
  specification_version: 4
168
147
  summary: A CLI to fetch and compare the 2019 coronavirus pandemic statistics.
169
148
  test_files: []