Giter Club home page Giter Club logo

kovid's Introduction

Gem Version Open Source Helpers

If you're looking to consume this in your Ruby-based application, you might want to check Sarskov out. Sarskov returns statistics in a JSON format.

🦠 Kovid

Kovid is a small CLI app to fetch data surrounding the coronavirus pandemic of 2019. I found myself checking Wikipedia constantly for information so I thought I'd build this to provide info directly in the terminal. It's where some of us spend time more.

Code contribution and ideas welcome.

βš™οΈ Installation

To install:

  • ️ Wash your hands with soap and water for at least 20 seconds.

  • Run gem install kovid.

It's recommended you update often with gem update kovid.

βš’οΈ Usage

You can run kovid --help to see the full list of available commands.

Commands Overview

😷 Fetching

  • kovid check COUNTRY aliased as kovid country COUNTRY.
  • kovid check COUNTRY -f aliased as kovid country COUNTRY --full.

You can get continental information with the following commands:

  • kovid africa.
  • kovid europe.
  • kovid eu. (The European Union)
  • kovid sa. (South America)
  • kovid asia.
  • kovid world. (Worldwide Statistics)

πŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡Έ

You can fetch US state-specific data:

  • kovid state STATE OR kovid state "STATE NAME".
  • kovid states --all or kovid states -a for data on all US states.

You can also use USPS abbreviations. Example: kovid state me

Provinces

You can fetch province specific data:

  • kovid province PROVINCE or kovid province "PROVINCE NAME".

😷 Comparing

  • kovid compare FOO BAR (sorts by cases DESC).
  • kovid compare FOO BAR -f OR kovid compare FOO BAR --full (sorts by cases DESC).

Where FOO and BAR are different countries.

You can compare as many countries as you want; kovid compare FOO BAR BAZ OR kovid compare FOO BAR BAZ -f

πŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡ΈπŸ‡ΊπŸ‡Έ

You can compare US states with:

  • kovid states STATE STATE Example: kovid states illinois "new york" california OR kovid states il ny ca

You can compare provicnes with:

  • kovid provinces PROVINCE PROVINCE Example: kovid provinces ontario manitoba

😷 History

  • kovid history COUNTRY (full history).
  • kovid history COUNTRY N (history in the last N days).
  • kovid history STATE --usa

😷 Top N (by cases/deaths for countries and US States)

  • kovid top N (top N countries in number of cases).
  • kovid top N -d OR kovid top N --deaths (top N countries in number of deaths).
  • kovid top N --states (top N US states in number of cases).
  • kovid top N --states -d (top N countries in number of deaths).

NOTE: If you find it irritating to have to type kovid state STATE, covid state STATE works as well.

Commands Details

To fetch basic data on a country run:

kovid check ghana. If the location contains spaces: kovid check "Diamond Princess"

kovid

For full table info on a country:

kovid check italy -f OR kovid check italy --full

kovid

To compare country stats:

kovid compare germany poland spain

kovid

To compare a countries stats with a full table:

kovid compare poland italy usa china -f OR kovid compare poland italy usa china --full

kovid

To fetch state-specific data run:

kovid state colorado OR kovid state "north carolina"

kovid

To fetch EU data run:

kovid eu

kovid

To fetch data on Africa:

kovid africa

kovid

You can check historical statistics by running

kovid history italy 7 eg:

kovid

To check for total figures:

kovid world

kovid

To fetch top 5 countries in number of cases or deaths:

kovid top

kovid

kovid top --deaths OR kovid top -d

kovid

It is also possible to fetch top US states in number of cases or deaths:

kovid top --states

kovid

kovid top --states --deaths OR kovid top --states -d

kovid

To fetch more number of countries or US states you can pass N. eg:

kovid top 10

kovid

Data Source

JHU CSSE GISand Data and https://www.worldometers.info/coronavirus/ via NovelCOVID/API

πŸ‘¨β€πŸ’» Development

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.

To install this gem onto your local machine, run bundle exec rake install.

🀲 Contributing

