covidstats 0.1.0
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 +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/covidstats +5 -0
- data/bin/setup +8 -0
- data/covidstats.gemspec +44 -0
- data/lib/covidstats.rb +15 -0
- data/lib/covidstats/api.rb +8 -0
- data/lib/covidstats/cli.rb +168 -0
- data/lib/covidstats/continents.rb +99 -0
- data/lib/covidstats/country.rb +50 -0
- data/lib/covidstats/version.rb +3 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69208c0625dbc5c6df9dbe82a9b25be3fdf5ed061803213d82166675a5d73c9f
|
4
|
+
data.tar.gz: 5ad84cca13661991eed0163424a636d6ad62de36f9e81be2589f72392d41410a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd9954202601f7d5dc8e03a27fc4a3c95e101bdb0f60dd6cfe633efc1ab6cd3602fb5899a37d3df5da1a3f6e85bfaafaf67ea0f7784d1f39bf647161f088aaed
|
7
|
+
data.tar.gz: 966f4408d281210f6d7a0404ed0f976d61c7f484189b0ec08700a346b0b4e1aa905e8742b80c5f4bd16244797a6c1b667f5619a3cc985b82556795b46b7484a4
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 'acg2176@columbia.edu'. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
covidstats (0.1.0)
|
5
|
+
colorize
|
6
|
+
httparty
|
7
|
+
tty-prompt
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
colorize (0.8.1)
|
13
|
+
equatable (0.6.1)
|
14
|
+
httparty (0.18.0)
|
15
|
+
mime-types (~> 3.0)
|
16
|
+
multi_xml (>= 0.5.2)
|
17
|
+
mime-types (3.3.1)
|
18
|
+
mime-types-data (~> 3.2015)
|
19
|
+
mime-types-data (3.2020.0512)
|
20
|
+
multi_xml (0.6.0)
|
21
|
+
necromancer (0.5.1)
|
22
|
+
pastel (0.7.4)
|
23
|
+
equatable (~> 0.6)
|
24
|
+
tty-color (~> 0.5)
|
25
|
+
rake (12.3.3)
|
26
|
+
tty-color (0.5.1)
|
27
|
+
tty-cursor (0.7.1)
|
28
|
+
tty-prompt (0.21.0)
|
29
|
+
necromancer (~> 0.5.0)
|
30
|
+
pastel (~> 0.7.0)
|
31
|
+
tty-reader (~> 0.7.0)
|
32
|
+
tty-reader (0.7.0)
|
33
|
+
tty-cursor (~> 0.7)
|
34
|
+
tty-screen (~> 0.7)
|
35
|
+
wisper (~> 2.0.0)
|
36
|
+
tty-screen (0.7.1)
|
37
|
+
wisper (2.0.1)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
bundler (~> 2.0)
|
44
|
+
covidstats!
|
45
|
+
rake (~> 12.3.3)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 'Anna Guerrero'
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
=======
|
2
|
+
# Covidstats
|
3
|
+
|
4
|
+
Welcome to Covidstats! This is a daily tracker of the COVID-19 pandemic and features statistics on different countries and continents. Whether you would like to look up how a certain country is doing or the country with the highest cases, this is the gem for you. This was built to be an informative app on the pandemic that has affected the whole world.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'covidstats'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install covidstats
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
To run the program, use the command bin/covidstats.
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
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).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/acg2176/covidstats. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
39
|
+
|
40
|
+
## Code of Conduct
|
41
|
+
|
42
|
+
Everyone interacting in the Covidstats project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'interactive-chain-4903'/covidstats/blob/master/CODE_OF_CONDUCT.md).
|
43
|
+
>>>>>>> 7334a8e74186c0b710c086f62afc0ec1f6f73ba1
|
44
|
+
>>>>>>> 93e19ea6d5423f941a535cd461ff16777a6e5b8d
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "covidstats"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/covidstats
ADDED
data/bin/setup
ADDED
data/covidstats.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "covidstats/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "covidstats"
|
8
|
+
spec.version = Covidstats::VERSION
|
9
|
+
spec.authors = ["'Anna Guerrero'"]
|
10
|
+
spec.email = ["'acg2176@columbia.edu'"]
|
11
|
+
|
12
|
+
spec.summary = %q{Covid-19 Daily Tracker}
|
13
|
+
spec.description = %q{This serves as a coronavirus daily tracker of the number of cases around the world.}
|
14
|
+
spec.homepage = "https://github.com/acg2176/covidstats"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/acg2176/covidstats"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/acg2176/covidstats"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
40
|
+
spec.add_development_dependency "rake", "~> 12.3.3"
|
41
|
+
spec.add_dependency "httparty"
|
42
|
+
spec.add_dependency "tty-prompt"
|
43
|
+
spec.add_dependency "colorize"
|
44
|
+
end
|
data/lib/covidstats.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'tty-prompt'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
|
6
|
+
require_relative "covidstats/version"
|
7
|
+
require_relative "covidstats/cli"
|
8
|
+
require_relative "covidstats/api"
|
9
|
+
require_relative "covidstats/country"
|
10
|
+
require_relative "covidstats/continents"
|
11
|
+
|
12
|
+
module Covidstats
|
13
|
+
class Error < StandardError; end
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
class Covidstats::CLI
|
2
|
+
def call
|
3
|
+
puts "Welcome to the daily corona tracker! This CLI app provides real time data regarding the ongoing coronavirus pandemic and includes information from numerous countries and continents.".colorize(:light_green)
|
4
|
+
get_all_countries
|
5
|
+
world_stats
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_all_countries
|
9
|
+
countries_array = Covidstats::API.get_reports
|
10
|
+
Covidstats::Country.create_from_collection(countries_array)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_all_continents
|
14
|
+
continents_array = Covidstats::Continents.continent_reports
|
15
|
+
array = Covidstats::Continents.merge_hash(continents_array)
|
16
|
+
Covidstats::Continents.create_from_collection(array)
|
17
|
+
end
|
18
|
+
|
19
|
+
def ask_for_choices
|
20
|
+
puts "Would you like to do anything else? (y/n)".colorize(:light_green)
|
21
|
+
input = gets.strip
|
22
|
+
if input == "y"
|
23
|
+
list_of_actions
|
24
|
+
else
|
25
|
+
puts "Ok, thanks for using Covidstats today!".colorize(:light_green)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def world_stats
|
30
|
+
puts "To begin, would you like to see the world statistics for today? (y/n)".colorize(:light_green)
|
31
|
+
input = gets.strip
|
32
|
+
if input == "y"
|
33
|
+
puts "Here are the World Statistics:".colorize(:light_green)
|
34
|
+
world = Covidstats::API.get_reports[0]
|
35
|
+
puts "Total Cases:".colorize(:red) + " #{world["TotalCases"]}".colorize(:yellow)
|
36
|
+
puts "New Cases:".colorize(:red) + " #{world["NewCases"]}".colorize(:yellow)
|
37
|
+
puts "Total Deaths:".colorize(:red) + " #{world["TotalDeaths"]}".colorize(:yellow)
|
38
|
+
puts "New Deaths:".colorize(:red) + " #{world["NewDeaths"]}".colorize(:yellow)
|
39
|
+
puts "TotalRecovered:".colorize(:red) + " #{world["TotalRecovered"]}".colorize(:yellow)
|
40
|
+
puts "Active Cases:".colorize(:red) + " #{world["ActiveCases"]}".colorize(:yellow)
|
41
|
+
puts "Deaths per Million:".colorize(:red) + " #{world["Deaths_1M_pop"]}".colorize(:yellow)
|
42
|
+
puts "Number of Serious/Critical Cases:".colorize(:red) + " #{world["Serious_Critical"]}".colorize(:yellow)
|
43
|
+
puts "Total Cases per Million:".colorize(:red) + " #{world["TotCases_1M_Pop"]}".colorize(:yellow)
|
44
|
+
ask_for_choices
|
45
|
+
else
|
46
|
+
list_of_actions
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def list_of_actions
|
51
|
+
prompt = TTY::Prompt.new
|
52
|
+
choice = prompt.select("Please select what you would like to do:".colorize(:light_green)) do |prompt|
|
53
|
+
prompt.choice "stats by country"
|
54
|
+
prompt.choice "stats by continent"
|
55
|
+
prompt.choice "Top 10 countries with highest cases"
|
56
|
+
prompt.choice "Top 10 countries with highest testing rates by tests per million"
|
57
|
+
prompt.choice "Top 10 countries with highest fatality rates by deaths per million"
|
58
|
+
end
|
59
|
+
country_select if choice == "stats by country"
|
60
|
+
continent_select if choice == "stats by continent"
|
61
|
+
highest_cases if choice == "Top 10 countries with highest cases"
|
62
|
+
testing_rates if choice == "Top 10 countries with highest testing rates by tests per million"
|
63
|
+
fatality_rates if choice == "Top 10 countries with highest fatality rates by deaths per million"
|
64
|
+
end
|
65
|
+
|
66
|
+
def country_select
|
67
|
+
puts "Enter the name of the country you would like to search. Please note that for the country United States, please enter".colorize(:light_green) + " USA".colorize(:yellow) + " for United Kingdom, please enter".colorize(:light_green) + " UK".colorize(:yellow) + " and for South Korea, please enter".colorize(:light_green) + " S. Korea".colorize(:yellow)
|
68
|
+
input = gets.strip
|
69
|
+
input = input.capitalize if input != "USA" && input != "S. Korea" && input != "UK"
|
70
|
+
Covidstats::Country.all.each do |country|
|
71
|
+
if country.name == input
|
72
|
+
display_stats_country(country)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
ask_for_choices
|
76
|
+
end
|
77
|
+
|
78
|
+
def continent_select
|
79
|
+
get_all_continents
|
80
|
+
prompt = TTY::Prompt.new
|
81
|
+
choice = prompt.select("Please select which continent:".colorize(:light_green)) do |prompt|
|
82
|
+
prompt.choice "Asia"
|
83
|
+
prompt.choice "South America"
|
84
|
+
prompt.choice "North America"
|
85
|
+
prompt.choice "Europe"
|
86
|
+
prompt.choice "Africa"
|
87
|
+
prompt.choice "Australia/Oceania"
|
88
|
+
end
|
89
|
+
Covidstats::Continents.all.each do |continent|
|
90
|
+
if continent.name == choice
|
91
|
+
display_stats_continent(continent)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
ask_for_choices
|
95
|
+
end
|
96
|
+
|
97
|
+
def display_stats_country(country)
|
98
|
+
puts "Total Cases:".colorize(:magenta) + " #{country.total_cases}".colorize(:yellow)
|
99
|
+
puts "New Cases:".colorize(:magenta) + " #{country.new_cases}".colorize(:yellow)
|
100
|
+
puts "Total Deaths:".colorize(:magenta) + " #{country.total_deaths}".colorize(:yellow)
|
101
|
+
puts "Total Recovered:".colorize(:magenta) + " #{country.total_recovered}".colorize(:yellow)
|
102
|
+
puts "Active Cases:".colorize(:magenta) + " #{country.active_cases}".colorize(:yellow)
|
103
|
+
puts "Total Tests:".colorize(:magenta) + " #{country.total_tests}".colorize(:yellow)
|
104
|
+
puts "Population:".colorize(:magenta) + " #{country.population}".colorize(:yellow)
|
105
|
+
puts "Continent:".colorize(:magenta) + " #{country.continent}".colorize(:yellow)
|
106
|
+
puts "Deaths per Million:".colorize(:magenta) + " #{country.deaths_per_mil}".colorize(:yellow)
|
107
|
+
puts "Number of Serious/Critical Cases:".colorize(:magenta) + " #{country.serious_critical}".colorize(:yellow)
|
108
|
+
puts "Tests per Million:".colorize(:magenta) + " #{country.tests_per_mil}".colorize(:yellow)
|
109
|
+
puts "Total Cases per Million:".colorize(:magenta) + " #{country.total_cases_per_mil}".colorize(:yellow)
|
110
|
+
end
|
111
|
+
|
112
|
+
def display_stats_continent(continent)
|
113
|
+
puts "Total Cases:".colorize(:light_blue) + " #{continent.total_cases}".colorize(:yellow)
|
114
|
+
puts "New Cases:".colorize(:light_blue) + " #{continent.new_cases}".colorize(:yellow)
|
115
|
+
puts "Total Deaths:".colorize(:light_blue) + " #{continent.total_deaths}".colorize(:yellow)
|
116
|
+
puts "New Deaths:".colorize(:light_blue) + " #{continent.new_deaths}".colorize(:yellow)
|
117
|
+
puts "Total Recovered:".colorize(:light_blue) + " #{continent.total_recovered}".colorize(:yellow)
|
118
|
+
puts "Active Cases:".colorize(:light_blue) + " #{continent.active_cases}".colorize(:yellow)
|
119
|
+
puts "Total Tests:".colorize(:light_blue) + " #{continent.total_tests}".colorize(:yellow)
|
120
|
+
puts "Number of Serious/Critical Cases:".colorize(:light_blue) + " #{continent.serious_critical}".colorize(:yellow)
|
121
|
+
end
|
122
|
+
|
123
|
+
def highest_cases
|
124
|
+
arr_total_cases = []
|
125
|
+
Covidstats::Country.all.each {|country| arr_total_cases << country.total_cases}
|
126
|
+
top_10_cases = arr_total_cases.sort.reverse[0,10]
|
127
|
+
|
128
|
+
top_10_cases.each do |total_case|
|
129
|
+
Covidstats::Country.all.each do |country|
|
130
|
+
if country.total_cases == total_case
|
131
|
+
puts "#{country.name}:".colorize(:red) + " #{country.total_cases}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
ask_for_choices
|
136
|
+
end
|
137
|
+
|
138
|
+
def testing_rates
|
139
|
+
arr_test_rates = []
|
140
|
+
Covidstats::Country.all.each {|country| arr_test_rates << country.tests_per_mil}
|
141
|
+
top_10_test_rates = arr_test_rates.sort.reverse[0,10]
|
142
|
+
|
143
|
+
top_10_test_rates.each do |test_rate|
|
144
|
+
Covidstats::Country.all.each do |country|
|
145
|
+
if country.tests_per_mil == test_rate
|
146
|
+
puts "#{country.name}:".colorize(:blue) + " #{country.tests_per_mil}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
ask_for_choices
|
151
|
+
end
|
152
|
+
|
153
|
+
def fatality_rates
|
154
|
+
arr_fatal_rates = []
|
155
|
+
Covidstats::Country.all.each {|country| arr_fatal_rates << country.deaths_per_mil}
|
156
|
+
top_10_fatal_rates = arr_fatal_rates.sort.reverse[0,10]
|
157
|
+
|
158
|
+
top_10_fatal_rates.each do |fatal_rate|
|
159
|
+
Covidstats::Country.all.each do |country|
|
160
|
+
if country.deaths_per_mil == fatal_rate
|
161
|
+
puts "#{country.name}:".colorize(:green) + " #{country.deaths_per_mil}".colorize(:yellow)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
ask_for_choices
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
class Covidstats::Continents
|
2
|
+
attr_accessor :total_cases, :new_cases, :total_deaths, :new_deaths, :total_recovered, :active_cases, :total_tests, :name, :serious_critical
|
3
|
+
@@all = []
|
4
|
+
|
5
|
+
def initialize(continent_hash)
|
6
|
+
hash_attr(continent_hash)
|
7
|
+
save
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.merge_hash(continents_array)
|
11
|
+
new_array = []
|
12
|
+
continents_array.each do |array|
|
13
|
+
new_hash = {}
|
14
|
+
new_hash["Continent"] = ""
|
15
|
+
new_hash["TotalCases"] = 0
|
16
|
+
new_hash["NewCases"] = 0
|
17
|
+
new_hash["TotalDeaths"] = 0
|
18
|
+
new_hash["NewDeaths"] = 0
|
19
|
+
new_hash["TotalRecovered"] = 0
|
20
|
+
new_hash["ActiveCases"] = 0
|
21
|
+
new_hash["TotalTests"] = 0
|
22
|
+
new_hash["Serious_Critical"] = 0
|
23
|
+
array.each do |hash|
|
24
|
+
hash.each do |key, value|
|
25
|
+
new_hash["Continent"] = hash["Continent"]
|
26
|
+
if key != "Country" && key != "" && key != "Deaths_1M_pop" && key != "TotCases_1M_Pop" && key != "Population" && key != "Tests_1M_Pop" && key != "Continent" && value.class == String
|
27
|
+
hash[key] = value.gsub(",","").gsub("+","")
|
28
|
+
hash[key] = hash[key].to_i
|
29
|
+
if key == "TotalCases"
|
30
|
+
new_hash["TotalCases"] += hash[key]
|
31
|
+
elsif key == "NewCases"
|
32
|
+
new_hash["NewCases"] += hash[key]
|
33
|
+
elsif key == "TotalDeaths"
|
34
|
+
new_hash["TotalDeaths"] += hash[key]
|
35
|
+
elsif key == "NewDeaths"
|
36
|
+
new_hash["NewDeaths"] += hash[key]
|
37
|
+
elsif key == "TotalRecovered"
|
38
|
+
new_hash["TotalRecovered"] += hash[key]
|
39
|
+
elsif key == "ActiveCases"
|
40
|
+
new_hash["ActiveCases"] += hash[key]
|
41
|
+
elsif key == "TotalTests"
|
42
|
+
new_hash["TotalTests"] += hash[key]
|
43
|
+
elsif key == "Serious_Critical"
|
44
|
+
new_hash["Serious_Critical"] += hash[key]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
new_array << new_hash
|
50
|
+
end
|
51
|
+
new_array
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.continent_reports
|
55
|
+
continents_array = []
|
56
|
+
hash_continents = Covidstats::API.get_reports
|
57
|
+
asia = hash_continents.select{|hash| hash["Continent"] == "Asia"}
|
58
|
+
continents_array << asia
|
59
|
+
africa = hash_continents.select{|hash| hash["Continent"] == "Africa"}
|
60
|
+
continents_array << africa
|
61
|
+
europe = hash_continents.select{|hash| hash["Continent"] == "Europe"}
|
62
|
+
continents_array << europe
|
63
|
+
n_america = hash_continents.select{|hash| hash["Continent"] == "North America"}
|
64
|
+
continents_array << n_america
|
65
|
+
s_america = hash_continents.select{|hash| hash["Continent"] == "South America"}
|
66
|
+
continents_array << s_america
|
67
|
+
australia = hash_continents.select{|hash| hash["Continent"] == "Australia/Oceania"}
|
68
|
+
continents_array << australia
|
69
|
+
continents_array
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.create_from_collection(continents_array)
|
73
|
+
continents_array.each do |continent| #this is a hash
|
74
|
+
self.new(continent)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def hash_attr(hash) #given a hash, returns all the attributes
|
79
|
+
@total_cases = hash["TotalCases"]
|
80
|
+
@new_cases = hash["NewCases"]
|
81
|
+
@total_deaths = hash["TotalDeaths"]
|
82
|
+
@new_deaths = hash["NewDeaths"]
|
83
|
+
@total_recovered = hash["TotalRecovered"]
|
84
|
+
@active_cases = hash["ActiveCases"]
|
85
|
+
@total_tests = hash["TotalTests"]
|
86
|
+
@name = hash["Continent"]
|
87
|
+
@serious_critical = hash["Serious_Critical"]
|
88
|
+
end
|
89
|
+
|
90
|
+
def save
|
91
|
+
@@all << self
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.all
|
95
|
+
@@all
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Covidstats::Country
|
2
|
+
attr_accessor :total_cases, :new_cases, :total_deaths, :new_deaths, :total_recovered, :active_cases, :total_tests, :population, :continent, :deaths_per_mil, :name, :serious_critical, :tests_per_mil, :total_cases_per_mil
|
3
|
+
@@all = []
|
4
|
+
|
5
|
+
def initialize(country_hash)
|
6
|
+
hash_attr(country_hash)
|
7
|
+
save
|
8
|
+
end
|
9
|
+
|
10
|
+
def hash_attr(hash)
|
11
|
+
hash = hash.each do |key, value|
|
12
|
+
hash[key] = value.gsub(",","").gsub("+","")
|
13
|
+
if key != "Continent" && key != "Country"
|
14
|
+
hash[key] = hash[key].to_i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@total_cases = hash["TotalCases"]
|
18
|
+
@new_cases = hash["NewCases"]
|
19
|
+
@total_deaths = hash["TotalDeaths"]
|
20
|
+
@new_deaths = hash["NewDeaths"]
|
21
|
+
@total_recovered = hash["TotalRecovered"]
|
22
|
+
@active_cases = hash["ActiveCases"]
|
23
|
+
@total_tests = hash["TotalTests"]
|
24
|
+
@population = hash["Population"]
|
25
|
+
@continent = hash["Continent"]
|
26
|
+
@deaths_per_mil = hash["Deaths_1M_pop"]
|
27
|
+
@name = hash["Country"]
|
28
|
+
@serious_critical = hash["Serious_Critical"]
|
29
|
+
@tests_per_mil = hash["Tests_1M_Pop"]
|
30
|
+
@total_cases_per_mil = hash["TotCases_1M_Pop"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.create_from_collection(countries_array)
|
34
|
+
countries_array.delete_if { |h| h["Country"] == "World"}
|
35
|
+
countries_array.delete_if { |h| h["Country"] == "Total:"}
|
36
|
+
countries_array.each do |country|
|
37
|
+
self.new(country)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.all
|
42
|
+
@@all
|
43
|
+
end
|
44
|
+
|
45
|
+
def save
|
46
|
+
@@all << self
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: covidstats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "'Anna Guerrero'"
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 12.3.3
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 12.3.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-prompt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: This serves as a coronavirus daily tracker of the number of cases around
|
84
|
+
the world.
|
85
|
+
email:
|
86
|
+
- "'acg2176@columbia.edu'"
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/covidstats
|
100
|
+
- bin/setup
|
101
|
+
- covidstats.gemspec
|
102
|
+
- lib/covidstats.rb
|
103
|
+
- lib/covidstats/api.rb
|
104
|
+
- lib/covidstats/cli.rb
|
105
|
+
- lib/covidstats/continents.rb
|
106
|
+
- lib/covidstats/country.rb
|
107
|
+
- lib/covidstats/version.rb
|
108
|
+
homepage: https://github.com/acg2176/covidstats
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata:
|
112
|
+
allowed_push_host: https://rubygems.org
|
113
|
+
homepage_uri: https://github.com/acg2176/covidstats
|
114
|
+
source_code_uri: https://github.com/acg2176/covidstats
|
115
|
+
changelog_uri: https://github.com/acg2176/covidstats
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubygems_version: 3.0.3
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Covid-19 Daily Tracker
|
135
|
+
test_files: []
|