covid19-cli 0.1.0 → 0.2.0
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -1
- data/CODE_OF_CONDUCT.md +3 -3
- data/Gemfile +2 -3
- data/Gemfile.lock +45 -0
- data/README.md +3 -4
- data/Rakefile +7 -1
- data/covid19-cli.gemspec +14 -6
- data/exe/covid19-cli +5 -0
- data/lib/covid19/client.rb +30 -0
- data/lib/covid19/services/covid19_data.rb +45 -0
- data/lib/covid19/version.rb +3 -0
- data/spec/lib/covid19/services/covid19_data_spec.rb +37 -0
- data/spec/lib/covid19/version_spec.rb +5 -0
- data/spec/spec_helper.rb +14 -0
- metadata +84 -8
- data/lib/covid19/cli.rb +0 -8
- data/lib/covid19/cli/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0cb53d0266bd5f000d8c9aa104aaa9eaf7f74783cd1b477bd2cf09c0109c7be
|
4
|
+
data.tar.gz: ea4c7ffb5b8103552ddebf40e30e48afd70a9f11c1a0e65d27a0d03aef6245e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9b7eb91f099b54f047100e36a825a75d58db06c78d4558f81e24c333104c3c145425d9cb8a7cbe2a6acb4716f252ef55fe026bb4051c1ce4a1947d6c81528c7
|
7
|
+
data.tar.gz: 7891c7a465fe916d41d38eca66d910756338348431e61592d435a2b679a264de691aa2913000f20e2fb697597777abc25ac4c4450c72464ee3ed1662bffd620e
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -68,7 +68,7 @@ members of the project's leadership.
|
|
68
68
|
## Attribution
|
69
69
|
|
70
70
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
72
|
|
73
|
-
[homepage]:
|
74
|
-
[version]:
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
covid19-cli (0.2.0)
|
5
|
+
httparty
|
6
|
+
thor
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
httparty (0.18.1)
|
13
|
+
mime-types (~> 3.0)
|
14
|
+
multi_xml (>= 0.5.2)
|
15
|
+
mime-types (3.3.1)
|
16
|
+
mime-types-data (~> 3.2015)
|
17
|
+
mime-types-data (3.2020.0512)
|
18
|
+
multi_xml (0.6.0)
|
19
|
+
rake (10.5.0)
|
20
|
+
rspec (3.9.0)
|
21
|
+
rspec-core (~> 3.9.0)
|
22
|
+
rspec-expectations (~> 3.9.0)
|
23
|
+
rspec-mocks (~> 3.9.0)
|
24
|
+
rspec-core (3.9.2)
|
25
|
+
rspec-support (~> 3.9.3)
|
26
|
+
rspec-expectations (3.9.2)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.9.0)
|
29
|
+
rspec-mocks (3.9.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.9.0)
|
32
|
+
rspec-support (3.9.3)
|
33
|
+
thor (1.0.1)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 1.7)
|
40
|
+
covid19-cli!
|
41
|
+
rake (~> 10.0)
|
42
|
+
rspec (~> 3.0)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.17.3
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ gem 'covid19-cli'
|
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
17
|
-
$ bundle
|
17
|
+
$ bundle
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
@@ -32,8 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/covid19-cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [
|
36
|
-
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/covid19-cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
37
36
|
|
38
37
|
## License
|
39
38
|
|
@@ -41,4 +40,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
41
40
|
|
42
41
|
## Code of Conduct
|
43
42
|
|
44
|
-
Everyone interacting in the Covid19::Cli project
|
43
|
+
Everyone interacting in the Covid19::Cli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/covid19-cli/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/covid19-cli.gemspec
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require_relative "lib/covid19/version"
|
2
5
|
|
3
6
|
Gem::Specification.new do |spec|
|
4
7
|
spec.name = "covid19-cli"
|
5
|
-
spec.version = Covid19::
|
8
|
+
spec.version = Covid19::VERSION
|
6
9
|
spec.authors = ["Alexandre Carlos Martins"]
|
7
10
|
spec.email = ["tecnooxossi@gmail.com"]
|
8
11
|
|
@@ -10,10 +13,15 @@ Gem::Specification.new do |spec|
|
|
10
13
|
spec.description = "Get COVID19 stats of worldwide"
|
11
14
|
spec.homepage = "https://github.com/TecnoSigma/covid19-cli"
|
12
15
|
spec.license = "MIT"
|
13
|
-
spec.files =
|
14
|
-
|
15
|
-
end
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
|
16
18
|
spec.bindir = "exe"
|
17
|
-
spec.executables =
|
19
|
+
spec.executables = ["covid19-cli"]
|
18
20
|
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "thor"
|
23
|
+
spec.add_dependency "httparty"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
19
27
|
end
|
data/exe/covid19-cli
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'services/covid19_data'
|
3
|
+
|
4
|
+
module Covid19
|
5
|
+
class Client < Thor
|
6
|
+
def self.exit_on_failure?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'all_continents', 'List all continents data'
|
11
|
+
def all_continents
|
12
|
+
puts Covid19::Services::Covid19Data.all_continents
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'all countries', 'List all countries data'
|
16
|
+
def all_countries
|
17
|
+
puts Covid19::Services::Covid19Data.all_countries
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'continent CONTINENT_NAME', 'List continent data'
|
21
|
+
def continent(continent_name)
|
22
|
+
puts Covid19::Services::Covid19Data.continent(continent_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'country COUNTRY_NAME', 'List country data'
|
26
|
+
def country(country_name)
|
27
|
+
puts Covid19::Services::Covid19Data.country(country_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Covid19
|
5
|
+
module Services
|
6
|
+
class Covid19Data
|
7
|
+
URI = 'https://corona.lmao.ninja/v3/covid-19'
|
8
|
+
RESOURCES = { continents: 'continents',
|
9
|
+
countries: 'countries' }
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def all_continents
|
13
|
+
data(resource: RESOURCES[:continents])
|
14
|
+
end
|
15
|
+
|
16
|
+
def all_countries
|
17
|
+
data(resource: RESOURCES[:countries])
|
18
|
+
end
|
19
|
+
|
20
|
+
def continent(continent_name)
|
21
|
+
data(resource: RESOURCES[:continents], query: titleize(continent_name))
|
22
|
+
end
|
23
|
+
|
24
|
+
def country(country_name)
|
25
|
+
data(resource: RESOURCES[:countries], query: titleize(country_name))
|
26
|
+
end
|
27
|
+
|
28
|
+
def data(resource:, query: nil)
|
29
|
+
response = HTTParty.get("#{URI}/#{resource}/#{query}")
|
30
|
+
|
31
|
+
JSON.parse(response.body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def titleize(string)
|
35
|
+
string
|
36
|
+
.split('_')
|
37
|
+
.map { |str| str.capitalize }
|
38
|
+
.join('%20')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private_class_method :data, :titleize
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../../../../lib/covid19/services/covid19_data'
|
2
|
+
|
3
|
+
RSpec.describe 'Covid19::Services::Covid19Data' do
|
4
|
+
describe '.all_continents' do
|
5
|
+
it 'returns all continents in JSON format' do
|
6
|
+
result = Covid19::Services::Covid19Data.all_continents
|
7
|
+
|
8
|
+
expect(result).not_to be_empty
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.all_countries' do
|
13
|
+
it 'returns all countries in JSON format' do
|
14
|
+
result = Covid19::Services::Covid19Data.all_countries
|
15
|
+
|
16
|
+
expect(result).not_to be_empty
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.continent' do
|
21
|
+
it 'returns continent data in JSON format' do
|
22
|
+
continent_name = 'South_America'
|
23
|
+
result = Covid19::Services::Covid19Data.continent(continent_name)
|
24
|
+
|
25
|
+
expect(result).not_to be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.country' do
|
30
|
+
it 'returns country data in JSON format' do
|
31
|
+
country_name = 'Brazil'
|
32
|
+
result = Covid19::Services::Covid19Data.country(country_name)
|
33
|
+
|
34
|
+
expect(result).not_to be_empty
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "covid19/client"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,19 +1,90 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covid19-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Carlos Martins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
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: httparty
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
13
83
|
description: Get COVID19 stats of worldwide
|
14
84
|
email:
|
15
85
|
- tecnooxossi@gmail.com
|
16
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- covid19-cli
|
17
88
|
extensions: []
|
18
89
|
extra_rdoc_files: []
|
19
90
|
files:
|
@@ -22,6 +93,7 @@ files:
|
|
22
93
|
- ".travis.yml"
|
23
94
|
- CODE_OF_CONDUCT.md
|
24
95
|
- Gemfile
|
96
|
+
- Gemfile.lock
|
25
97
|
- LICENSE
|
26
98
|
- LICENSE.txt
|
27
99
|
- README.md
|
@@ -29,8 +101,13 @@ files:
|
|
29
101
|
- bin/console
|
30
102
|
- bin/setup
|
31
103
|
- covid19-cli.gemspec
|
32
|
-
-
|
33
|
-
- lib/covid19/
|
104
|
+
- exe/covid19-cli
|
105
|
+
- lib/covid19/client.rb
|
106
|
+
- lib/covid19/services/covid19_data.rb
|
107
|
+
- lib/covid19/version.rb
|
108
|
+
- spec/lib/covid19/services/covid19_data_spec.rb
|
109
|
+
- spec/lib/covid19/version_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
34
111
|
homepage: https://github.com/TecnoSigma/covid19-cli
|
35
112
|
licenses:
|
36
113
|
- MIT
|
@@ -50,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
127
|
- !ruby/object:Gem::Version
|
51
128
|
version: '0'
|
52
129
|
requirements: []
|
53
|
-
|
54
|
-
rubygems_version: 2.7.6
|
130
|
+
rubygems_version: 3.0.6
|
55
131
|
signing_key:
|
56
132
|
specification_version: 4
|
57
133
|
summary: COVID-19 Stats
|
data/lib/covid19/cli.rb
DELETED