kovid 0.1.6 → 0.1.11

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: 29a085cad77bc261e7c65efbddbff9af592c328e2e980ce785a868ce1f7dd88d
4
- data.tar.gz: 310c0a2f5139cc26fa0a20159d8fb5ad3b141722f4e28360e67ad89afd9a6763
3
+ metadata.gz: 69bb9029da31d65ec61e33aca03f1e8719105ae941b37be509761d6b64823d85
4
+ data.tar.gz: c1e49c8b5323ef9e0db516ec6a9b55ab5c906127a6d090accc4afac62d0bd69d
5
5
  SHA512:
6
- metadata.gz: 4225dbced44ac4a1c6cde1c5aea535a626f9df380e06cc2960c8c9c2be104508ca5b8818b44470f0b1af605714a168e2ef3ad73cbd5524fe80bc455558b85c75
7
- data.tar.gz: b890a173fca7a3c34f103954d6f3f97c43e286d4b99dc57dffadbb772dd4dd487743bf81db32e36b938534698465a7fe51d6995d480407b8a7edecd22c081f4b
6
+ metadata.gz: c2bdf77245d95fd7784e6592c390164160b2042d098d713636100efb46f4662973ac0b066a62fed4b8a2f28c4b6e22e277a93b6789856ab56d201213ec14ac77
7
+ data.tar.gz: 33b3716e9cb1f5308ae457a0c5d64720cfe120e52c89d2d1a8a2d3dba01ad5eeb8224e750b8dd82e8d58c7e4d255d04a0e45d3167254e4a2ef15521ca3f3f47b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.1.4)
4
+ kovid (0.1.10)
5
5
  terminal-table
6
6
  thor
7
7
  typhoeus
@@ -38,6 +38,7 @@ GEM
38
38
  cucumber-tag_expressions (1.1.1)
39
39
  cucumber-wire (0.0.1)
40
40
  diff-lcs (1.3)
41
+ docile (1.3.2)
41
42
  ethon (0.12.0)
42
43
  ffi (>= 1.3.0)
43
44
  ffi (1.12.2)
@@ -62,6 +63,10 @@ GEM
62
63
  diff-lcs (>= 1.2.0, < 2.0)
63
64
  rspec-support (~> 3.9.0)
64
65
  rspec-support (3.9.2)
66
+ simplecov (0.18.5)
67
+ docile (~> 1.1)
68
+ simplecov-html (~> 0.11)
69
+ simplecov-html (0.12.2)
65
70
  terminal-table (1.8.0)
66
71
  unicode-display_width (~> 1.1, >= 1.1.1)
67
72
  thor (1.0.1)
@@ -79,6 +84,7 @@ DEPENDENCIES
79
84
  pry
80
85
  rake (~> 12.0)
81
86
  rspec (~> 3.0)
87
+ simplecov
82
88
 
83
89
  BUNDLED WITH
84
90
  2.1.2
data/README.md CHANGED
@@ -12,31 +12,40 @@ Before installing:
12
12
 
13
13
  ☝️ Wash your hands with soap and water for at least 20 seconds.
14
14
 
15
- ✌️ Run `$ gem install kovid`
15
+ ✌️ Run `gem install kovid`
16
16
 
17
17
 
18
18
  After installing:
19
19
 
20
20
  ☝️ Avoid touching your eyes, nose and mouth with unwashed hands later.
21
21
 
22
- ✌️ Disinfect your phones, keys, doorknobs and anything you touch often than you should.
22
+ ✌️ Disinfect your phones, keys, doorknobs and anything you touch more often than you should.
23
23
 
24
24
 
25
25
 
26
26
  ## ⚒️ Usage
27
27
 
28
+ You can run `kovid --help` to see the full list of available commands.
29
+
28
30
  #### Commands Overview
29
- **Fetching**
30
- * `kovid check ghana`.
31
+ 😷 **Fetching**
32
+ * `kovid check ghana`
31
33
  * `kovid check ghana -f` OR `kovid check ghana --full`
32
34
 
33
- **Comparing**
34
- * `kovid compare ghana poland`
35
- * `kovid compare ghana poland -f` OR `kovid compare ghana poland --full`
35
+ 🇺🇸You can fetch US state-specific data 🇺🇸
36
+ * `kovid state colorado` OR `kovid state "north carolina"`
37
+
38
+ 😷 **Comparing**
39
+ * `kovid compare ghana poland` (sorts by cases DESC)
40
+ * `kovid compare ghana poland -f` OR `kovid compare ghana poland --full` (sorts by cases DESC)
41
+
42
+ You can compare as many countries as you want.
36
43
 
37
- **Total figures**
44
+ 😷 **Total figures**
38
45
  * `kovid cases`
39
46
 
