corona_virus_cli 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 +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +20 -0
- data/Rakefile +6 -0
- data/bin/corona_virus_cli +9 -0
- data/bin/setup +8 -0
- data/corona_virus_cli.gemspec +47 -0
- data/lib/ThoughtProcess.md +23 -0
- data/lib/corona_virus.rb +9 -0
- data/lib/corona_virus_cli/cli.rb +114 -0
- data/lib/corona_virus_cli/country.rb +34 -0
- data/lib/corona_virus_cli/scraper.rb +57 -0
- data/lib/corona_virus_cli/version.rb +3 -0
- data/lib/corona_virus_cli/virus.rb +49 -0
- metadata +131 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1ce68b26c4a467ceb3b8baf487d5720e877844fe1b81eb37d48e8428c933c30f
|
|
4
|
+
data.tar.gz: '059322d1ac1e699122f228393c240923a4eac1bbd4f3a31ce567daa21d4f3e9e'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7973b4242739975c56efecd3039e9f08d2f4536bf835ff323ec74dbd59401d0d5d64a2958a9f3ba455f74ecc3b4af6f9c7c45d8a67c2749e23e27604de01d3b8
|
|
7
|
+
data.tar.gz: 609572da13c842a44c3b5ba64047bcb60b80ad8c63f1b25ab76186bf2054a3b8516b5acda75a655dd9ed40742fde8d611dcff62bda3d1a6a0e2ed29e467af4ec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
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 gavinsharkey2016@gmail.com. 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/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 gavinsharkey
|
|
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,20 @@
|
|
|
1
|
+
# Corona Virus Cli
|
|
2
|
+
|
|
3
|
+
Hello! This is a simple CLI gem for displaying up-to-date statistics about the Corona Virus (COVID-19).
|
|
4
|
+
You can view world stats (total cases, active cases, closed cases), and you can view stats per country.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
After you fork it, run ```bundle install```, then ```ruby bin/corona_virus_cli```.
|
|
9
|
+
|
|
10
|
+
## Contributing
|
|
11
|
+
|
|
12
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gavinsharkey/corona_virus_cli. 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.
|
|
13
|
+
|
|
14
|
+
## License
|
|
15
|
+
|
|
16
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
17
|
+
|
|
18
|
+
## Code of Conduct
|
|
19
|
+
|
|
20
|
+
Everyone interacting in the CoronaVirusCli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/corona_virus_cli/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/setup
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "corona_virus_cli/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "corona_virus_cli"
|
|
8
|
+
spec.version = CoronaVirusCLI::VERSION
|
|
9
|
+
spec.authors = ["gavinsharkey"]
|
|
10
|
+
spec.email = ["gavinsharkey2016@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Corona Virus Gem}
|
|
13
|
+
spec.description = %q{it displays info about the corona virus}
|
|
14
|
+
spec.homepage = "https://github.com/gavinsharkey/my_cli_project.git"
|
|
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"] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
|
|
22
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
# spec.metadata["source_code_uri"] = "git@github.com:gavinsharkey/my_cli_project.git"
|
|
24
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
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"
|
|
40
|
+
spec.add_development_dependency "rake"
|
|
41
|
+
spec.add_development_dependency "rspec"
|
|
42
|
+
spec.add_development_dependency 'pry'
|
|
43
|
+
|
|
44
|
+
spec.add_dependency 'nokogiri'
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## My Goals
|
|
2
|
+
|
|
3
|
+
I want to make a CLI that displays up-to-date stats about COVID-19.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Scraper
|
|
7
|
+
|
|
8
|
+
1. Build a Scraper class that scrapes all the stats from the website.
|
|
9
|
+
2. Send that data to a class to represent that data.
|
|
10
|
+
|
|
11
|
+
### Virus/Country
|
|
12
|
+
|
|
13
|
+
1. Build a Virus class that represents the world stats.
|
|
14
|
+
2. Build a Country class that represents the stats of an individual country.
|
|
15
|
+
3. The Virus class *has many* instances of Country.
|
|
16
|
+
|
|
17
|
+
### CLI
|
|
18
|
+
|
|
19
|
+
1. Build a CLI class that is responsible for front-end/user interactions.
|
|
20
|
+
2. Have a few different options of world stats to show (from the Virus instance).
|
|
21
|
+
3. Give the option to list the top 20 countries, and select a specific country to view that stats of.
|
|
22
|
+
|
|
23
|
+
|
data/lib/corona_virus.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'pry'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
|
|
5
|
+
require_relative "corona_virus_cli/version"
|
|
6
|
+
require_relative "corona_virus_cli/cli"
|
|
7
|
+
require_relative "corona_virus_cli/scraper"
|
|
8
|
+
require_relative "corona_virus_cli/virus"
|
|
9
|
+
require_relative "corona_virus_cli/country"
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
class CoronaVirusCLI::CLI
|
|
2
|
+
attr_reader :virus
|
|
3
|
+
|
|
4
|
+
def call
|
|
5
|
+
puts "*****Loading data from the web...*****"
|
|
6
|
+
|
|
7
|
+
@virus = CoronaVirusCLI::Scraper.get_virus
|
|
8
|
+
CoronaVirusCLI::Scraper.get_virus_per_country
|
|
9
|
+
|
|
10
|
+
puts "\n_____COVID-19 World Statistics_____\n"
|
|
11
|
+
self.main_loop
|
|
12
|
+
puts "\nThank you, and stay safe!"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def main_loop
|
|
16
|
+
self.list_options
|
|
17
|
+
print "\nWhat would you like to do? "
|
|
18
|
+
input = gets.strip.to_i
|
|
19
|
+
if input.between?(1, 5)
|
|
20
|
+
if input == 5
|
|
21
|
+
return nil
|
|
22
|
+
else
|
|
23
|
+
self.option(input)
|
|
24
|
+
end
|
|
25
|
+
else
|
|
26
|
+
puts "\n___Invalid Input___"
|
|
27
|
+
self.main_loop
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
print "\nWould you like to check something else?(Y/N) "
|
|
31
|
+
input = gets.strip.downcase
|
|
32
|
+
self.main_loop if input == 'y'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def list_options
|
|
36
|
+
puts ""
|
|
37
|
+
puts "1. World Total Stats"
|
|
38
|
+
puts "2. World Active Cases Stats"
|
|
39
|
+
puts "3. World Closed Cases Stats"
|
|
40
|
+
puts "4. Stats per Country"
|
|
41
|
+
puts "5. Exit"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def option(i)
|
|
45
|
+
if i == 1
|
|
46
|
+
self.display_totals
|
|
47
|
+
elsif i == 2
|
|
48
|
+
self.display_active
|
|
49
|
+
elsif i == 3
|
|
50
|
+
self.display_closed
|
|
51
|
+
elsif i == 4
|
|
52
|
+
self.display_country
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def display_totals
|
|
57
|
+
puts ''
|
|
58
|
+
puts '--------------------------------'
|
|
59
|
+
puts "Total Cases: #{self.virus.total}"
|
|
60
|
+
puts "Total Deaths: #{self.virus.total_deaths}"
|
|
61
|
+
puts "Total Recovered: #{self.virus.total_recovered}"
|
|
62
|
+
puts '--------------------------------'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def display_active
|
|
66
|
+
puts ''
|
|
67
|
+
puts '--------------------------------'
|
|
68
|
+
puts "World Active Cases: #{self.virus.active}"
|
|
69
|
+
puts " In Mild Condition: #{self.virus.active_mild}"
|
|
70
|
+
puts " In Severe Condition: #{self.virus.active_severe}"
|
|
71
|
+
puts '--------------------------------'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def display_closed
|
|
75
|
+
puts ''
|
|
76
|
+
puts '--------------------------------'
|
|
77
|
+
puts "World Closed Cases: #{self.virus.closed}"
|
|
78
|
+
puts " Recovered: #{self.virus.closed_recovered}"
|
|
79
|
+
puts " Deaths: #{self.virus.closed_deaths}"
|
|
80
|
+
puts '--------------------------------'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def display_country
|
|
84
|
+
self.list_countries
|
|
85
|
+
print "\nWhich country would you like to view? "
|
|
86
|
+
input = gets.strip.to_i
|
|
87
|
+
|
|
88
|
+
if input.between?(1, self.virus.countries.length)
|
|
89
|
+
country = self.virus.countries[input - 1]
|
|
90
|
+
puts ''
|
|
91
|
+
puts '--------------------------------'
|
|
92
|
+
puts "#{country.name}:"
|
|
93
|
+
puts " Total Cases: #{country.total}"
|
|
94
|
+
puts " Total Deaths: #{country.deaths}"
|
|
95
|
+
puts " Total Recovered: #{country.recovered}"
|
|
96
|
+
puts " Active Cases: #{country.active}"
|
|
97
|
+
puts '--------------------------------'
|
|
98
|
+
|
|
99
|
+
print "\nWould you like to view another country?(Y/N) "
|
|
100
|
+
repeat = gets.strip.downcase
|
|
101
|
+
self.display_country if repeat == 'y'
|
|
102
|
+
else
|
|
103
|
+
puts "\n___Invalid Input___"
|
|
104
|
+
self.display_country
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def list_countries
|
|
109
|
+
puts ""
|
|
110
|
+
self.virus.countries.each.with_index(1) do |country, i|
|
|
111
|
+
puts "#{i}. #{country.name}"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class CoronaVirusCLI::Country
|
|
2
|
+
attr_accessor :name, :total, :deaths, :recovered, :active
|
|
3
|
+
|
|
4
|
+
@@all = []
|
|
5
|
+
|
|
6
|
+
def self.all
|
|
7
|
+
@@all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def save
|
|
11
|
+
@@all << self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(name, total, deaths, recovered, active)
|
|
15
|
+
self.name = name
|
|
16
|
+
self.total = total
|
|
17
|
+
self.deaths = deaths
|
|
18
|
+
self.recovered = recovered
|
|
19
|
+
self.active = active
|
|
20
|
+
|
|
21
|
+
self.save
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.sort_by_deaths
|
|
25
|
+
|
|
26
|
+
self.all.sort_by do |country|
|
|
27
|
+
country.deaths.gsub(',', '').to_i
|
|
28
|
+
end.reverse
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.find_by_name(name)
|
|
32
|
+
self.all.detect {|obj| obj.name == name}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class CoronaVirusCLI::Scraper
|
|
2
|
+
|
|
3
|
+
@@doc = Nokogiri::HTML(open('https://www.worldometers.info/coronavirus/'))
|
|
4
|
+
|
|
5
|
+
def self.doc
|
|
6
|
+
@@doc
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.get_virus
|
|
10
|
+
all = self.get_totals.merge(self.get_active, self.get_closed)
|
|
11
|
+
|
|
12
|
+
virus = CoronaVirusCLI::Virus.create('World', all)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.get_virus_per_country
|
|
16
|
+
countries = @@doc.css('tbody')[0].css('tr')
|
|
17
|
+
countries[0..19].each do |country|
|
|
18
|
+
name = country.css('a').text.strip
|
|
19
|
+
name = country.css('td')[0].text.strip if name.empty?
|
|
20
|
+
total = country.css('td')[1].text.strip
|
|
21
|
+
deaths = country.css('td')[3].text.strip
|
|
22
|
+
recovered = country.css('td')[5].text.strip
|
|
23
|
+
active = country.css('td')[6].text.strip
|
|
24
|
+
|
|
25
|
+
CoronaVirusCLI::Country.new(name, total, deaths, recovered, active)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.get_totals
|
|
30
|
+
totals = @@doc.css('div.maincounter-number')
|
|
31
|
+
{
|
|
32
|
+
total: totals[0].text.strip,
|
|
33
|
+
total_deaths: totals[1].text.strip,
|
|
34
|
+
total_recovered: totals[2].text.strip,
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.get_active
|
|
39
|
+
active = @@doc.css('div.panel_front')[0]
|
|
40
|
+
|
|
41
|
+
{
|
|
42
|
+
active: active.css('div.number-table-main').text.strip,
|
|
43
|
+
active_mild: active.css('span.number-table')[0].text.strip,
|
|
44
|
+
active_severe: active.css('span.number-table')[1].text.strip
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.get_closed
|
|
49
|
+
closed = @@doc.css('div.panel_front')[1]
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
closed: closed.css('div.number-table-main').text.strip,
|
|
53
|
+
closed_recovered: closed.css('span.number-table')[0].text.strip,
|
|
54
|
+
closed_deaths: closed.css('span.number-table')[1].text.strip
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class CoronaVirusCLI::Virus
|
|
2
|
+
attr_accessor :name, :total, :total_deaths, :total_recovered, :active, :active_mild, :active_severe, :closed, :closed_deaths, :closed_recovered
|
|
3
|
+
|
|
4
|
+
@@all = []
|
|
5
|
+
# @@countries = []
|
|
6
|
+
|
|
7
|
+
def self.all
|
|
8
|
+
@@all
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def save
|
|
12
|
+
@@all << self
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(name)
|
|
16
|
+
self.name = name
|
|
17
|
+
self.save
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.create(name, data)
|
|
21
|
+
virus = self.new(name)
|
|
22
|
+
|
|
23
|
+
data.each do |key, value|
|
|
24
|
+
virus.send("#{key}=", value)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
virus
|
|
28
|
+
end
|
|
29
|
+
# Potential refactor, still deciding
|
|
30
|
+
# def self.create_country(name, total, deaths, recovered, active)
|
|
31
|
+
# country = Virus.new(name)
|
|
32
|
+
# country.total = total
|
|
33
|
+
# country.total_deaths = deaths
|
|
34
|
+
# country.total_recovered = recovered
|
|
35
|
+
# country.active = active
|
|
36
|
+
|
|
37
|
+
# @@countries << country
|
|
38
|
+
# country
|
|
39
|
+
# end
|
|
40
|
+
|
|
41
|
+
def countries
|
|
42
|
+
CoronaVirusCLI::Country.all
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.find_by_name(name)
|
|
46
|
+
self.all.detect {|obj| obj.name == name}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: corona_virus_cli
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- gavinsharkey
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-04-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: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '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: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
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: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
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: nokogiri
|
|
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: it displays info about the corona virus
|
|
84
|
+
email:
|
|
85
|
+
- gavinsharkey2016@gmail.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- ".travis.yml"
|
|
93
|
+
- CODE_OF_CONDUCT.md
|
|
94
|
+
- Gemfile
|
|
95
|
+
- LICENSE.txt
|
|
96
|
+
- README.md
|
|
97
|
+
- Rakefile
|
|
98
|
+
- bin/corona_virus_cli
|
|
99
|
+
- bin/setup
|
|
100
|
+
- corona_virus_cli.gemspec
|
|
101
|
+
- lib/ThoughtProcess.md
|
|
102
|
+
- lib/corona_virus.rb
|
|
103
|
+
- lib/corona_virus_cli/cli.rb
|
|
104
|
+
- lib/corona_virus_cli/country.rb
|
|
105
|
+
- lib/corona_virus_cli/scraper.rb
|
|
106
|
+
- lib/corona_virus_cli/version.rb
|
|
107
|
+
- lib/corona_virus_cli/virus.rb
|
|
108
|
+
homepage: https://github.com/gavinsharkey/my_cli_project.git
|
|
109
|
+
licenses:
|
|
110
|
+
- MIT
|
|
111
|
+
metadata: {}
|
|
112
|
+
post_install_message:
|
|
113
|
+
rdoc_options: []
|
|
114
|
+
require_paths:
|
|
115
|
+
- lib
|
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
requirements: []
|
|
127
|
+
rubygems_version: 3.0.3
|
|
128
|
+
signing_key:
|
|
129
|
+
specification_version: 4
|
|
130
|
+
summary: Corona Virus Gem
|
|
131
|
+
test_files: []
|