kovid 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +26 -0
- data/exe/kovid +4 -0
- data/kovid.gemspec +6 -0
- data/lib/kovid.rb +4 -2
- data/lib/kovid/cli.rb +23 -0
- data/lib/kovid/nineteen.rb +21 -0
- data/lib/kovid/request.rb +30 -0
- data/lib/kovid/tablelize.rb +39 -0
- data/lib/kovid/version.rb +3 -1
- metadata +79 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 036bbe0bb6050bb3ecd8b931bbfef995160be952208e1ac2210ebf9d9a56a443
|
4
|
+
data.tar.gz: 90e69a301215c6d24f540f9cd7cdbdb42ea3d11bcb15d711973ec9e465e4a43d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ddbb4ebc9211a7e29234c9bd87078f7131975418015962e46099f5c3c431c6f3742d170afcfbe629a73760d609443c37850e4f54b3a5a6b8f130dde282fc90c
|
7
|
+
data.tar.gz: 4d5e1830d51eb65b577c70e8d45a124745d6d10c56077fa0e7c793086f798a792c9766ba46bf2ee487c79c4fe6a7bb2710ff2324d7515a8137a23dbcad641b18
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,11 +2,30 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
kovid (0.1.0)
|
5
|
+
httparty
|
6
|
+
terminal-table
|
7
|
+
thor
|
8
|
+
typhoeus
|
5
9
|
|
6
10
|
GEM
|
7
11
|
remote: https://rubygems.org/
|
8
12
|
specs:
|
13
|
+
coderay (1.1.2)
|
9
14
|
diff-lcs (1.3)
|
15
|
+
ethon (0.12.0)
|
16
|
+
ffi (>= 1.3.0)
|
17
|
+
ffi (1.12.2)
|
18
|
+
httparty (0.18.0)
|
19
|
+
mime-types (~> 3.0)
|
20
|
+
multi_xml (>= 0.5.2)
|
21
|
+
method_source (0.9.2)
|
22
|
+
mime-types (3.3.1)
|
23
|
+
mime-types-data (~> 3.2015)
|
24
|
+
mime-types-data (3.2019.1009)
|
25
|
+
multi_xml (0.6.0)
|
26
|
+
pry (0.12.2)
|
27
|
+
coderay (~> 1.1.0)
|
28
|
+
method_source (~> 0.9.0)
|
10
29
|
rake (12.3.3)
|
11
30
|
rspec (3.9.0)
|
12
31
|
rspec-core (~> 3.9.0)
|
@@ -21,12 +40,19 @@ GEM
|
|
21
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
41
|
rspec-support (~> 3.9.0)
|
23
42
|
rspec-support (3.9.2)
|
43
|
+
terminal-table (1.8.0)
|
44
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
45
|
+
thor (1.0.1)
|
46
|
+
typhoeus (1.3.1)
|
47
|
+
ethon (>= 0.9.0)
|
48
|
+
unicode-display_width (1.7.0)
|
24
49
|
|
25
50
|
PLATFORMS
|
26
51
|
ruby
|
27
52
|
|
28
53
|
DEPENDENCIES
|
29
54
|
kovid!
|
55
|
+
pry
|
30
56
|
rake (~> 12.0)
|
31
57
|
rspec (~> 3.0)
|
32
58
|
|
data/exe/kovid
ADDED
data/kovid.gemspec
CHANGED
@@ -26,4 +26,10 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.bindir = "exe"
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "thor"
|
31
|
+
spec.add_dependency "terminal-table"
|
32
|
+
spec.add_dependency "httparty"
|
33
|
+
spec.add_dependency "typhoeus"
|
34
|
+
spec.add_development_dependency "pry"
|
29
35
|
end
|
data/lib/kovid.rb
CHANGED
data/lib/kovid/cli.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'kovid'
|
5
|
+
|
6
|
+
module Kovid
|
7
|
+
class CLI < Thor
|
8
|
+
desc 'whatis', 'Defines COVID-19'
|
9
|
+
def whatis
|
10
|
+
Kovid::Nineteen.whatis
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'country', 'Returns data on country'
|
14
|
+
method_option :full, aliases: '-f'
|
15
|
+
def country(name)
|
16
|
+
if options[:full]
|
17
|
+
Kovid::Nineteen.country_full(name)
|
18
|
+
else
|
19
|
+
Kovid::Nineteen.country(name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'request'
|
4
|
+
|
5
|
+
module Kovid
|
6
|
+
class Nineteen
|
7
|
+
class << self
|
8
|
+
def whatis
|
9
|
+
puts 'Coronavirus disease (COVID-19) is an infectious disease caused by a new virus.'
|
10
|
+
end
|
11
|
+
|
12
|
+
def country(name)
|
13
|
+
puts Kovid::Request.by_country(name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def country_full(name)
|
17
|
+
puts Kovid::Request.by_country_full(name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'typhoeus'
|
4
|
+
require 'json'
|
5
|
+
require_relative 'tablelize'
|
6
|
+
|
7
|
+
module Kovid
|
8
|
+
class Request
|
9
|
+
BASE_URL = 'https://corona.lmao.ninja'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
require 'pry'
|
13
|
+
def by_country(name)
|
14
|
+
path = "/countries/#{name}"
|
15
|
+
fetch_url = BASE_URL + path
|
16
|
+
|
17
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
18
|
+
Kovid::Tablelize.country_table(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
def by_country_full(name)
|
22
|
+
path = "/countries/#{name}"
|
23
|
+
fetch_url = BASE_URL + path
|
24
|
+
|
25
|
+
response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
|
26
|
+
Kovid::Tablelize.full_country_table(response)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'terminal-table'
|
4
|
+
|
5
|
+
module Kovid
|
6
|
+
class Tablelize
|
7
|
+
def self.country_table(data)
|
8
|
+
rows = []
|
9
|
+
rows << [data['cases'], data['deaths'], data['recovered']]
|
10
|
+
puts Terminal::Table.new(title: data['country'], headings: %w[Cases Deaths Recovered], rows: rows)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.full_country_table(data)
|
14
|
+
headings = [
|
15
|
+
'Cases',
|
16
|
+
'Deaths',
|
17
|
+
'Recovered',
|
18
|
+
'Cases Today',
|
19
|
+
'Deaths Today',
|
20
|
+
'Critical',
|
21
|
+
'Cases/Million'
|
22
|
+
]
|
23
|
+
|
24
|
+
rows = []
|
25
|
+
rows << [
|
26
|
+
data['cases'],
|
27
|
+
data['deaths'],
|
28
|
+
data['recovered'],
|
29
|
+
data['todayCases'],
|
30
|
+
data['todayDeaths'],
|
31
|
+
data['critical'],
|
32
|
+
data['casesPerOneMillion']
|
33
|
+
]
|
34
|
+
puts Terminal::Table.new(title: data['country'],
|
35
|
+
headings: headings,
|
36
|
+
rows: rows)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/kovid/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Hayford
|
@@ -9,11 +9,82 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-03-20 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: typhoeus
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
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: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
13
83
|
description: Scraper to get Coronavirus data.
|
14
84
|
email:
|
15
85
|
- siawmensah@gmail.com
|
16
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- kovid
|
17
88
|
extensions: []
|
18
89
|
extra_rdoc_files: []
|
19
90
|
files:
|
@@ -28,8 +99,13 @@ files:
|
|
28
99
|
- Rakefile
|
29
100
|
- bin/console
|
30
101
|
- bin/setup
|
102
|
+
- exe/kovid
|
31
103
|
- kovid.gemspec
|
32
104
|
- lib/kovid.rb
|
105
|
+
- lib/kovid/cli.rb
|
106
|
+
- lib/kovid/nineteen.rb
|
107
|
+
- lib/kovid/request.rb
|
108
|
+
- lib/kovid/tablelize.rb
|
33
109
|
- lib/kovid/version.rb
|
34
110
|
homepage: https://github.com/siaw23/kovid
|
35
111
|
licenses:
|