covid 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35923fa3834ae014ca0219955ff2dc0e2ddb7bc0c655893bac3119ffd5dec718
4
- data.tar.gz: b0f6390ab836cc3ea7a8043e2e6fb24072d1e19e76b298074d6aa835d76966e8
3
+ metadata.gz: 45031ff90f434962a6dcbadd4637e70aa37d6d71887a2c4853a1264431b2d85f
4
+ data.tar.gz: 180e814b23cdf9741db5c18350b9cde087c633d57f0aa43fcb749e153145858c
5
5
  SHA512:
6
- metadata.gz: a6c619fe85383eb53c8a5e6d52440ed47789d17349753a9c3a118f7f43e28a053d355d1cb49b346bcef93e244f03a507be9e202cc9cb1dcdc13e8c787451f3c7
7
- data.tar.gz: 76c93830dfc16a39fdd332176c93f26de6fb7d9ec36e07e6786487f4352ca941c45d2c24640e08d7f81972b2c9bea104bf39a489c52fa7cb4fbebd5a7b2702a9
6
+ metadata.gz: ddbf567e6cd6f1a776b79c9c399760616b7afa7c57f569c2a9cc84a08879919e29b68974a68ecb77d016f644960c9f05cc96c44a5d7f8d6b52d81e55dc77006b
7
+ data.tar.gz: b891a1c3b7850c4edca62df515fcd987619c8db6aa325aaa070a65239e93411bc4b97135a39ad5ecaf7ae3bf62e9d49bc7349cff6d4abcd22c5fd546b9bc85f0
@@ -0,0 +1,21 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ schedule:
7
+ - cron: '0 16 * * Sat'
8
+ jobs:
9
+ build:
10
+ name: Smoke Test
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby 2.6
15
+ uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.6.x
18
+ - name: Install dependencies
19
+ run: bundle install
20
+ - name: Run smoke test
21
+ run: rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- covid (0.1.1)
4
+ covid (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,10 +26,10 @@ PLATFORMS
26
26
  ruby
27
27
 
28
28
  DEPENDENCIES
29
- bundler (~> 1.17)
29
+ bundler (>= 2.3.5)
30
30
  covid!
31
31
  rake (~> 13.0)
32
32
  rspec (~> 3.0)
33
33
 
34
34
  BUNDLED WITH
35
- 1.17.2
35
+ 2.3.5
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Covid
2
2
 
3
- JSON wrapper around [Johns Hopkins dataset](https://github.com/CSSEGISandData/COVID-19) for COVID-19.
3
+ Ruby wrapper around [Johns Hopkins dataset](https://github.com/CSSEGISandData/COVID-19) for COVID-19.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'covid'
10
+ gem "covid"
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -21,18 +21,38 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```
24
- $ puts Covid::Nineteen.confirmed
24
+ $ Covid::Nineteen.confirmed
25
+ $ Covid::Nineteen.deaths
26
+ $ Covid::Nineteen.recovered
25
27
  ```
26
28
 
29
+ Any result can be filtered by country/region and/or state/province like so:
27
30
  ```
28
- $ puts Covid::Nineteen.deaths
31
+ $ confirmed = Covid::Nineteen.confirmed
32
+ $ confirmed.country("Australia")
33
+ $ confirmed.region("Australia")
34
+ $ confirmed.state("Victoria")
35
+ $ confirmed.province("Victoria")
36
+ $ confirmed.country("Australia").province("Victoria")
29
37
  ```
30
38
 
39
+ The data is structured as such:
31
40
  ```
32
- $ puts Covid::Nineteen.recovered
41
+ $ pp Covid::Nineteen.confirmed
42
+ [
43
+ {
44
+ "Province/State"=>nil,
45
+ "Country/Region"=>"Thailand",
46
+ "Lat"=>"15",
47
+ "Long"=>"101",
48
+ "1/22/20"=>"2",
49
+ "1/23/20"=>"3",
50
+ "1/24/20"=>"5"
51
+ },
52
+ { ... }
53
+ ]
33
54
  ```
34
55
 
35
-
36
56
  ## Development
37
57
 
38
58
  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.
data/covid.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ["lib"]
36
36
 
37
- spec.add_development_dependency "bundler", "~> 1.17"
37
+ spec.add_development_dependency "bundler", ">= 2.3.5"
38
38
  spec.add_development_dependency "rake", "~> 13.0"
39
39
  spec.add_development_dependency "rspec", "~> 3.0"
40
40
  end
data/lib/covid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Covid
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/covid.rb CHANGED
@@ -7,18 +7,37 @@ require "net/http"
7
7
 
8
8
  module Covid
9
9
  class Error < StandardError; end
10
+ class Result < Array
11
+ def country(name)
12
+ filter("Country/Region", name)
13
+ end
14
+
15
+ def state(name)
16
+ filter("Province/State", name)
17
+ end
18
+
19
+ alias_method :region, :country
20
+ alias_method :province, :state
21
+
22
+ private
23
+
24
+ def filter(key, name)
25
+ self.class.new(select { |result| result[key] == name })
26
+ end
27
+ end
28
+
10
29
  class Nineteen
11
30
  BASE_URI = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/"
12
- CONFIRMED = "time_series_19-covid-Confirmed.csv"
13
- DEATHS = "time_series_19-covid-Deaths.csv"
14
- RECOVERED = "time_series_19-covid-Recovered.csv"
31
+ CONFIRMED = "time_series_covid19_confirmed_global.csv"
32
+ DEATHS = "time_series_covid19_deaths_global.csv"
33
+ RECOVERED = "time_series_covid19_recovered_global.csv"
15
34
 
16
35
  def initialize(path)
17
36
  @path = path
18
37
  end
19
38
 
20
39
  def run
21
- csv.map(&:to_h).to_json
40
+ Result.new(parsed_json)
22
41
  end
23
42
 
24
43
  def self.confirmed
@@ -39,10 +58,18 @@ module Covid
39
58
  CSV.parse(response, headers: true)
40
59
  end
41
60
 
61
+ def raw
62
+ csv.map(&:to_h).to_json
63
+ end
64
+
42
65
  def response
43
66
  Net::HTTP.get(uri)
44
67
  end
45
68
 
69
+ def parsed_json
70
+ JSON.parse(raw)
71
+ end
72
+
46
73
  def uri
47
74
  URI(BASE_URI + @path)
48
75
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: covid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Thom
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-14 00:00:00.000000000 Z
11
+ date: 2022-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: 2.3.5
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: 2.3.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,13 +52,14 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description:
55
+ description:
56
56
  email:
57
57
  - jonathan.thom1990@gmail.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/gempush.yml"
62
63
  - ".gitignore"
63
64
  - ".rspec"
64
65
  - ".travis.yml"
@@ -79,7 +80,7 @@ metadata:
79
80
  allowed_push_host: https://rubygems.org
80
81
  homepage_uri: https://github.com/jonathanwthom/covid
81
82
  source_code_uri: https://github.com/jonathanwthom/covid
82
- post_install_message:
83
+ post_install_message:
83
84
  rdoc_options: []
84
85
  require_paths:
85
86
  - lib
@@ -94,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
95
  - !ruby/object:Gem::Version
95
96
  version: '0'
96
97
  requirements: []
97
- rubygems_version: 3.0.3
98
- signing_key:
98
+ rubygems_version: 3.2.32
99
+ signing_key:
99
100
  specification_version: 4
100
101
  summary: JSON wrapper around Johns Hopkins COVID-19 dataset
101
102
  test_files: []