covid19-rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb5d25789f7091413c4cfef3fa2e511d62effc3019c0ab8dcf11c4b1a166c1e9
4
+ data.tar.gz: fc325e2934719f70123028c1b80a32d68455ebf2a5c1c013bda6da4e402bca12
5
+ SHA512:
6
+ metadata.gz: 34efe9ca0bb341d2f1892716196ce2eeb126f919b0a0b5a73dffc41370c2518937eb41a4a5eed1e0628eabfa41df87703ab7ca5ae171f84a1ffc8df03f4b837b
7
+ data.tar.gz: b13638444a4ce380c1bb0f8aaa9575b67da9e5aa001fa89c9692fbfb30307d0855c027b23895209d199121cdc020efd889e6a8a04a3c6a3f861415b09b7075d2
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.1
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,3 @@
1
+ # Change Log
2
+
3
+ Tbd
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at 1703579+viccarrasco@users.noreply.github.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in covid19.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ covid19-rb (0.1.0)
5
+ arssene
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ arssene (0.1.3)
11
+ mechanize
12
+ sanitize
13
+ byebug (11.1.1)
14
+ connection_pool (2.2.2)
15
+ crass (1.0.6)
16
+ diff-lcs (1.3)
17
+ domain_name (0.5.20190701)
18
+ unf (>= 0.0.5, < 1.0.0)
19
+ http-cookie (1.0.3)
20
+ domain_name (~> 0.5)
21
+ mechanize (2.7.6)
22
+ domain_name (~> 0.5, >= 0.5.1)
23
+ http-cookie (~> 1.0)
24
+ mime-types (>= 1.17.2)
25
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
26
+ net-http-persistent (>= 2.5.2)
27
+ nokogiri (~> 1.6)
28
+ ntlm-http (~> 0.1, >= 0.1.1)
29
+ webrobots (>= 0.0.9, < 0.2)
30
+ mime-types (3.3.1)
31
+ mime-types-data (~> 3.2015)
32
+ mime-types-data (3.2019.1009)
33
+ mini_portile2 (2.4.0)
34
+ net-http-digest_auth (1.4.1)
35
+ net-http-persistent (3.1.0)
36
+ connection_pool (~> 2.2)
37
+ nokogiri (1.10.8)
38
+ mini_portile2 (~> 2.4.0)
39
+ nokogumbo (2.0.2)
40
+ nokogiri (~> 1.8, >= 1.8.4)
41
+ ntlm-http (0.1.1)
42
+ rake (12.3.3)
43
+ rspec (3.9.0)
44
+ rspec-core (~> 3.9.0)
45
+ rspec-expectations (~> 3.9.0)
46
+ rspec-mocks (~> 3.9.0)
47
+ rspec-core (3.9.1)
48
+ rspec-support (~> 3.9.1)
49
+ rspec-expectations (3.9.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.9.0)
52
+ rspec-mocks (3.9.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.9.0)
55
+ rspec-support (3.9.2)
56
+ sanitize (5.1.0)
57
+ crass (~> 1.0.2)
58
+ nokogiri (>= 1.8.0)
59
+ nokogumbo (~> 2.0)
60
+ unf (0.1.4)
61
+ unf_ext
62
+ unf_ext (0.0.7.6)
63
+ webrobots (0.1.2)
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ bundler (~> 2.0)
70
+ byebug
71
+ covid19-rb!
72
+ rake (~> 12.0)
73
+ rspec (~> 3.0)
74
+
75
+ BUNDLED WITH
76
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Vic Carrasco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,339 @@
1
+ # Covid19
2
+
3
+ This tool's goal is to create an easy way to start building projects which have as goal fighting the unprecedented virus **Covid-19**. If you stumble upon this gem, please share it as someone might find it useful.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'covid19-rb'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install covid19
23
+ ```
24
+
25
+ ## Retrieve Global Statistics
26
+
27
+ ```ruby
28
+ statistics = Covid19::GlobalStatistics.retrieve
29
+ puts statistics
30
+ # =>
31
+ ```
32
+
33
+ ```json
34
+ {
35
+ "results": [
36
+ {
37
+ "total_cases": 259273,
38
+ "total_recovered": 89914,
39
+ "total_unresolved": 158195,
40
+ "total_deaths": 10546,
41
+ "total_new_cases_today": 14379,
42
+ "total_new_deaths_today": 518,
43
+ "total_active_cases": 158813,
44
+ "total_serious_cases": 7636,
45
+ "source": {
46
+ "url": "https://thevirustracker.com/"
47
+ }
48
+ }
49
+ ],
50
+ "stat": "ok"
51
+ }
52
+ ```
53
+
54
+ ## Retrieve Statistics by Country
55
+
56
+ ```ruby
57
+ italy_statistics = Covid19::GlobalStatistics.by(country: 'it')
58
+ puts italy_statistics
59
+ # =>
60
+ ```
61
+
62
+ ```json
63
+ {
64
+ "countrydata": [
65
+ {
66
+ "info": {
67
+ "ourid": 78,
68
+ "title": "Italy",
69
+ "code": "IT",
70
+ "source": "https://thevirustracker.com/italy-coronavirus-information-it"
71
+ },
72
+ "total_cases": 41035,
73
+ "total_recovered": 4440,
74
+ "total_unresolved": 0,
75
+ "total_deaths": 3405,
76
+ "total_new_cases_today": 0,
77
+ "total_new_deaths_today": 0,
78
+ "total_active_cases": 33190,
79
+ "total_serious_cases": 2498
80
+ }
81
+ ],
82
+ "countrynewsitems": [
83
+ {
84
+ "60": {
85
+ "newsid": "iOG6m7",
86
+ "title": "Leave Italy Washington U. tells study-abroad students after CDC coronavirus alert",
87
+ "image": "https://thevirustracker.com/news-images/thumbs/5/leave-italy-washington-u-tells-study-abroad-students-after-cdc-coronavirus-alert-iOG6m7.jpg",
88
+ "time": "3 March 2020 05:12",
89
+ "url": "https://thevirustracker.com/story/leave-italy-washington-u-tells-study-abroad-students-after-cdc-coronavirus-alert-iOG6m7"
90
+ },
91
+ "61": {
92
+ "newsid": "KhyueW",
93
+ "title": "GRCC cancels culinary study abroad program to Italy due to coronavirus concerns",
94
+ "image": "https://thevirustracker.com/news-images/thumbs/5/grcc-cancels-culinary-study-abroad-program-to-italy-due-to-coronavirus-concerns-KhyueW.jpg",
95
+ "time": "3 March 2020 05:12",
96
+ "url": "https://thevirustracker.com/story/grcc-cancels-culinary-study-abroad-program-to-italy-due-to-coronavirus-concerns-KhyueW"
97
+ },
98
+ "62": {
99
+ "newsid": "OTW4jB",
100
+ "title": "Pope tests negative for coronavirus Italy report says",
101
+ "image": "https://thevirustracker.com/news-images/thumbs/5/pope-tests-negative-for-coronavirus-italy-report-says-OTW4jB.jpg",
102
+ "time": "3 March 2020 06:45",
103
+ "url": "https://thevirustracker.com/story/pope-tests-negative-for-coronavirus-italy-report-says-OTW4jB"
104
+ },
105
+ "63": {
106
+ "newsid": "062yDp",
107
+ "title": "Italy's coronavirus outbreak has ramifications for rest of Europe professor says",
108
+ "image": "https://thevirustracker.com/news-images/thumbs/5/italy-s-coronavirus-outbreak-has-ramifications-for-rest-of-europe-professor-says-062yDp.jpg",
109
+ "time": "3 March 2020 09:41",
110
+ "url": "https://thevirustracker.com/story/italy-s-coronavirus-outbreak-has-ramifications-for-rest-of-europe-professor-says-062yDp"
111
+ },
112
+ "64": {
113
+ "newsid": "UUp8f2",
114
+ "title": "US Requires Airline Passengers From Iran But Not Italy Or Korea To Use Designated Airports To Control Coronavirus",
115
+ "image": "https://thevirustracker.com/news-images/thumbs/5/us-requires-airline-passengers-from-iran-but-not-italy-or-korea-to-use-designated-airports-to-control-coronavirus-UUp8f2.jpg",
116
+ "time": "3 March 2020 11:01",
117
+ "url": "https://thevirustracker.com/story/us-requires-airline-passengers-from-iran-but-not-italy-or-korea-to-use-designated-airports-to-control-coronavirus-UUp8f2"
118
+ },
119
+ "65": {
120
+ "newsid": "snjWyP",
121
+ "title": "Coronavirus: Inter chief Zhang's 'clown' comment probed by Serie A",
122
+ "image": "https://thevirustracker.com/news-images/thumbs/5/coronavirus-inter-chief-zhang-s-clown-comment-probed-by-serie-a-snjWyP.jpg",
123
+ "time": "3 March 2020 12:48",
124
+ "url": "https://thevirustracker.com/story/coronavirus-inter-chief-zhang-s-clown-comment-probed-by-serie-a-snjWyP"
125
+ },
126
+ "stat": "ok"
127
+ }
128
+ ]
129
+ }
130
+ ```
131
+
132
+ ## Timelines
133
+
134
+ You can retrieve a global timeline by doing the following:
135
+
136
+ ```ruby
137
+ timeline = Covid19::Timeline.retrieve
138
+ ```
139
+
140
+ You can also request a timeline by country as so:
141
+
142
+ ```ruby
143
+ timeline = Covid19::Timeline.by(country: 'it')
144
+ puts timeline
145
+ # =>
146
+ ```
147
+
148
+ ```json
149
+ {
150
+ "countrytimelinedata": [
151
+ {
152
+ "info": {
153
+ "ourid": 78,
154
+ "title": "Italy",
155
+ "code": "IT",
156
+ "source": "https://thevirustracker.com/italy-coronavirus-information-it"
157
+ }
158
+ }
159
+ ],
160
+ "timelineitems": [
161
+ {
162
+ "3/17/2020": {
163
+ "new_daily_cases": 3526,
164
+ "new_daily_deaths": 345,
165
+ "total_cases": 31506,
166
+ "total_recoveries": 2941,
167
+ "total_deaths": 2503
168
+ },
169
+ "3/18/2020": {
170
+ "new_daily_cases": 4207,
171
+ "new_daily_deaths": 475,
172
+ "total_cases": 35713,
173
+ "total_recoveries": 4025,
174
+ "total_deaths": 2978
175
+ },
176
+ "3/19/2020": {
177
+ "new_daily_cases": 5322,
178
+ "new_daily_deaths": 427,
179
+ "total_cases": 41035,
180
+ "total_recoveries": 4440,
181
+ "total_deaths": 3405
182
+ },
183
+ "3/20/2020": {
184
+ "new_daily_cases": 0,
185
+ "new_daily_deaths": 0,
186
+ "total_cases": 41035,
187
+ "total_recoveries": 4440,
188
+ "total_deaths": 3405
189
+ },
190
+ "stat": "ok"
191
+ }
192
+ ]
193
+ }
194
+ ```
195
+
196
+ ## News
197
+
198
+ By default the news will be retrieved from [The World Health Organization](https://www.who.int/)
199
+
200
+ ```ruby
201
+ who = Covid19::News.retrieve
202
+ ```
203
+
204
+ ```json
205
+ {
206
+ "title":"News (English) - World Health Organization",
207
+ "description":"Corporate news releases, statements, and notes for media issued by the World Health Organization.",
208
+ "entries":[
209
+ {
210
+ "title":"Dracunculiasis eradication: intensifying surveillance amid continued zero human cases in Ethiopia and Mali",
211
+ "link":"https://www.who.int/news-room/detail/19-03-2020-dracunculiasis-eradication-intensifying-surveillance-amid-continued-zero-human-cases-in-ethiopia-and-mali",
212
+ "date":"Thu, 19 Mar 2020 18:23:38 -0000",
213
+ "description":"In 2019, Ethiopia and Mali reported zero human cases of dracunculiasis (guinea-worm disease), although the total number of human cases reported to the World Health Organization (WHO) last year peaked at 54 cases.nWhile surveillance activities have been stepped-up in countries reporting cases, hundreds more field workers and volunteers are being trained, and, cross-border vigilance are being carried out to prevent transmission."
214
+ },
215
+ {
216
+ "title":"CND accepts all WHO recommendations on the control of several psychoactive substances from the 42nd ECDD meeting",
217
+ "link":"https://www.who.int/news-room/detail/18-03-2020-c-n-d-accepts-all-w-h-o-recommendations-from-42nd-e-c-d-d",
218
+ "date":"Thu, 19 Mar 2020 08:20:13 -0000",
219
+ "description":"During its 63rd session, the Commission on Narcotic Drugs (CND) accepted all recommendations from the 42nd meeting of the WHO Expert Committee on Drug Dependence (ECDD)."
220
+ },
221
+ {
222
+ "title":"Water and Climate Change",
223
+ "link":"https://www.who.int/news-room/detail/17-03-2020-water-and-climate-change",
224
+ "date":"Mon, 16 Mar 2020 17:08:49 -0000",
225
+ "description":"<p>World Water Day 2020 is about water and climate change &ndash; and how the two are inextricably linked. This year&rsquo;s campaign shows how our use of water will help reduce floods, droughts, scarcity and pollution, and will help fight climate change itself. By adapting to the water effects of climate change, we will protect health and save lives. And, by using water more efficiently, we will reduce greenhouse gases. Our key messages are clear:</p><ul><li>We cannot afford to wait. Climate policy makers must put water at the heart of action plans.</li><li>Climate change effects water supplies and human health.</li><li>Health systems need to prepare for more water-related disease associated with climate change.</li><li>Water can help fight climate change and protect health. There are sustainable, affordable and scalable water and sanitation solutions.</li><li>Everyone has a role to play. In our daily lives, there are surprisingly easy steps we can all take to address climate change, and protect health.</li></ul><p></p>"
226
+ }
227
+ ]
228
+ }
229
+ ```
230
+
231
+ You may also retrieve information from another source if you know the rss feed's url. Please check [Arssene](https://github.com/viccarrasco/arssene) for further information.
232
+
233
+ ```ruby
234
+ feed = 'https://tools.cdc.gov/api/v2/resources/media/403372.rss'
235
+ news = Covid19::News.retrieve(rss: feed)
236
+ puts news
237
+ # =>
238
+ ```
239
+
240
+ ```json
241
+ {
242
+ "title": "2019 Novel Coronavirus",
243
+ "description": "The Centers for Disease Control and Prevention (CDC) is closely monitoring an outbreak of respiratory illness caused by a novel (new) coronavirus first identified in Wuhan, Hubei Province, China.",
244
+ "entries": [
245
+ {
246
+ "title": "Resources for Large Community Events & Mass Gatherings",
247
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405375",
248
+ "date": "Fri, 20 Mar 2020 15:00:00 +0000",
249
+ "description": "Resources for large community events and mass gatherings"
250
+ },
251
+ {
252
+ "title": "Environmental Cleaning and Disinfection Recommendations",
253
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=404586",
254
+ "date": "Fri, 20 Mar 2020 15:00:00 +0000",
255
+ "description": "Environmental Cleaning and Disinfection Recommendations"
256
+ },
257
+ {
258
+ "title": "Interim Guidance for Businesses and Employers",
259
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=403631",
260
+ "date": "Fri, 20 Mar 2020 15:00:00 +0000",
261
+ "description": "The following interim guidance may help prevent workplace exposures to acute respiratory illnesses, including COVID-19, in non-healthcare settings. The guidance also provides planning considerations if there are more widespread, community outbreaks of COVID-19."
262
+ },
263
+ {
264
+ "title": "Get Your Community- and Faith-Based Organizations Ready for Coronavirus Disease 2019",
265
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405374",
266
+ "date": "Fri, 20 Mar 2020 14:00:00 +0000",
267
+ "description": "This interim guidance is to help community- and faith-based organizations (CFBOs), whose members may include vulnerable populations, plan for community transmission of coronavirus disease (COVID-19) in the United States."
268
+ },
269
+ {
270
+ "title": "Get Your Mass Gatherings or Large Community Events Ready",
271
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=404922",
272
+ "date": "Fri, 20 Mar 2020 14:00:00 +0000",
273
+ "description": "This interim guidance is intended for organizers and staff responsible for planning mass gatherings or large community events in the United States. A mass gathering is a planned or spontaneous event with a large number of people in attendance that could strain the planning and response resources of the community hosting the event, such as a concert, festival, conference, or sporting event."
274
+ },
275
+ {
276
+ "title": "Disinfecting Your Facility if Someone is Sick",
277
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405360",
278
+ "date": "Thu, 19 Mar 2020 20:00:00 +0000",
279
+ "description": "Steps to disinfect your facility if someone is sick."
280
+ },
281
+ {
282
+ "title": "Taking Advantage of the 15-Day Pause to Slow the Spread of COVID-19",
283
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405368",
284
+ "date": "Thu, 19 Mar 2020 18:00:00 +0000",
285
+ "description": "Steps every sector can take during the 15-day pause to plan as One Community"
286
+ },
287
+ {
288
+ "title": "Travelers from Countries with Widespread Sustained (Ongoing) Transmission Arriving in the United States",
289
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405367",
290
+ "date": "Thu, 19 Mar 2020 18:00:00 +0000",
291
+ "description": "Depending on your travel history, you will be asked to stay home for a period of 14 days from the time you left an area with widespread or ongoing community spread."
292
+ },
293
+ {
294
+ "title": "Caring for someone at home",
295
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405343",
296
+ "date": "Thu, 19 Mar 2020 18:00:00 +0000",
297
+ "description": "Most people who get sick with COVID-19 will have only mild illness and should recover at home. Care at home can help stop the spread of COVID-19 and help protect people who are at risk for getting seriously ill from COVID-19."
298
+ },
299
+ {
300
+ "title": "Interim Infection Prevention and Control Recommendations for Patients with Suspected or Confirmed Coronavirus Disease 2019 (COVID-19) in Healthcare Settings",
301
+ "link": "https://tools.cdc.gov/api/embed/downloader/download.asp?m=403372&c=405362",
302
+ "date": "Thu, 19 Mar 2020 18:00:00 +0000",
303
+ "description": "This interim guidance has been updated based on currently available information about COVID-19 and the current situation in the United States, which includes reports of cases of community transmission, infections identified in healthcare personnel (HCP), and shortages of facemasks, N95 filtering facepiece respirators (FFRs) (commonly known as N95 respirators), and gowns."
304
+ }
305
+ ]
306
+ }
307
+ ```
308
+
309
+ ## Accepted parameters
310
+
311
+ For `country` please use one of the following keys:
312
+
313
+ ```ruby
314
+ af al dz as ad ao ai aq ag ar am aw au at az bs bh bd bb by
315
+ be bz bj bm bt bo ba bw bv br io bn bg bf bi kh cm ca cv ky
316
+ cf td cl cn cx cc co km cg cd ck cr ci hr cu cy cz dk dj dm
317
+ do ec eg sv gq er ee et fk fo fj fi fr gf pf tf ga gm ge de
318
+ gh gi gr gl gd gp gu gt gn gw gy ht hm va hn hk hu is in id
319
+ ir iq ie il it jm jp jo kz ke ki kp kr kw kg la lv lb ls lr
320
+ ly li lt lu mo mk mg mw my mv ml mt mh mq mr mu yt mx fm md
321
+ mc mn ms ma mz mm na nr np nl an nc nz ni ne ng nu nf mp no
322
+ om pk pw ps pa pg py pe ph pn pl pt pr qa re ro ru rw sh kn
323
+ lc pm vc ws sm st sa sn cs sc sl sg sk si sb so za gs sp lk
324
+ sd sr sj sz se ch sy tw tj tz th tl tg tk to tt tn tr tm tc
325
+ tv ug ua ae uk us um uy uz vu ve vn vg vi wf eh ye zm zw
326
+ ```
327
+
328
+
329
+ ## Contributing
330
+
331
+ Bug reports and pull requests are welcome on GitHub at https://github.com/viccarrasco/covid19. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/covid19/blob/master/CODE_OF_CONDUCT.md).
332
+
333
+ ## License
334
+
335
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
336
+
337
+ ## Code of Conduct
338
+
339
+ Everyone interacting in the Covid19 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/covid19/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "covid19"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/covid19/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'covid19-rb'
7
+ spec.version = Covid19::VERSION
8
+ spec.authors = ['Vic Carrasco']
9
+ spec.email = ['1703579+viccarrasco@users.noreply.github.com']
10
+
11
+ spec.summary = 'Fight Covid-19'
12
+ spec.description = 'Write a longer description or delete this line.'
13
+ spec.homepage = 'https://github.com/viccarrasco/covid-19'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = spec.homepage
21
+ spec.metadata['changelog_uri'] = 'https://github.com/viccarrasco/covid-19/blob/master/CHANGE_LOG.md'
22
+ else
23
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
24
+ 'public gem pushes.'
25
+ end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.add_development_dependency 'bundler', '~> 2.0'
37
+ spec.add_development_dependency 'byebug'
38
+ spec.add_development_dependency 'rake', '~> 12.3.3'
39
+ spec.add_development_dependency 'rspec'
40
+ spec.add_dependency 'arssene'
41
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'covid19/version'
4
+ require 'date'
5
+ require 'net/http'
6
+ require 'byebug'
7
+ require 'json'
8
+ require 'arssene'
9
+ require 'covid19/lib/presenters/presenters.rb'
10
+ require 'covid19/lib/base_resource.rb'
11
+ require 'covid19/lib/global.rb'
12
+ require 'covid19/lib/timeline.rb'
13
+ require 'covid19/lib/news.rb'
14
+ require 'covid19/lib/repositories/virus_tracker/base_repository.rb'
15
+ require 'covid19/lib/repositories/virus_tracker/statistics_repository.rb'
16
+ require 'covid19/lib/repositories/virus_tracker/timeline_repository.rb'
17
+ require 'covid19/lib/repositories/news/news_repository.rb'
18
+ require 'covid19/lib/validators/query_validator.rb'
19
+
20
+ module Covid19
21
+ class Error < StandardError; end
22
+ # Your code goes here...
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BaseResource
4
+ extend Presenters
5
+
6
+ def self.retrieve(**options)
7
+ raise 'NotImplementedException::retrieve'
8
+ end
9
+
10
+ def self.by(country:)
11
+ present_as_json(repository.by_country(country: country))
12
+ end
13
+
14
+ private
15
+
16
+ def self.repository
17
+ raise 'NotImplementedException::repository'
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Covid19
4
+ class GlobalStatistics < BaseResource
5
+ def self.retrieve(**options)
6
+ present_as_json(repository.global)
7
+ end
8
+
9
+ private
10
+
11
+ def self.repository
12
+ Repositories::Statistics.new
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Covid19
4
+ class News < BaseResource
5
+ def self.retrieve(**options)
6
+ present_as_json(repository.retrieve(options))
7
+ end
8
+
9
+ def self.by_country(country:)
10
+ raise 'NotYetImplementedError::News'
11
+ end
12
+
13
+ private
14
+
15
+ def self.repository
16
+ Repositories::News.new
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Presenters
4
+ def present_as_json(data)
5
+ JSON.parse(data).to_json
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Repositories
4
+ class News
5
+ WHO_FEED = 'https://www.who.int/rss-feeds/news-english.xml'
6
+
7
+ def retrieve(**args)
8
+ arssene = Arssene::Feed.request(rss(args), from_date: DateTime.now - 2)[:channel]
9
+ data = {
10
+ title: arssene.title,
11
+ description: arssene.description,
12
+ entries: entries_to_hash(arssene.entries)
13
+ }
14
+ data.to_json
15
+ end
16
+
17
+ private
18
+
19
+ def rss(parameters)
20
+ parameters[:rss].nil? ? WHO_FEED : parameters[:rss]
21
+ end
22
+
23
+ def entries_to_hash(entries)
24
+ entries.map.with_index do |entry, index|
25
+ entries[index] = {
26
+ title: entry.title,
27
+ link: entry.link.strip.chomp,
28
+ date: entry.publication_date.to_s.strip.chomp,
29
+ description: entry.description.strip.chomp
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BaseRepository
4
+ GLOBAL_STATS_URL = 'https://thevirustracker.com/'
5
+ DEFAULT_RESOURCE = 'free-api'
6
+
7
+ attr_reader :query_validator
8
+
9
+ def initialize
10
+ @query_validator = Validators::QueryValidator.new
11
+ end
12
+
13
+ def global
14
+ raise 'NotImplementedError::global'
15
+ end
16
+
17
+ def by_country(country:)
18
+ raise 'NotImplementedError::by_country'
19
+ end
20
+
21
+ private
22
+
23
+ def retrieve(resource:, query:)
24
+ if query_validator.valid?(query: query)
25
+ response = ping_api(GLOBAL_STATS_URL, resource: resource, query: query)
26
+ response.body
27
+ else
28
+ { error: 'Invalid parameter sequence' }.to_json
29
+ end
30
+ rescue => exception
31
+ { error: "Unexpected Error: #{exception}" }.to_json
32
+ end
33
+
34
+ def ping_api(uri, **options)
35
+ uri = URI(uri += options[:resource]) if options[:resource]
36
+ uri.query = URI.encode_www_form(options[:query]) if options[:query]
37
+ Net::HTTP.get_response(uri)
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Repositories
4
+ class Statistics < BaseRepository
5
+ def global
6
+ retrieve(resource: DEFAULT_RESOURCE, query: { global: 'stats' })
7
+ end
8
+
9
+ def by_country(country:)
10
+ country = country.upcase unless country.nil?
11
+ retrieve(resource: DEFAULT_RESOURCE, query: { countryTotal: country })
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Repositories
4
+ class Timeline < BaseRepository
5
+ def global
6
+ retrieve(resource: 'timeline/map-data.json', query: {})
7
+ end
8
+
9
+ def by_country(country:)
10
+ retrieve(resource: DEFAULT_RESOURCE, query: { countryTimeline: country&.upcase })
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Covid19
4
+ class Timeline < BaseResource
5
+ def self.retrieve(**options)
6
+ present_as_json(repository.global)
7
+ end
8
+
9
+ private
10
+
11
+ def self.repository
12
+ Repositories::Timeline.new
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Validators
4
+ class QueryValidator
5
+ COUNTRIES = %w[
6
+ af al dz as ad ao ai aq ag ar am aw au at az bs bh bd bb by
7
+ be bz bj bm bt bo ba bw bv br io bn bg bf bi kh cm ca cv ky
8
+ cf td cl cn cx cc co km cg cd ck cr ci hr cu cy cz dk dj dm
9
+ do ec eg sv gq er ee et fk fo fj fi fr gf pf tf ga gm ge de
10
+ gh gi gr gl gd gp gu gt gn gw gy ht hm va hn hk hu is in id
11
+ ir iq ie il it jm jp jo kz ke ki kp kr kw kg la lv lb ls lr
12
+ ly li lt lu mo mk mg mw my mv ml mt mh mq mr mu yt mx fm md
13
+ mc mn ms ma mz mm na nr np nl an nc nz ni ne ng nu nf mp no
14
+ om pk pw ps pa pg py pe ph pn pl pt pr qa re ro ru rw sh kn
15
+ lc pm vc ws sm st sa sn cs sc sl sg sk si sb so za gs sp lk
16
+ sd sr sj sz se ch sy tw tj tz th tl tg tk to tt tn tr tm tc
17
+ tv ug ua ae uk us um uy uz vu ve vn vg vi wf eh ye zm zw
18
+ ].freeze
19
+
20
+ def valid?(query:)
21
+ return true if query.nil?
22
+ valid = query.key?(:countryTotal) ? valid_country?(key: :countryTotal, query: query) : true
23
+ valid = query.key?(:countryTimeline) ? valid_country?(key: :countryTimeline, query: query) : valid
24
+ valid
25
+ end
26
+
27
+ private
28
+
29
+ def valid_country?(key:, query:)
30
+ query[key].nil? ? false : COUNTRIES.include?(query[key].downcase)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Covid19
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: covid19-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vic Carrasco
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 12.3.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 12.3.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: arssene
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Write a longer description or delete this line.
84
+ email:
85
+ - 1703579+viccarrasco@users.noreply.github.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CHANGE_LOG.md
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - covid19.gemspec
103
+ - lib/covid19.rb
104
+ - lib/covid19/lib/base_resource.rb
105
+ - lib/covid19/lib/global.rb
106
+ - lib/covid19/lib/news.rb
107
+ - lib/covid19/lib/presenters/presenters.rb
108
+ - lib/covid19/lib/repositories/news/news_repository.rb
109
+ - lib/covid19/lib/repositories/virus_tracker/base_repository.rb
110
+ - lib/covid19/lib/repositories/virus_tracker/statistics_repository.rb
111
+ - lib/covid19/lib/repositories/virus_tracker/timeline_repository.rb
112
+ - lib/covid19/lib/timeline.rb
113
+ - lib/covid19/lib/validators/query_validator.rb
114
+ - lib/covid19/version.rb
115
+ homepage: https://github.com/viccarrasco/covid-19
116
+ licenses:
117
+ - MIT
118
+ metadata:
119
+ allowed_push_host: https://rubygems.org
120
+ homepage_uri: https://github.com/viccarrasco/covid-19
121
+ source_code_uri: https://github.com/viccarrasco/covid-19
122
+ changelog_uri: https://github.com/viccarrasco/covid-19/blob/master/CHANGE_LOG.md
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.3.0
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 3.0.0
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Fight Covid-19
142
+ test_files: []