covid19-cli 0.1.0 → 0.2.0

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: b04eb4bc406efe5e90e50f6a78bd2c1c87678413a9f8209da91a8baa8ac93bba
4
- data.tar.gz: 9a56f95a9fefcf57c601760423ea27debc4eced89abb4c9296d144c9d3babd75
3
+ metadata.gz: f0cb53d0266bd5f000d8c9aa104aaa9eaf7f74783cd1b477bd2cf09c0109c7be
4
+ data.tar.gz: ea4c7ffb5b8103552ddebf40e30e48afd70a9f11c1a0e65d27a0d03aef6245e5
5
5
  SHA512:
6
- metadata.gz: 19162b086a55c5a3e14419a4ee64566157d2f0dbbb886cb7ea58aede18d779055bcca42aef992bbdba72b3385976464bcd41d87efa98247eeee46bdc295d0524
7
- data.tar.gz: 94e8115ea507e2297c5e259f81642d2649ec2000a990517d9a64ff1cf686b6879553cb093a98da2449319e4056f3064cdf2f3e3450c3ba183d41948a7885d251
6
+ metadata.gz: a9b7eb91f099b54f047100e36a825a75d58db06c78d4558f81e24c333104c3c145425d9cb8a7cbe2a6acb4716f252ef55fe026bb4051c1ce4a1947d6c81528c7
7
+ data.tar.gz: 7891c7a465fe916d41d38eca66d910756338348431e61592d435a2b679a264de691aa2913000f20e2fb697597777abc25ac4c4450c72464ee3ed1662bffd620e
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /vendor/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
@@ -1,6 +1,7 @@
1
1
  ---
2
+ sudo: false
2
3
  language: ruby
3
4
  cache: bundler
4
5
  rvm:
5
6
  - 2.5.1
6
- before_install: gem install bundler -v 2.1.4
7
+ before_install: gem install bundler -v 1.17.3
@@ -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 [https://contributor-covenant.org/version/1/4][version]
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
72
 
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
3
5
  # Specify your gem's dependencies in covid19-cli.gemspec
4
6
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
@@ -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 install
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 [code of conduct](https://github.com/[USERNAME]/covid19-cli/blob/master/CODE_OF_CONDUCT.md).
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'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).
43
+ Everyone interacting in the Covid19::Cli projects 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
@@ -3,4 +3,10 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
7
+
8
+ namespace :gem do
9
+ task :build do
10
+ system "rake build && rake install"
11
+ end
12
+ end
@@ -1,8 +1,11 @@
1
- require_relative 'lib/covid19/cli/version'
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::Cli::VERSION
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 = Dir.chdir(File.expand_path('..', __FILE__)) do
14
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
- end
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+
16
18
  spec.bindir = "exe"
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'covid19/client'
4
+
5
+ Covid19::Client.start
@@ -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,3 @@
1
+ module Covid19
2
+ VERSION = "0.2.0"
3
+ 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
@@ -0,0 +1,5 @@
1
+ RSpec.describe Covid19::Client do
2
+ it "has version latest number" do
3
+ expect(Covid19::VERSION).to eq('0.2.0')
4
+ end
5
+ end
@@ -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.1.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-07 00:00:00.000000000 Z
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
- - lib/covid19/cli.rb
33
- - lib/covid19/cli/version.rb
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
- rubyforge_project:
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
@@ -1,8 +0,0 @@
1
- require "covid19/cli/version"
2
-
3
- module Covid19
4
- module Cli
5
- class Error < StandardError; end
6
- # Your code goes here...
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- module Covid19
2
- module Cli
3
- VERSION = "0.1.0"
4
- end
5
- end