covid19 0.1.1 → 0.1.2

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: 6733fa65744f743fda7c448e801dd984fc0a1737ab90e71b8ad748f1477cd59b
4
- data.tar.gz: 6ab5afaa596136070a056a1edc4833126b9a61440512a7c9dc1f4e7303b956f7
3
+ metadata.gz: '07796add8d36511f373a1ed6268fa95cc164577d9fb19726e592f6f4b33ecb2c'
4
+ data.tar.gz: eee233d00944280fd37ae88c06f78f7be419225e102d135107ad9ecae4aee355
5
5
  SHA512:
6
- metadata.gz: d03cc9515829db8b90f90dd975a95826e1271a3d5951512c4f637c7174adb3a009bb933484cae985c108a0e9e5a1f11c74d4ad1c099f179499bafd480e1f01d2
7
- data.tar.gz: 8c84f7ca6fec08e92f6965e92bb12a1d0b7480fb968376211b7bdadacf4626ec8f8f17f0bedab815fa376af67f93ff622a53c54d5da56c25a4bfcf85cf8aba3d
6
+ metadata.gz: 0e9f6750488e1a05e7c9ff620497c7c7e4376412c6da31acf6d6afce8d559b0b0de032eeae6d1f1b72e156a7de57581186e42fa1b769c0b0acd4e0eba78e5802
7
+ data.tar.gz: 5c0408ad61b9c7bf48c664aa301be11c7bd998be2ea82ba303371cb8ef09325e672b73b866144ef1d00147d4e1ea167c168a169dc1a87335785884b74cede305
@@ -5,9 +5,13 @@ 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/v0.1.0...HEAD)
8
+ ### [v0.1.2](https://github.com/WolfAtheneum/covid19/compare/v0.1.0...v0.1.2)
9
9
 
10
- - Add a death rate as a percentage of confirmed cases [`[660e2b6]`](https://github.com/WolfAtheneum/covid19/commit/660e2b6e17b2ababed7e0c820a8d687b867cdf7f) [`[TGWolf]`](https://github.com/TGWolf)
10
+ > Released on March, 23rd 2020
11
+
12
+ - Add the new code to the binary as it was only added to the testing binary [`[e99c9ec]`](https://github.com/WolfAtheneum/covid19/commit/e99c9ec9a37d38b05ec1b632f0cb07e68788a19a) [`[TGWolf]`](https://github.com/TGWolf)
13
+
14
+ - Add a death rate as a percentage of confirmed cases [`[348efbf]`](https://github.com/WolfAtheneum/covid19/commit/348efbf2c1ca5bdffbd369595c670acc7cadeaf8) [`[TGWolf]`](https://github.com/TGWolf)
11
15
 
12
16
  ### [v0.1.0](https://github.com/WolfAtheneum/covid19/releases/v0.1.0)
13
17
 
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -17,6 +17,14 @@ def format_latest_stats(results)
17
17
  results['latest'].each do |key, value|
18
18
  formatted << [key, value]
19
19
  end
20
+
21
+ confirmed = results['latest']['confirmed']
22
+ deaths = results['latest']['deaths']
23
+
24
+ percentage = ((deaths.to_f / confirmed) * 100).round(2).to_s + ' %'
25
+
26
+ formatted << ['death rate', percentage]
27
+
20
28
  puts Terminal::Table.new :title => 'Latest Global Statistics', :rows => formatted, :style => { :width => 80 }
21
29
  end
22
30
 
@@ -40,7 +48,11 @@ def format_latest_country_stats(results, options = {})
40
48
  deaths = item['latest']['deaths']
41
49
  recovered = item['latest']['recovered']
42
50
  end
43
- processed[country_code] = { 'country' => item['country'], 'country_code' => country_code, 'id' => item['id'], 'confirmed' => confirmed, 'deaths' => deaths, 'recovered' => recovered }
51
+ percentage = ((deaths.to_f / confirmed) * 100).round(2)
52
+
53
+ percentage = 0 if percentage.nil?
54
+
55
+ processed[country_code] = { 'country' => item['country'], 'country_code' => country_code, 'id' => item['id'], 'confirmed' => confirmed, 'deaths' => deaths, 'recovered' => recovered, 'death_rate' => percentage }
44
56
  end
45
57
 
46
58
  sorted = []
@@ -52,13 +64,14 @@ def format_latest_country_stats(results, options = {})
52
64
  sorted = sorted.sort_by { |k| k['confirmed'] }.reverse if options[:confirmed]
53
65
  sorted = sorted.sort_by { |k| k['deaths'] }.reverse if options[:deaths]
54
66
  sorted = sorted.sort_by { |k| k['recovered'] }.reverse if options[:recovered]
67
+ sorted = sorted.sort_by { |k| k['death_rate'] }.reverse if options[:percentage]
55
68
 
56
69
  formatted = []
57
70
  sorted.each do |item|
58
- formatted << [item['country'], item['country_code'], item['id'], item['confirmed'], item['deaths'], item['recovered']]
71
+ formatted << [item['country'], item['country_code'], item['id'], item['confirmed'], item['deaths'], item['recovered'], item['death_rate'].to_s + ' %']
59
72
  end
60
73
 
61
- 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 }
74
+ 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 }
62
75
  table.align_column(1, :center)
63
76
  table.align_column(2, :right)
64
77
  table.align_column(3, :right)
@@ -114,18 +127,28 @@ def process_arguments
114
127
  opts.on('-c', '--confirmed', 'Order results by confirmed cases') do
115
128
  options[:confirmed] = true
116
129
  options[:deaths] = false
130
+ options[:percentage] = false
117
131
  options[:recovered] = false
118
132
  end
119
133
 
120
134
  opts.on('-d', '--deaths', 'Order results by deaths') do
121
135
  options[:confirmed] = false
122
136
  options[:deaths] = true
137
+ options[:percentage] = false
138
+ options[:recovered] = false
139
+ end
140
+
141
+ opts.on('-p', '--death-rate', 'Order results by percentage of deaths (death rate)') do
142
+ options[:confirmed] = false
143
+ options[:deaths] = false
144
+ options[:percentage] = true
123
145
  options[:recovered] = false
124
146
  end
125
147
 
126
148
  opts.on('-r', '--recovered', 'Order results by recovered numbers') do
127
149
  options[:confirmed] = false
128
150
  options[:deaths] = false
151
+ options[:percentage] = false
129
152
  options[:recovered] = true
130
153
  end
131
154
  end
@@ -1,3 +1,3 @@
1
1
  class Covid19
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: covid19
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gurney aka Wolf