There are multiple areas in this repo that can be improved or use some refactoring(there's a lot to be refactored in fact!). For that reason, bug reports and pull requests are welcome! This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

πŸ”– License

The gem is available as open-source under the terms of the MIT License.

❀️ Code of Conduct

Everyone interacting in the Kovid project's codebases and issue trackers is expected to follow the code of conduct.

kovid's People

Contributors

dylanandrews avatar jberczel avatar jcsjcs avatar joshleblanc avatar jsantos avatar l-ghost avatar pasikonik avatar siaw23-retired avatar vfonic avatar volfgox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kovid's Issues

CSV output feature

Hi,

Very nice work so far! I thought it would be nice to have a CSV export feature, so the output is not only pretty-printed to the console, this way the data could be reused in other tools (for plotting, etc). If I have the time later I might open a PR.

Cheers

Viewing the Netherlands shows Caribbean Netherlands

I don't think this is the intention... same for the compare command.

➜  ~ kovid country netherlands
+-------+-------------+--------+--------------+-----------+
|                πŸ‡§πŸ‡Άβ€‹ CARIBBEAN NETHERLANDS                 |
+-------+-------------+--------+--------------+-----------+
| Cases | Cases Today | Deaths | Deaths Today | Recovered |
+-------+-------------+--------+--------------+-----------+
| 2     | 0           | 0      | 0            | 0         |
+-------+-------------+--------+--------------+-----------+

broken with ActiveSupport error

.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-7.0.2.2/lib/active_support/xml_mini.rb:184:in `current_thread_backend': uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState (NameError)

Collection of ISO codes for countries

In response to #40, we need help collecting ISO 3166-1 alpha-2 country codes for the following groupings:

  1. EU (European Union)
  2. Africa
  3. Asia
  4. South America
  5. Europe

The codes should be an array of strings. With this, we can aggregate information on a continental level.

CLI Table shows Active Cases on the "Recovered" column

Noticed this today when I saw the Singapore column with 12.950 recovered case. I recalled from the news earlier today that this is not the number of recovered patients, but the number of Active Cases.

As I see on /lib/kovid/tablelize.rb, the country_row method only mentions active cases and not recovered.

I've obtained this result with kovid check singapore and by comparing to other countries.

Argument Errors

Some commands gives ArgumentErrors

~# kovid eu

Traceback (most recent call last):
        11: from /usr/local/bin/kovid:23:in `<main>'
        10: from /usr/local/bin/kovid:23:in `load'
         9: from /var/lib/gems/2.5.0/gems/kovid-0.4.10/exe/kovid:4:in `<top (required)>'
         8: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
         7: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
         6: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
         5: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
         4: from /var/lib/gems/2.5.0/gems/kovid-0.4.10/lib/kovid/cli.rb:62:in `eu'
         3: from /var/lib/gems/2.5.0/gems/kovid-0.4.10/lib/kovid.rb:14:in `eu_aggregate'
         2: from /var/lib/gems/2.5.0/gems/kovid-0.4.10/lib/kovid/request.rb:26:in `eu_aggregate'
         1: from /var/lib/gems/2.5.0/gems/kovid-0.4.10/lib/kovid/request.rb:188:in `aggregator'
/var/lib/gems/2.5.0/gems/kovid-0.4.10/lib/kovid/request.rb:188:in `merge': wrong number of arguments (given 26, expected 1) (ArgumentError)

kovid top N --death not working

kovid top 10 --death is not working but kovid top 10 -d works OK.

Let's fix kovid top 10 --death

Output:

ERROR: "kovid top" was called with arguments ["10", "--death"]
Usage: "kovid top N"

Problems setting up locally for testing

Hi. Thanks for the gem! Very cool.

So I'm very new to local gem development and am having trouble getting my local clone to be in a state where I can test the command line functionality, and I need to get this working before I can contribute.

I've done the following and am not having any luck. Any help would be most appreciated.

❯ bin/setup

bundle install
+ bundle install
Warning: the running version of Bundler (2.0.2) is older than the version that created the lockfile (2.1.4). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Using rake 12.3.3
Using ascii_charts 0.9.1
Using bundler 2.0.2
Using diff-lcs 1.3
Using docile 1.3.2
Using ffi 1.12.2
Using ethon 0.12.0
Using rainbow 3.0.0
Using unicode-display_width 1.7.0
Using terminal-table 1.8.0
Using thor 1.0.1
Using typhoeus 1.3.1
Using kovid 0.6.0 from source at `.`
Using rspec-support 3.9.2
Using rspec-core 3.9.1
Using rspec-expectations 3.9.1
Using rspec-mocks 3.9.1
Using rspec 3.9.0
Using simplecov-html 0.12.2
Using simplecov 0.18.5
Bundle complete! 4 Gemfile dependencies, 20 gems now installed.
Bundled gems are installed into `./vendor`

Then

❯ bundle exec rake install
kovid 0.6.0 built to pkg/kovid-0.6.0.gem.
kovid (0.6.0) installed.

Then

❯ kovid state Florida
Traceback (most recent call last):
	2: from /Users/dylanandrews/.asdf/installs/ruby/2.6.3/bin/kovid:23:in `<main>'
	1: from /Users/dylanandrews/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/Users/dylanandrews/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem kovid (>= 0.a) with executable kovid (Gem::GemNotFoundException)

Any thoughts on what I'm doing wrong?

Thanks.

Add error handling

If a country is not found (has no recorded case of the virus), a unexpected token at 'Country not found' (JSON::ParserError) is returned.

Refactorise to use URI builder

 path = "/countries/#{name}"
 fetch_url = BASE_URL + path

 response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
 Kovid::Tablelize.full_country_table(response)

Likes of the above should be refactorised to use a URI build with URI::HTTP
Everything in lib/ should be refactorised!

Support aggregated data for EU

Looking at data for the entire EU is very difficult. Can we get aggregated data for the EU somehow?

The US has state-level info, but there does not seem to be the opposite for the EU.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.