47
+ **PS:** If you find it irritating to have to type `kovid state michigan`, I got your back, `covid state michigan` will work as well.
48
+
40
49
 
41
50
 
42
51
  #### Commands Details
@@ -62,9 +71,15 @@ To compare country stats:
62
71
 
63
72
  To compare a countries stats with a full table:
64
73
 
65
- `kovid compare ghana poland -f` OR `kovid compare ghana poland --full`
74
+ `kovid compare poland italy usa china -f` OR `kovid compare poland italy usa china --full`
75
+
76
+ ![kovid](https://i.gyazo.com/7ce86c5e93d549e1412fb6104a1d7877.png "Covid data.")
66
77
 
67
- ![kovid](https://i.gyazo.com/d0b72207765090b118a5b76d72ddde19.png "Covid data.")
78
+ To fetch state-specific data run:
79
+
80
+ `kovid state colorado`
81
+
82
+ ![kovid](https://i.gyazo.com/133046d9d31c20a8bad1a05b46ba4d3e.png "Covid data.")
68
83
 
69
84
  To check for total figures:
70
85
 
@@ -72,15 +87,19 @@ To check for total figures:
72
87
 
73
88
  ![kovid](https://i.gyazo.com/f8a21ae54152cd945fbb124b72d12ff7.png "Covid data.")
74
89
 
90
+ ## Source
91
+ > https://www.worldometers.info/coronavirus/
92
+
75
93
  ## 👨‍💻 Development
76
94
 
77
95
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
96
 
79
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
97
+ To install this gem onto your local machine, run `bundle exec rake install`.
98
+
80
99
 
81
100
  ## 🤲 Contributing
82
101
 
83
- Bug reports and pull requests are welcome on GitHub at https://github.com/siaw23/kovid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/siaw23/kovid/blob/master/CODE_OF_CONDUCT.md).
102
+ There are multiple areas in this repo that can be improved or use some refactoring and for that's why bug reports and pull requests are welcome here on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/siaw23/kovid/blob/master/CODE_OF_CONDUCT.md).
84
103
 
85
104
 
86
105
  ## 🔖 License
@@ -89,4 +108,4 @@ The gem is available as open-source under the terms of the [MIT License](https:/
89
108
 
90
109
  ## ❤️ Code of Conduct
91
110
 
92
- Everyone interacting in the Kovid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/siaw23/kovid/blob/master/CODE_OF_CONDUCT.md).
111
+ Everyone interacting in the Kovid project's codebases and issue trackers is expected to follow the [code of conduct](https://github.com/siaw23/kovid/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'kovid/cli'
3
+
4
+ Kovid::CLI.start
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "pry"
35
35
  spec.add_development_dependency "cucumber"
36
36
  spec.add_development_dependency "aruba"
37
+ spec.add_development_dependency "simplecov"
37
38
  end
@@ -4,5 +4,6 @@ require 'kovid/version'
4
4
  require 'kovid/nineteen'
5
5
 
6
6
  module Kovid
7
+ require 'pry'
7
8
  class Error < StandardError; end
8
9
  end
@@ -5,34 +5,39 @@ require 'kovid'
5
5
 
6
6
  module Kovid
7
7
  class CLI < Thor
8
- desc 'whatis', 'Defines COVID-19'
9
- def definition
10
- Kovid::Nineteen.whatis
8
+ desc 'define', 'Defines COVID-19'
9
+ def define
10
+ puts Kovid::Nineteen.whatis
11
11
  end
12
12
 
13
- desc 'check', 'Returns data on country'
13
+ desc 'check COUNTRY', 'Returns reported data on provided country'
14
14
  method_option :full, aliases: '-f'
15
15
  def check(name)
16
16
  if options[:full]
17
- Kovid::Nineteen.country_full(name)
17
+ puts Kovid::Nineteen.country_full(name)
18
18
  else
19
- Kovid::Nineteen.country(name)
19
+ puts Kovid::Nineteen.country(name)
20
20
  end
21
21
  end
22
22
 
23
- desc 'compare', 'Returns full comparison table for given countries'
23
+ desc 'state STATE', 'Return reported data on provided state'
24
+ def state(state)
25
+ puts Kovid::Nineteen.state(state)
26
+ end
27
+
28
+ desc 'compare COUNTRY COUNTRY', 'Returns full comparison table for given countries. Accepts multiple countries'
24
29
  def compare(*name)
25
30
  if name[-1] == '-f' || name[-1] == '--full'
26
31
  name = name.reverse.drop(1).reverse
27
- Kovid::Nineteen.country_comparison_full(name)
32
+ puts Kovid::Nineteen.country_comparison_full(name)
28
33
  else
29
- Kovid::Nineteen.country_comparison(name)
34
+ puts Kovid::Nineteen.country_comparison(name)
30
35
  end
31
36
  end
32
37
 
33
38
  desc 'cases', 'Returns total number of cases, deaths and recoveries'
34
39
  def cases
35
- Kovid::Nineteen.cases
40
+ puts Kovid::Nineteen.cases
36
41
  end
37
42
  end
38
43
  end
@@ -6,27 +6,31 @@ module Kovid
6
6
  class Nineteen
7
7
  class << self
8
8
  def whatis
9
- puts 'Coronavirus disease (COVID-19) is an infectious disease caused by a new virus.'
9
+ 'Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).'
10
10
  end
11
11
 
12
12
  def country(name)
13
- puts Kovid::Request.by_country(name)
13
+ Kovid::Request.by_country(name)
14
14
  end
15
15
 
16
16
  def country_full(name)
17
- puts Kovid::Request.by_country_full(name)
17
+ Kovid::Request.by_country_full(name)
18
18
  end
19
19
 
20
- def country_comparison(name)
21
- puts Kovid::Request.by_country_comparison(name)
20
+ def state(state)
21
+ Kovid::Request.state(state)
22
22
  end
23
23
 
24
- def country_comparison_full(name)
25
- puts Kovid::Request.by_country_comparison_full(name)
24
+ def country_comparison(names_array)
25
+ Kovid::Request.by_country_comparison(names_array)
26
+ end
27
+
28
+ def country_comparison_full(names_array)
29
+ Kovid::Request.by_country_comparison_full(names_array)
26
30
  end
27
31
 
28
32
  def cases
29
- puts Kovid::Request.cases
33
+ Kovid::Request.cases
30
34
  end
31
35
  end
32
36
  end
@@ -9,52 +9,56 @@ module Kovid
9
9
  BASE_URL = 'https://corona.lmao.ninja'
10
10
 
11
11
  class << self
12
- require 'pry'
13
- def by_country(name)
14
- # path = "/countries/#{name}"
15
- # fetch_url = BASE_URL + path
12
+ def by_country(country_name)
13
+ response = fetch_country(country_name)
16
14
 
17
- # binding.pry
18
- # response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
19
- # Kovid::Tablelize.country_table(response)
20
-
21
- begin
22
- path = "/countries/#{name}"
23
- fetch_url = BASE_URL + path
15
+ Kovid::Tablelize.country_table(response)
16
+ rescue JSON::ParserError
17
+ no_case_in(country_name)
18
+ end
24
19
 
25
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
26
- Kovid::Tablelize.country_table(response)
20
+ def by_country_full(country_name)
21
+ response = fetch_country(country_name)
27
22
 
28
- rescue JSON::ParserError
29
- rows = []
30
- rows << ["Thankfully there are no reported cases in #{name.capitalize}!"]
31
- table = Terminal::Table.new :headings => ["#{name}",], :rows => rows
32
- puts table
33
- end
23
+ Kovid::Tablelize.full_country_table(response)
24
+ rescue JSON::ParserError
25
+ no_case_in(country_name)
34
26
  end
35
27
 
36
- def by_country_full(name)
37
- path = "/countries/#{name}"
38
- fetch_url = BASE_URL + path
28
+ def state(state)
29
+ response = fetch_state(state)
39
30
 
40
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
41
- Kovid::Tablelize.full_country_table(response)
31
+ Kovid::Tablelize.full_state_table(response)
42
32
  end
43
33
 
44
34
  def by_country_comparison(list)
45
- array = []
35
+ array = fetch_countries(list)
36
+ Kovid::Tablelize.compare_countries_table(array)
37
+ end
46
38
 
47
- list.each do |country|
48
- path = "/countries/#{country}"
49
- fetch_url = BASE_URL + path
39
+ def by_country_comparison_full(list)
40
+ array = fetch_countries(list)
41
+ Kovid::Tablelize.compare_countries_table_full(array)
42
+ end
50
43
 
51
- array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
52
- end
44
+ def cases
45
+ path = '/all'
46
+ fetch_url = BASE_URL + path
53
47
 
54
- Kovid::Tablelize.compare_countries_table(array)
48
+ response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
49
+ Kovid::Tablelize.cases(response)
55
50
  end
56
51
 
57
- def by_country_comparison_full(list)
52
+ private
53
+
54
+ def no_case_in(country)
55
+ rows = []
56
+ rows << ["Thankfully, there are no reported cases in #{country.capitalize}!"]
57
+ table = Terminal::Table.new headings: [country.capitalize.to_s], rows: rows
58
+ table
59
+ end
60
+
61
+ def fetch_countries(list)
58
62
  array = []
59
63
 
60
64
  list.each do |country|
@@ -64,15 +68,23 @@ module Kovid
64
68
  array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
65
69
  end
66
70
 
67
- Kovid::Tablelize.compare_countries_table_full(array)
71
+ array = array.sort_by { |json| -json['cases'] }
68
72
  end
69
73
 
70
- def cases
71
- path = '/all'
74
+ def fetch_country(country_name)
75
+ path = "/countries/#{country_name}"
72
76
  fetch_url = BASE_URL + path
73
77
 
74
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
75
- Kovid::Tablelize.cases(response)
78
+ JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
79
+ end
80
+
81
+ def fetch_state(state)
82
+ path = '/states'
83
+ fetch_url = BASE_URL + path
84
+
85
+ states_array = JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
86
+
87
+ states_array.select { |state_name| state_name['state'] == state.split.map(&:capitalize).join(' ') }.first
76
88
  end
77
89
  end
78
90
  end
@@ -9,7 +9,7 @@ module Kovid
9
9
  headings = %w[Cases Deaths Recovered]
10
10
  rows = []
11
11
  rows << [data['cases'], data['deaths'], data['recovered']]
12
- puts Terminal::Table.new(title: data['country'], headings: headings, rows: rows)
12
+ Terminal::Table.new(title: data['country'], headings: headings, rows: rows)
13
13
  end
14
14
 
15
15
  def full_country_table(data)
@@ -33,9 +33,16 @@ module Kovid
33
33
  data['critical'],
34
34
  data['casesPerOneMillion']
35
35
  ]
36
- puts Terminal::Table.new(title: data['country'],
37
- headings: headings,
38
- rows: rows)
36
+ Terminal::Table.new(title: data['country'],
37
+ headings: headings,
38
+ rows: rows)
39
+ end
40
+
41
+ def full_state_table(state)
42
+ headings = ['Cases', 'Cases Today', 'Deaths', 'Deaths Today', 'Reovered', 'Active']
43
+ rows = []
44
+ rows << [state['cases'], state['todayCases'], state['deaths'], state['todayDeaths'], state['recovered'], state['active']]
45
+ Terminal::Table.new(title: state['state'], headings: headings, rows: rows)
39
46
  end
40
47
 
41
48
  def compare_countries_table(data)
@@ -46,18 +53,36 @@ module Kovid
46
53
  rows << [country['country'], country['cases'], country['deaths'], country['recovered']]
47
54
  end
48
55
 
49
- puts Terminal::Table.new(headings: headings, rows: rows)
56
+ Terminal::Table.new(headings: headings, rows: rows)
50
57
  end
51
58
 
52
59
  def compare_countries_table_full(data)
53
- headings = ['Country', 'Cases', 'Deaths', 'Recovered', 'Cases Today', 'Deaths Today', 'Critical', 'Cases/Million']
60
+ headings = [
61
+ 'Country',
62
+ 'Cases',
63
+ 'Deaths',
64
+ 'Recovered',
65
+ 'Cases Today',
66
+ 'Deaths Today',
67
+ 'Critical',
68
+ 'Cases/Million'
69
+ ]
54
70
  rows = []
55
71
 
56
72
  data.each do |country|
57
- rows << [country['country'], country['cases'], country['deaths'], country['recovered'], country['todayCases'], country['todayDeaths'], country['critical'], country['casesPerOneMillion']]
73
+ rows << [
74
+ country['country'],
75
+ country['cases'],
76
+ country['deaths'],
77
+ country['recovered'],
78
+ country['todayCases'],
79
+ country['todayDeaths'],
80
+ country['critical'],
81
+ country['casesPerOneMillion']
82
+ ]
58
83
  end
59
84
 
60
- puts Terminal::Table.new(headings: headings, rows: rows)
85
+ Terminal::Table.new(headings: headings, rows: rows)
61
86
  end
62
87
 
63
88
  def cases(cases)
@@ -66,7 +91,7 @@ module Kovid
66
91
  rows = []
67
92
 
68
93
  rows << [cases['cases'], cases['deaths'], cases['recovered']]
69
- puts Terminal::Table.new(title: "Total # of incidents", headings: headings, rows: rows)
94
+ Terminal::Table.new(title: 'Total # of incidents', headings: headings, rows: rows)
70
95
  end
71
96
  end
72
97
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.11'
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.1.6
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-21 00:00:00.000000000 Z
11
+ date: 2020-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -94,11 +94,26 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: A CLI tool to fetch and compare the 2019 coronavirus pandemic numbers.
98
112
  email:
99
113
  - siawmensah@gmail.com
100
114
  executables:
101
115
  - console
116
+ - covid
102
117
  - kovid
103
118
  - setup
104
119
  extensions: []
@@ -114,6 +129,7 @@ files:
114
129
  - README.md
115
130
  - Rakefile
116
131
  - bin/console
132
+ - bin/covid
117
133
  - bin/kovid
118
134
  - bin/setup
119
135
  - kovid.gemspec