kovid 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bd969471381d80a48eadfa3a7a209e44b640210d46a07abc49f2893aafa6733
4
- data.tar.gz: a17fb95681ea89fe2e8e5ad5aec5b5fde2f8d3b52476668a2d7ed909e38f9dbf
3
+ metadata.gz: eda967d6a2af12ffe6c318f4deceda6a69d3d200cafd5bca9a681a675beb2cf8
4
+ data.tar.gz: ad0ade25d0e1d3e26b91821b02a480f973d92e70ac205d460660b4e38e52955a
5
5
  SHA512:
6
- metadata.gz: 65017f21ef033e9a23f54119b136d334fecab2e3f2c637a23743fb0033e7d6b0f0c73123ae12e46d6fef5ff0c768b837edaa992ce8666c3a72049ee4b1be57a2
7
- data.tar.gz: 367189c05cd5049c445f13b1a797afd7e131c09393f91997f047718cd382fd63984be1f4b867d6d923a4fe3c591c83aeb50e4cefc1ac15a51360c58b3caf15a7
6
+ metadata.gz: b894aa6499ca25617128ff8ac6acf330d45831657722bb1ba2d98cf89a18a6d62c79e8e67b3ae922fdee53306f5075474c6da78ce0314835f928be681ee3b4e8
7
+ data.tar.gz: ea6c116dabb8d9a7252e3791f73eeb0d402e8d094d58bdb246b50904e4dc2483a629049d17e615250fd628dbea809af84df527b030e538b1b43df1377b31ec05
data/README.md CHANGED
@@ -27,15 +27,27 @@ After installing:
27
27
 
28
28
  To fetch basic data on a country run:
29
29
 
30
- `kovid country ghana`
30
+ `kovid check ghana`
31
31
 
32
- ![kovid](https://i.gyazo.com/c95aa03d01c63ee1256dd28f66e1b657.png "Covid data.")
32
+ ![kovid](https://i.gyazo.com/ca57d9250c7523a921d0d7e1104716be.png "Covid data.")
33
33
 
34
34
  For a full table info on a country:
35
35
 
36
- `kovid country poland -f` OR `kovid country poland --full`
36
+ `kovid check ghana -f` OR `kovid check ghana --full`
37
37
 
38
- ![kovid](https://i.gyazo.com/48797cc6314e5685a34146d4cd749fa3.png "Covid data.")
38
+ ![kovid](https://i.gyazo.com/628f07faf8e3c1c2a0b6ab05e4a86404.png "Covid data.")
39
+
40
+ To compare country stats:
41
+
42
+ `kovid compare ghana poland`
43
+
44
+ ![kovid](https://i.gyazo.com/a15922e13e9e6c1ba804ccf5beeb863b.png "Covid data.")
45
+
46
+ To compare a countries stats with a full table:
47
+
48
+ `kovid compare ghana poland -f`
49
+
50
+ ![kovid](https://i.gyazo.com/d0b72207765090b118a5b76d72ddde19.png "Covid data.")
39
51
 
40
52
  ## 👨‍💻 Development
41
53
 
data/lib/kovid/cli.rb CHANGED
@@ -20,9 +20,15 @@ module Kovid
20
20
  end
21
21
  end
22
22
 
23
- desc 'compare', 'Returns comparison table for given countries'
23
+ desc 'compare', 'Returns full comparison table for given countries'
24
24
  def compare(*name)
25
- Kovid::Nineteen.country_comparison(name)
25
+ if name[-1] == "-f" || name[-1] == "--full"
26
+ name = name.reverse.drop(1).reverse
27
+
28
+ Kovid::Nineteen.country_comparison_full(name)
29
+ else
30
+ Kovid::Nineteen.country_comparison(name)
31
+ end
26
32
  end
27
33
  end
28
34
  end
@@ -20,6 +20,10 @@ module Kovid
20
20
  def country_comparison(name)
21
21
  puts Kovid::Request.by_country_comparison(name)
22
22
  end
23
+
24
+ def country_comparison_full(name)
25
+ puts Kovid::Request.by_country_comparison_full(name)
26
+ end
23
27
  end
24
28
  end
25
29
  end
data/lib/kovid/request.rb CHANGED
@@ -29,6 +29,7 @@ module Kovid
29
29
  def by_country_comparison(list)
30
30
  array = []
31
31
 
32
+
32
33
  list.each do |country|
33
34
  path = "/countries/#{country}"
34
35
  fetch_url = BASE_URL + path
@@ -38,6 +39,19 @@ module Kovid
38
39
 
39
40
  Kovid::Tablelize.compare_countries_table(array)
40
41
  end
42
+
43
+ def by_country_comparison_full(list)
44
+ array = []
45
+
46
+ list.each do |country|
47
+ path = "/countries/#{country}"
48
+ fetch_url = BASE_URL + path
49
+
50
+ array << JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
51
+ end
52
+
53
+ Kovid::Tablelize.compare_countries_table_full(array)
54
+ end
41
55
  end
42
56
  end
43
57
  end
@@ -48,6 +48,17 @@ module Kovid
48
48
 
49
49
  puts Terminal::Table.new(headings: headings, rows: rows)
50
50
  end
51
+
52
+ def compare_countries_table_full(data)
53
+ headings = ['Country', 'Cases', 'Deaths', 'Recovered', 'Cases Today', 'Deaths Today', 'Critical', 'Cases/Million']
54
+ rows = []
55
+
56
+ data.each do |country|
57
+ rows << [country['country'], country['cases'], country['deaths'], country['recovered'], country['todayCases'], country['todayDeaths'], country['critical'], country['casesPerOneMillion']]
58
+ end
59
+
60
+ puts Terminal::Table.new(headings: headings, rows: rows)
61
+ end
51
62
  end
52
63
  end
53
64
  end
data/lib/kovid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kovid
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kovid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Hayford