covid19 0.1.0 → 0.1.1

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: f35dbf85b81c455721c10fc03a22be3cc2b2e7ca7e3e0ec3d4e523780f5148cb
4
- data.tar.gz: b1df7e8671ecdbb7d7a66a857648a2586c215001e927bd3ee9b3f5e90b8240a7
3
+ metadata.gz: 6733fa65744f743fda7c448e801dd984fc0a1737ab90e71b8ad748f1477cd59b
4
+ data.tar.gz: 6ab5afaa596136070a056a1edc4833126b9a61440512a7c9dc1f4e7303b956f7
5
5
  SHA512:
6
- metadata.gz: 9e8f7b394546576506318b922988e682ecc1a7c447bf9e6218d4b19cc0c57c044f0ca14fc7dab554c5567e2503f243af5cd63c47fe2a365eddb2aba6d1477565
7
- data.tar.gz: 9921a44a2a1e85cca225447203fc2fed6349515a77758ba94791843b44bbad349814fbeb322a4e9a6d45e617d84cb0d32be054ec8c2223e11aa8d41a6340096c
6
+ metadata.gz: d03cc9515829db8b90f90dd975a95826e1271a3d5951512c4f637c7174adb3a009bb933484cae985c108a0e9e5a1f11c74d4ad1c099f179499bafd480e1f01d2
7
+ data.tar.gz: 8c84f7ca6fec08e92f6965e92bb12a1d0b7480fb968376211b7bdadacf4626ec8f8f17f0bedab815fa376af67f93ff622a53c54d5da56c25a4bfcf85cf8aba3d
@@ -5,9 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
 
