minato-utils 0.1.1 → 0.2.1
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 +2 -1
- data/.gitlab-ci.yml +4 -39
- data/Gemfile.lock +7 -7
- data/README.md +5 -5
- data/lib/minato/utils/client.rb +2 -1
- data/lib/minato/utils/response_handler.rb +7 -3
- data/lib/minato/utils/version.rb +1 -1
- data/{minato-utils.gemspec → minato-ruby-utils.gemspec} +10 -10
- data/release-notes.md +8 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bc10d814c0e9102aad2fc41b3f36ee3bf42e8e62221e855967c1e7839a98e80
|
4
|
+
data.tar.gz: 0b1c1fbf289d59ff9db246f838c2ad46c625cd5990429af7e06ce4926aaf4db3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 007ea958aecc24ddcf66c158100368763001981a5aa19e529f646e62f020fe17a12778e0587e3422d3690719868d23dca0ba91556ec31965c9b48ab75f9cbcec
|
7
|
+
data.tar.gz: 55b48408b7cfa0d53ee20679edc8050f63bcefe13428e092e772b33f100ae890832e07de1dbca7b68761434b75eda50d23eb2a08e2cc145ce46663d32c2746a7
|
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
*.gem
|
2
|
+
*.code-workspace
|
data/.gitlab-ci.yml
CHANGED
@@ -1,40 +1,5 @@
|
|
1
|
-
|
1
|
+
include:
|
2
|
+
- project: 'ferreri/minato-projects/minato-ci'
|
3
|
+
ref: main
|
4
|
+
file: '/gem/.gitlab-ci.yml'
|
2
5
|
|
3
|
-
stages:
|
4
|
-
- test
|
5
|
-
|
6
|
-
variables:
|
7
|
-
IMAGE_REF: "$IMAGE:$CI_COMMIT_SHORT_SHA"
|
8
|
-
KEY_FILE: "gcloud-service-key.json"
|
9
|
-
|
10
|
-
.cmd_google_key: &cmd_google_key |-
|
11
|
-
echo $GCLOUD_SERVICE_KEY | base64 -d > $KEY_FILE
|
12
|
-
|
13
|
-
.cmd_auth_docker: &cmd_auth_docker |-
|
14
|
-
cat $KEY_FILE | docker login -u _json_key --password-stdin https://gcr.io
|
15
|
-
|
16
|
-
.auth_docker: &auth_docker
|
17
|
-
before_script:
|
18
|
-
- *cmd_google_key
|
19
|
-
- *cmd_auth_docker
|
20
|
-
|
21
|
-
rspec:
|
22
|
-
<<: *auth_docker
|
23
|
-
stage: test
|
24
|
-
image: ruby:2.7.3
|
25
|
-
only:
|
26
|
-
- merge_requests
|
27
|
-
- dev
|
28
|
-
- main
|
29
|
-
cache:
|
30
|
-
paths:
|
31
|
-
- vendor/ruby
|
32
|
-
variables:
|
33
|
-
RAILS_ENV: test
|
34
|
-
BASE_PATH: /minato-ruby-utils
|
35
|
-
before_script:
|
36
|
-
- gem install bundler --no-document
|
37
|
-
- bundle config set --local path 'vendor/ruby'
|
38
|
-
- bundle install -j $(nproc)
|
39
|
-
script:
|
40
|
-
- bundle exec rspec
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
minato-utils (0.
|
4
|
+
minato-utils (0.2.0)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
httparty (~> 0.18)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.1.4.
|
11
|
+
activesupport (6.1.4.4)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
@@ -33,10 +33,10 @@ GEM
|
|
33
33
|
mime-types (3.4.1)
|
34
34
|
mime-types-data (~> 3.2015)
|
35
35
|
mime-types-data (3.2021.1115)
|
36
|
-
minitest (5.
|
36
|
+
minitest (5.15.0)
|
37
37
|
multi_xml (0.6.0)
|
38
38
|
parallel (1.21.0)
|
39
|
-
parser (3.0.2
|
39
|
+
parser (3.0.3.2)
|
40
40
|
ast (~> 2.4.1)
|
41
41
|
pry (0.14.1)
|
42
42
|
coderay (~> 1.1)
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
rack (2.2.3)
|
46
46
|
rainbow (3.0.0)
|
47
47
|
rake (10.5.0)
|
48
|
-
regexp_parser (2.
|
48
|
+
regexp_parser (2.2.0)
|
49
49
|
rexml (3.2.5)
|
50
50
|
rspec (3.10.0)
|
51
51
|
rspec-core (~> 3.10.0)
|
@@ -69,7 +69,7 @@ GEM
|
|
69
69
|
rubocop-ast (>= 1.12.0, < 2.0)
|
70
70
|
ruby-progressbar (~> 1.7)
|
71
71
|
unicode-display_width (>= 1.4.0, < 3.0)
|
72
|
-
rubocop-ast (1.
|
72
|
+
rubocop-ast (1.15.0)
|
73
73
|
parser (>= 3.0.1.1)
|
74
74
|
rubocop-rails (2.12.4)
|
75
75
|
activesupport (>= 4.2.0)
|
@@ -106,4 +106,4 @@ DEPENDENCIES
|
|
106
106
|
webmock (~> 3.14)
|
107
107
|
|
108
108
|
BUNDLED WITH
|
109
|
-
2.2.
|
109
|
+
2.2.33
|
data/README.md
CHANGED
@@ -46,16 +46,16 @@ Para usar o cliente você vai precisar iniciar ele com `base_uri` e
|
|
46
46
|
client = Minato::Utils::Client.new(base_uri: 'http://www.test.com', default_options: headers: { 'Content-type' => 'application/json' })
|
47
47
|
```
|
48
48
|
|
49
|
-
Você pode usar todos os métodos HTTP para fazer requisições.
|
50
|
-
|
51
|
-
|
49
|
+
Você pode usar todos os métodos HTTP para fazer requisições. Além disso, é
|
50
|
+
possível adicionar mais opções ou sobrescrever o padrão usando o método
|
51
|
+
`params`:
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
client.get('/path', headers: { 'X-Session-Token' => '123' })
|
55
55
|
```
|
56
56
|
|
57
|
-
As falhas de solicitação
|
58
|
-
As possíveis exceções são:
|
57
|
+
As falhas de solicitação produzirão uma exceção do tipo
|
58
|
+
`Minato::Utils::<Exception>`. As possíveis exceções são:
|
59
59
|
|
60
60
|
```ruby
|
61
61
|
Minato::Utils::BadRequest
|
data/lib/minato/utils/client.rb
CHANGED
@@ -37,6 +37,7 @@ module Minato
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def request(method, path, options)
|
40
|
+
return_headers = options.delete(:return_headers)
|
40
41
|
request_options = @default_options.deep_merge(options)
|
41
42
|
url = Minato::Utils::Helpers.join_url(@base_uri, path)
|
42
43
|
|
@@ -44,7 +45,7 @@ module Minato
|
|
44
45
|
response = self.class.send(method, url, request_options)
|
45
46
|
|
46
47
|
Minato::Utils.logger.log_response(method, @base_uri, path, request_options, response)
|
47
|
-
Minato::Utils::ResponseHandler.handle(response)
|
48
|
+
Minato::Utils::ResponseHandler.handle(response, return_headers)
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -7,15 +7,19 @@ module Minato
|
|
7
7
|
module Utils
|
8
8
|
class ResponseHandler
|
9
9
|
class << self
|
10
|
-
def handle(response)
|
10
|
+
def handle(response, return_headers)
|
11
11
|
raise_exception(response) if response_error?(response)
|
12
12
|
|
13
|
-
|
13
|
+
if return_headers
|
14
|
+
{ body: Minato::Utils::Helpers.parse_json(response.body), header: response.header }
|
15
|
+
else
|
16
|
+
Minato::Utils::Helpers.parse_json(response.body)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
private
|
17
21
|
|
18
|
-
SUCCESSFUL_RESPONSE_CODE = [200, 201, 204].freeze
|
22
|
+
SUCCESSFUL_RESPONSE_CODE = [200, 201, 204, 302].freeze
|
19
23
|
|
20
24
|
EXCEPTION_HANDLERS_MAP = {
|
21
25
|
400 => 'bad_request',
|
data/lib/minato/utils/version.rb
CHANGED
@@ -4,14 +4,14 @@ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
|
4
4
|
require 'minato/utils/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.summary
|
14
|
-
spec.
|
7
|
+
spec.authors = ['Ferreri']
|
8
|
+
spec.description = 'Library to share common functionality across services'
|
9
|
+
spec.email = ['contato@ferreri.co']
|
10
|
+
spec.homepage = 'https://gitlab.com/ferreri/minato-projects/minato-ruby-utils'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
spec.name = 'minato-utils'
|
13
|
+
spec.summary = 'Minato Ruby Utils'
|
14
|
+
spec.version = Minato::Utils::VERSION
|
15
15
|
|
16
16
|
spec.required_ruby_version = '>= 2.7'
|
17
17
|
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
22
|
end
|
23
|
-
spec.bindir
|
24
|
-
spec.executables
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ['lib']
|
26
26
|
|
27
27
|
spec.add_dependency 'activesupport', '~> 6.0'
|
data/release-notes.md
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minato-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferreri
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '3.14'
|
181
|
-
description: common
|
181
|
+
description: Library to share common functionality across services
|
182
182
|
email:
|
183
183
|
- contato@ferreri.co
|
184
184
|
executables: []
|
@@ -204,13 +204,14 @@ files:
|
|
204
204
|
- lib/minato/utils/logger.rb
|
205
205
|
- lib/minato/utils/response_handler.rb
|
206
206
|
- lib/minato/utils/version.rb
|
207
|
-
- minato-utils.gemspec
|
207
|
+
- minato-ruby-utils.gemspec
|
208
|
+
- release-notes.md
|
208
209
|
homepage: https://gitlab.com/ferreri/minato-projects/minato-ruby-utils
|
209
210
|
licenses:
|
210
211
|
- MIT
|
211
212
|
metadata:
|
212
213
|
rubygems_mfa_required: 'true'
|
213
|
-
post_install_message:
|
214
|
+
post_install_message:
|
214
215
|
rdoc_options: []
|
215
216
|
require_paths:
|
216
217
|
- lib
|
@@ -226,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
227
|
version: '0'
|
227
228
|
requirements: []
|
228
229
|
rubygems_version: 3.1.6
|
229
|
-
signing_key:
|
230
|
+
signing_key:
|
230
231
|
specification_version: 4
|
231
232
|
summary: Minato Ruby Utils
|
232
233
|
test_files: []
|