kovid 0.1.7 → 0.1.12

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: 6704e68fddf1650cddcc75fcaafebc00116ff3f77fa65d3564a276a3bbd0f464
4
- data.tar.gz: 276f9690e3066acb36c9a8dda80e8cd018b64f311028293083fd9735e0d422a2
3
+ metadata.gz: 7caa822059f633a6c539b81680b1687316c7c426df826db701fb3c4f8f6e6d2c
4
+ data.tar.gz: 52aced813f2ae8b7c15a9db83e660dec7dc25e8ce6da56a196b11b24718bf93d
5
5
  SHA512:
6
- metadata.gz: 1046f127ecd5edabc409f59a0df757ddb267405b3909306d811680de6dad7c7a4551b165bbeb88c9bce4bc0b2e8ffccdbea5cc96cb602611073d8ff5144ab7c8
7
- data.tar.gz: 0e9e3b798436cc005aa55dafbc4fa219d7144fc7d293c1449ac1519c920a4b3ec09624476ff4b68f2099014ed75bb46aa752e13f88fbace1581fa65031d6b011
6
+ metadata.gz: 495ce23620686e3945b5d60b71fd7967969f4eb45fe4010f79296d720c87566d968989175c2163016d7b228c3ab0fa37887c7fae46e10538c51006637626775c
7
+ data.tar.gz: 64f22c450cecd6fa413c95a09676b8a3b052c018d611903b898a63c2675a9623e960fe08e6dfa3212e2dc5def2663c8db23a113fa6059b33cf9caa949fb5bcef
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kovid (0.1.4)
4
+ kovid (0.1.11)
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,29 +12,38 @@ 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
+
30
+ **NOTE:** If you find it irritating to have to type `kovid state michigan`, `covid state michigan` works as well.
31
+
28
32
  #### Commands Overview
29
- **Fetching**
30
- * `kovid check ghana`.
33
+ 😷 **Fetching**
34
+ * `kovid check ghana`
31
35
  * `kovid check ghana -f` OR `kovid check ghana --full`
32
36
 
33
- **Comparing**
34
- * `kovid compare ghana poland`
35
- * `kovid compare ghana poland -f` OR `kovid compare ghana poland --full`
37
+ 🇺🇸You can fetch US state-specific data 🇺🇸
38
+ * `kovid state colorado` OR `kovid state "north carolina"`
39
+
40
+ 😷 **Comparing**
41
+ * `kovid compare ghana poland` (sorts by cases DESC)
42
+ * `kovid compare ghana poland -f` OR `kovid compare ghana poland --full` (sorts by cases DESC)
36
43
 
37
- **Total figures**
44
+ You can compare as many countries as you want.
45
+
46
+ 😷 **Total figures**
38
47
  * `kovid cases`
39
48
 
40
49
 
@@ -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,20 @@ 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/ via [NovelCOVID/API](https://github.com/novelcovid/api)
92
+
93
+
75
94
  ## 👨‍💻 Development
76
95
 
77
96
  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
97
 
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).
98
+ To install this gem onto your local machine, run `bundle exec rake install`.
99
+
80
100
 
81
101
  ## 🤲 Contributing
82
102
 
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).
103
+ There are multiple areas in this repo that can be improved or use some refactoring. For that reason, 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
104
 
85
105
 
86
106
  ## 🔖 License
@@ -89,4 +109,4 @@ The gem is available as open-source under the terms of the [MIT License](https:/
89
109
 
90
110
  ## ❤️ Code of Conduct
91
111
 
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).
112
+ 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).
File without changes
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'kovid/cli'
3
+
4
+ Kovid::CLI.start
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  end
26
- spec.bindir = "bin"
27
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "thor"
@@ -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,46 +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
- begin
15
- path = "/countries/#{name}"
16
- fetch_url = BASE_URL + path
12
+ def by_country(country_name)
13
+ response = fetch_country(country_name)
17
14
 
18
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
19
- Kovid::Tablelize.country_table(response)
15
+ Kovid::Tablelize.country_table(response)
16
+ rescue JSON::ParserError
17
+ no_case_in(country_name)
18
+ end
20
19
 
21
- rescue JSON::ParserError
22
- no_case_in(name)
23
- end
20
+ def by_country_full(country_name)
21
+ response = fetch_country(country_name)
22
+
23
+ Kovid::Tablelize.full_country_table(response)
24
+ rescue JSON::ParserError
25
+ no_case_in(country_name)
24
26
  end
25
27
 
26
- def by_country_full(name)
27
- begin
28
- path = "/countries/#{name}"
29
- fetch_url = BASE_URL + path
28
+ def state(state)
29
+ response = fetch_state(state)
30
30
 
31
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
32
- Kovid::Tablelize.full_country_table(response)
33
- rescue JSON::ParserError
34
- no_case_in(name)
35
- end
31
+ Kovid::Tablelize.full_state_table(response)
36
32
  end
37
33
 
38
34
  def by_country_comparison(list)
39
- array = []
35
+ array = fetch_countries(list)
36
+ Kovid::Tablelize.compare_countries_table(array)
37
+ end
40
38
 
41
- list.each do |country|
42
- path = "/countries/#{country}"
43
- 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
44
43
 
45
- array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
46
- end
44
+ def cases
45
+ path = '/all'
46
+ fetch_url = BASE_URL + path
47
47
 
48
- 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)
49
50
  end
50
51
 
51
- 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)
52
62
  array = []
53
63
 
54
64
  list.each do |country|
@@ -58,24 +68,23 @@ module Kovid
58
68
  array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
59
69
  end
60
70
 
61
- Kovid::Tablelize.compare_countries_table_full(array)
71
+ array = array.sort_by { |json| -json['cases'] }
62
72
  end
63
73
 
64
- def cases
65
- path = '/all'
74
+ def fetch_country(country_name)
75
+ path = "/countries/#{country_name}"
66
76
  fetch_url = BASE_URL + path
67
77
 
68
- response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
69
- Kovid::Tablelize.cases(response)
78
+ JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
70
79
  end
71
80
 
72
- private
81
+ def fetch_state(state)
82
+ path = '/states'
83
+ fetch_url = BASE_URL + path
73
84
 
74
- def no_case_in(country)
75
- rows = []
76
- rows << ["Thankfully there are no reported cases in #{country.capitalize}!"]
77
- table = Terminal::Table.new :headings => ["#{country.capitalize}",], :rows => rows
78
- puts table
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
79
88
  end
80
89
  end
81
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.7'
4
+ VERSION = '0.1.12'
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.7
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
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,13 +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
- - console
115
+ - covid
102
116
  - kovid
103
- - setup
104
117
  extensions: []
105
118
  extra_rdoc_files: []
106
119
  files:
@@ -114,8 +127,9 @@ files:
114
127
  - README.md
115
128
  - Rakefile
116
129
  - bin/console
117
- - bin/kovid
118
130
  - bin/setup
131
+ - exe/covid
132
+ - exe/kovid
119
133
  - kovid.gemspec
120
134
  - lib/kovid.rb
121
135
  - lib/kovid/cli.rb