6
6
  This changelog was automatically generated using [Caretaker](https://github.com/WolfAtheneum/covid19) by [Wolf Software](https://github.com/WolfSoftware)
7
7
 
8
- ### [Unreleased](https://github.com/WolfAtheneum/covid19/compare/0...HEAD)
8
+ ### [Unreleased](https://github.com/WolfAtheneum/covid19/compare/v0.1.0...HEAD)
9
9
 
10
- - Fix links and other travis issues [`[815b040]`](https://github.com/WolfAtheneum/covid19/commit/815b04078f795d9e13944e179439ca3fc9c61ddb) [`[TGWolf]`](https://github.com/TGWolf)
10
+ - Add a death rate as a percentage of confirmed cases [`[660e2b6]`](https://github.com/WolfAtheneum/covid19/commit/660e2b6e17b2ababed7e0c820a8d687b867cdf7f) [`[TGWolf]`](https://github.com/TGWolf)
11
+
12
+ ### [v0.1.0](https://github.com/WolfAtheneum/covid19/releases/v0.1.0)
13
+
14
+ > Released on March, 19th 2020
15
+
16
+ - Fix links and other travis issues [`[95c1073]`](https://github.com/WolfAtheneum/covid19/commit/95c1073fb1043515bbf150e99d080a96f7f58bd2) [`[TGWolf]`](https://github.com/TGWolf)
11
17
 
12
18
  - Initial commit [`[e83777b]`](https://github.com/WolfAtheneum/covid19/commit/e83777b4b3462b5d31f507a86de3448478d7adb4) [`[TGWolf]`](https://github.com/TGWolf)
13
19
 
data/README.md CHANGED
@@ -71,6 +71,7 @@ Usage: covid19
71
71
  -s, --split View the latestest information split by country
72
72
  -c, --confirmed Order results by confirmed cases
73
73
  -d, --deaths Order results by deaths
74
+ -p, --death-rate Order results by percentage of deaths (death rate)
74
75
  -r, --recovered Order results by recovered numbers
75
76
 
76
77
  ```
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -1,3 +1,3 @@
1
1
  class Covid19
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -18,6 +18,14 @@ def format_latest_stats(results)
18
18
  results['latest'].each do |key, value|
19
19
  formatted << [key, value]
20
20
  end
21
+
22
+ confirmed = results['latest']['confirmed']
23
+ deaths = results['latest']['deaths']
24
+
25
+ percentage = ((deaths.to_f / confirmed) * 100).round(2).to_s + ' %'
26
+
27
+ formatted << ['death rate', percentage]
28
+
21
29
  puts Terminal::Table.new :title => 'Latest Global Statistics', :rows => formatted, :style => { :width => 80 }
22
30
  end
23
31
 
@@ -41,7 +49,11 @@ def format_latest_country_stats(results, options = {})
41
49
  deaths = item['latest']['deaths']
42
50
  recovered = item['latest']['recovered']
43
51
  end
44
- processed[country_code] = { 'country' => item['country'], 'country_code' => country_code, 'id' => item['id'], 'confirmed' => confirmed, 'deaths' => deaths, 'recovered' => recovered }
52
+ percentage = ((deaths.to_f / confirmed) * 100).round(2)
53
+
54
+ percentage = 0 if percentage.nil?
55
+
56
+ processed[country_code] = { 'country' => item['country'], 'country_code' => country_code, 'id' => item['id'], 'confirmed' => confirmed, 'deaths' => deaths, 'recovered' => recovered, 'death_rate' => percentage }
45
57
  end
46
58
 
47
59
  sorted = []
@@ -53,13 +65,14 @@ def format_latest_country_stats(results, options = {})
53
65
  sorted = sorted.sort_by { |k| k['confirmed'] }.reverse if options[:confirmed]
54
66
  sorted = sorted.sort_by { |k| k['deaths'] }.reverse if options[:deaths]
55
67
  sorted = sorted.sort_by { |k| k['recovered'] }.reverse if options[:recovered]
68
+ sorted = sorted.sort_by { |k| k['death_rate'] }.reverse if options[:percentage]
56
69
 
57
70
  formatted = []
58
71
  sorted.each do |item|
59
- formatted << [item['country'], item['country_code'], item['id'], item['confirmed'], item['deaths'], item['recovered']]
72
+ formatted << [item['country'], item['country_code'], item['id'], item['confirmed'], item['deaths'], item['recovered'], item['death_rate'].to_s + ' %']
60
73
  end
61
74
 
62
- table = Terminal::Table.new :title => 'Latest Statistics by Country', :headings => ['Country', 'Code', 'ID', 'Confirmed', 'Deaths', 'Recovered'], :rows => formatted, :style => { :padding_left => 2, :padding_right => 2 }
75
+ table = Terminal::Table.new :title => 'Latest Statistics by Country', :headings => ['Country', 'Code', 'ID', 'Confirmed', 'Deaths', 'Recovered', 'Death Rate'], :rows => formatted, :style => { :padding_left => 2, :padding_right => 2 }
63
76
  table.align_column(1, :center)
64
77
  table.align_column(2, :right)
65
78
  table.align_column(3, :right)
@@ -115,18 +128,28 @@ def process_arguments
115
128
  opts.on('-c', '--confirmed', 'Order results by confirmed cases') do
116
129
  options[:confirmed] = true
117
130
  options[:deaths] = false
131
+ options[:percentage] = false
118
132
  options[:recovered] = false
119
133
  end
120
134
 
121
135
  opts.on('-d', '--deaths', 'Order results by deaths') do
122
136
  options[:confirmed] = false
123
137
  options[:deaths] = true
138
+ options[:percentage] = false
139
+ options[:recovered] = false
140
+ end
141
+
142
+ opts.on('-p', '--death-rate', 'Order results by percentage of deaths (death rate)') do
143
+ options[:confirmed] = false
144
+ options[:deaths] = false
145
+ options[:percentage] = true
124
146
  options[:recovered] = false
125
147
  end
126
148
 
127
149
  opts.on('-r', '--recovered', 'Order results by recovered numbers') do
128
150
  options[:confirmed] = false
129
151
  options[:deaths] = false
152
+ options[:percentage] = false
130
153
  options[:recovered] = true
131
154
  end
132
155
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: covid19
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gurney aka Wolf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-19 00:00:00.000000000 Z
11
+ date: 2020-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,6 +99,7 @@ files:
99
99
  - LICENSE.md
100
100
  - README.md
101
101
  - Rakefile
102
+ - VERSION.txt
102
103
  - bin/console
103
104
  - bin/setup
104
105
  - covid19.gemspec