json_api_toolbox 2.0.0 → 2.1.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: fc9706da38e740273930904f1f8c2921fa7172ac47f73a1f4130683c5774c624
4
- data.tar.gz: dd5b01dfad5c434d8b569769ad6149da78e317aaa8bb3f58102e1eb53b8f4630
3
+ metadata.gz: 57d15d5fd3e2fd4747a2606e83d3f38f8a1991dac1ce62bfa9dd9ccc45e27f94
4
+ data.tar.gz: ecbb101680a6767f7d83238a6e0500ef67ac4addbebc6500c9881172678b7d1e
5
5
  SHA512:
6
- metadata.gz: 91111bdba8cbe7562eb92f1b73172fbefbf062c501e298546ff6a795573e585ee3e53dfcafeee86a78631735f8b5f8935d5f9f11e499f3a7f8e64de60425b399
7
- data.tar.gz: 11a64750e2c53a541e9df20bce0032d122352bfacbf976500ebb22c1c8a2f949a9f93ee50570bb7dcf99dc905382b348c5e6089f9d5e3ac13fdb26c141499873
6
+ metadata.gz: 76bee9fcd248fd05746574fbcc763bfe83150c4822574ea3238c068613c712a09eb11c8d46426e2b8f4f43a5475642aedc6a2f2ea893108a954a4bddf1b63f14
7
+ data.tar.gz: 365556a551fb49c8050a78c106df2d7c5e1d02eee6e9c289f8ea0abe3f16c150902505a67be7ebfe86a3d7d942b7dc7922e7e8418d3c63fcc3757ac5055fdf18
data/.version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.1.0] - 2022-11-09
10
+ ### Changed
11
+ - Permite seja via parametro, seja via ENV alterar o timeout do RestClient
12
+
13
+ ## [2.0.1] - 2021-08-13
14
+ ### Fixed
15
+ - Fixed a constant loading problem on rails
16
+
9
17
  ## [2.0.0] - 2021-06-23
10
18
  ### Added
11
19
  - New README file describing the gem and it's uses
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.6-alpine
1
+ FROM ruby:3.0.0-alpine
2
2
 
3
3
  RUN apk update \
4
4
  && apk upgrade \
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_api_toolbox (2.0.0)
4
+ json_api_toolbox (2.1.0)
5
5
  activerecord (>= 5.1.0)
6
6
  activesupport (>= 5.1.0)
7
7
  json-api-vanilla
@@ -82,15 +82,15 @@ GEM
82
82
  diff-lcs (1.4.4)
83
83
  domain_name (0.5.20190701)
84
84
  unf (>= 0.0.5, < 1.0.0)
85
- erubi (1.10.0)
86
- globalid (0.4.2)
87
- activesupport (>= 4.2.0)
85
+ erubi (1.11.0)
86
+ globalid (1.0.0)
87
+ activesupport (>= 5.0)
88
88
  http-accept (1.7.0)
89
- http-cookie (1.0.4)
89
+ http-cookie (1.0.5)
90
90
  domain_name (~> 0.5)
91
91
  i18n (1.8.10)
92
92
  concurrent-ruby (~> 1.0)
93
- json-api-vanilla (1.0.2)
93
+ json-api-vanilla (1.0.4)
94
94
  jsonapi-renderer (0.2.2)
95
95
  jsonapi-serializable (0.3.1)
96
96
  jsonapi-renderer (~> 0.2.0)
@@ -99,7 +99,7 @@ GEM
99
99
  logstash-event (>= 1.2.02)
100
100
  logstash-logger (>= 0.26.1)
101
101
  rails (>= 5.0)
102
- lograge (0.11.2)
102
+ lograge (0.12.0)
103
103
  actionpack (>= 4)
104
104
  activesupport (>= 4)
105
105
  railties (>= 4)
@@ -107,24 +107,26 @@ GEM
107
107
  logstash-event (1.2.02)
108
108
  logstash-logger (0.26.1)
109
109
  logstash-event (~> 1.2)
110
- loofah (2.10.0)
110
+ loofah (2.19.0)
111
111
  crass (~> 1.0.2)
112
112
  nokogiri (>= 1.5.9)
113
113
  mail (2.7.1)
114
114
  mini_mime (>= 0.1.1)
115
- marcel (1.0.1)
115
+ marcel (1.0.2)
116
116
  method_source (1.0.0)
117
- mime-types (3.3.1)
117
+ mime-types (3.4.1)
118
118
  mime-types-data (~> 3.2015)
119
- mime-types-data (3.2021.0704)
120
- mini_mime (1.1.0)
119
+ mime-types-data (3.2022.0105)
120
+ mini_mime (1.1.2)
121
121
  minitest (5.14.4)
122
122
  netrc (0.11.0)
123
- nio4r (2.5.7)
124
- nokogiri (1.11.7-x86_64-linux)
123
+ nio4r (2.5.8)
124
+ nokogiri (1.13.9-x86_64-darwin)
125
+ racc (~> 1.4)
126
+ nokogiri (1.13.9-x86_64-linux)
125
127
  racc (~> 1.4)
126
128
  parallel (1.20.1)
127
- parser (3.0.1.1)
129
+ parser (3.0.2.0)
128
130
  ast (~> 2.4.1)
129
131
  pry (0.13.1)
130
132
  coderay (~> 1.1)
@@ -132,10 +134,10 @@ GEM
132
134
  pry-byebug (3.9.0)
133
135
  byebug (~> 11.0)
134
136
  pry (~> 0.13.0)
135
- racc (1.5.2)
136
- rack (2.2.3)
137
- rack-test (1.1.0)
138
- rack (>= 1.0, < 3)
137
+ racc (1.6.0)
138
+ rack (2.2.4)
139
+ rack-test (2.0.2)
140
+ rack (>= 1.3)
139
141
  rails (6.1.4)
140
142
  actioncable (= 6.1.4)
141
143
  actionmailbox (= 6.1.4)
@@ -154,7 +156,7 @@ GEM
154
156
  rails-dom-testing (2.0.3)
155
157
  activesupport (>= 4.2.0)
156
158
  nokogiri (>= 1.6)
157
- rails-html-sanitizer (1.3.0)
159
+ rails-html-sanitizer (1.4.3)
158
160
  loofah (~> 2.3)
159
161
  railties (6.1.4)
160
162
  actionpack (= 6.1.4)
@@ -163,9 +165,9 @@ GEM
163
165
  rake (>= 0.13)
164
166
  thor (~> 1.0)
165
167
  rainbow (3.0.0)
166
- rake (13.0.4)
168
+ rake (13.0.6)
167
169
  regexp_parser (2.1.1)
168
- request_store (1.5.0)
170
+ request_store (1.5.1)
169
171
  rack (>= 1.4)
170
172
  rest-client (2.1.0)
171
173
  http-accept (>= 1.7.0, < 2.0)
@@ -186,38 +188,38 @@ GEM
186
188
  diff-lcs (>= 1.2.0, < 2.0)
187
189
  rspec-support (~> 3.10.0)
188
190
  rspec-support (3.10.2)
189
- rubocop (1.18.3)
191
+ rubocop (1.19.0)
190
192
  parallel (~> 1.10)
191
193
  parser (>= 3.0.0.0)
192
194
  rainbow (>= 2.2.2, < 4.0)
193
195
  regexp_parser (>= 1.8, < 3.0)
194
196
  rexml
195
- rubocop-ast (>= 1.7.0, < 2.0)
197
+ rubocop-ast (>= 1.9.1, < 2.0)
196
198
  ruby-progressbar (~> 1.7)
197
199
  unicode-display_width (>= 1.4.0, < 3.0)
198
- rubocop-ast (1.7.0)
200
+ rubocop-ast (1.10.0)
199
201
  parser (>= 3.0.1.1)
200
202
  ruby-progressbar (1.11.0)
201
- shoulda-matchers (4.5.1)
202
- activesupport (>= 4.2.0)
203
- sprockets (4.0.2)
203
+ shoulda-matchers (5.0.0)
204
+ activesupport (>= 5.2.0)
205
+ sprockets (4.1.1)
204
206
  concurrent-ruby (~> 1.0)
205
207
  rack (> 1, < 3)
206
- sprockets-rails (3.2.2)
207
- actionpack (>= 4.0)
208
- activesupport (>= 4.0)
208
+ sprockets-rails (3.4.2)
209
+ actionpack (>= 5.2)
210
+ activesupport (>= 5.2)
209
211
  sprockets (>= 3.0.0)
210
- thor (1.1.0)
212
+ thor (1.2.1)
211
213
  tzinfo (2.0.4)
212
214
  concurrent-ruby (~> 1.0)
213
215
  unf (0.1.4)
214
216
  unf_ext
215
- unf_ext (0.0.7.7)
217
+ unf_ext (0.0.8.2)
216
218
  unicode-display_width (2.0.0)
217
219
  websocket-driver (0.7.5)
218
220
  websocket-extensions (>= 0.1.0)
219
221
  websocket-extensions (0.1.5)
220
- will_paginate (3.3.0)
222
+ will_paginate (3.3.1)
221
223
  zeitwerk (2.4.2)
222
224
 
223
225
  PLATFORMS
@@ -234,4 +236,4 @@ DEPENDENCIES
234
236
  shoulda-matchers
235
237
 
236
238
  BUNDLED WITH
237
- 2.2.22
239
+ 2.2.25
data/bin/docker ADDED
@@ -0,0 +1,61 @@
1
+ #! /usr/bin/env sh
2
+
3
+ NAMETAG="json-api-toolbox:dev"
4
+ COMMAND=${1:-help}
5
+ shift
6
+
7
+ command_help() {
8
+ echo "
9
+ Usage: docker COMMAND [code]
10
+
11
+ A simple script to control the project container
12
+
13
+ Commands:
14
+ run Run [code] on a new container
15
+ exec Run [code] on the current active container
16
+ build Build the project image
17
+ help Show this help message
18
+ "
19
+ }
20
+
21
+ command_build() {
22
+ docker build -t $NAMETAG --ssh=default .
23
+ }
24
+
25
+ config_ssh_agent() {
26
+ if [ uname == "Darwin" ]; then
27
+ AUTH_PATH="/run/host-services/ssh-auth.sock"
28
+ else
29
+ AUTH_PATH=$(echo $SSH_AUTH_SOCK)
30
+ fi
31
+
32
+ echo "-v $(echo $HOME)/.ssh:/root/.ssh \
33
+ -v $(echo $AUTH_PATH):/ssh-agent \
34
+ -e SSH_AUTH_SOCK=/ssh-agent \
35
+ "
36
+ }
37
+
38
+ command_run() {
39
+ [[ $1 == "--build" ]] && { command_build; shift; }
40
+
41
+ docker volume create bundler_cache > /dev/null
42
+ docker run -it \
43
+ -v bundler_cache:/usr/local/bundle \
44
+ -v $(pwd):/gem \
45
+ $(config_ssh_agent) \
46
+ $NAMETAG
47
+ $@
48
+ }
49
+
50
+ command_exec() {
51
+ [[ $1 == "--build" ]] && { command_build; shift; }
52
+
53
+ docker exec $NAMETAG $@
54
+ }
55
+
56
+ case $COMMAND in
57
+ build) command_build "$@" ;;
58
+ exec) command_exec "$@" ;;
59
+ run) command_run "$@" ;;
60
+ *) command_help "$@" ;;
61
+ esac
data/bin/setup.sh CHANGED
@@ -3,28 +3,31 @@
3
3
  DEFAULT_REPO=git@bitbucket.org:guideinvestimentos/rails_defaults.git
4
4
  STRICT=${1:-no}
5
5
  ONE_WEEK_AGO=$(( $(date +%s) - 604800 ))
6
- FILE_TIME=$(date +%s -r .rubocop.base.yml 2> /dev/null)
6
+
7
+ if [ -f .rubocop.base.yml ]; then
8
+ FILE_TIME=$(date -r .rubocop.base.yml +%s)
9
+ fi
7
10
 
8
11
  info(){
9
- echo -e "\\e[34;1m$1\\e[0m"
12
+ printf "\033[34;1m$1\033[0m\n"
10
13
  }
11
14
 
12
15
  step(){
13
- printf "- $1: \\e7\n"
16
+ printf " - $1: \0337\n"
14
17
  }
15
18
 
16
19
  success(){
17
- printf "\\e8\\e[32;1mOK!\\e[0m\n\\e[2K"
20
+ printf "\0338\033[1A\033[32;1mOK!\033[0m\n\033[2K"
18
21
  }
19
22
 
20
23
  skipped(){
21
- printf "\\e8\\e[33;1mSKIPPED ($1)\\e[0m\n\\e[2K"
24
+ printf "\0338\033[1A\033[33;1mSKIPPED ($1)\033[0m\n\033[2K"
22
25
  }
23
26
 
24
27
  error() {
25
- printf "\\e8\\e[31;1mERRO!\\e[0m\n\\e[2K"
26
- printf "\\e[31m $1\\e[0m\n"
27
- [ $STRICT == "--strict" ] && exit $2
28
+ printf "\0338\033[1A\033[31;1mERRO!\033[0m\n\033[2K"
29
+ printf "\033[31m $1\033[0m\n"
30
+ [ $STRICT -eq "--strict" ] && exit $2
28
31
  }
29
32
 
30
33
  info "Configurando o projeto\n"
@@ -48,7 +51,7 @@ step "Instalando dependências"
48
51
 
49
52
  bundle check 2>&1 > /dev/null && skipped "up-to date" || {
50
53
  RESULT=$(bundle install 2>&1 > /dev/null)
51
- [ $? == 0 ] && success || error "$RESULT" 2
54
+ [ $? -eq "0" ] && success || error "$RESULT" 2
52
55
  }
53
56
 
54
57
  info "\nConfiguração executada com sucesso"
@@ -22,12 +22,10 @@ definitions:
22
22
  - gem update --system
23
23
  - bundle config set --local path "vendor/bundle"
24
24
  - bundle install
25
- - "[ -d ~/.gem/ ] || mkdir -p ~/.gem/"
26
- - curl -u $RUBYGEMS_USERNAME:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml -o ~/.gem/credentials
25
+ - mkdir -p ~/.gem/
26
+ - curl -sSL -u $RUBYGEMS_USERNAME:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml -o ~/.gem/credentials
27
27
  - chmod 0600 ~/.gem/credentials
28
- - bundle exec rake release
29
- caches:
30
- - bundler-26
28
+ - bundle exec rake release --trace
31
29
 
32
30
  pipelines:
33
31
  pull-requests:
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec'
4
-
5
3
  module JsonApiToolbox
6
4
  module Rspec
7
5
  RSpec.shared_examples 'a http method' do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonApiToolbox
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
data/lib/postable.rb CHANGED
@@ -7,7 +7,7 @@ module JsonApiToolbox
7
7
  associations = model.reflect_on_all_associations.map(&:name)
8
8
  normalized_hash = hash.map do |key, value|
9
9
  child_model = association_class(model, key) if value.is_a? Hash
10
- key = associations.include?(key.to_sym) ? "#{key}_attributes" : key
10
+ key = "#{key}_attributes" if associations.include?(key.to_sym)
11
11
  hash_value = check_child_association(value, key, model, child_model)
12
12
  [key, hash_value]
13
13
  end
data/lib/service.rb CHANGED
@@ -6,12 +6,15 @@ require 'json-api-vanilla'
6
6
 
7
7
  module JsonApiToolbox
8
8
  class Service
9
- attr_reader :http_method, :url, :body, :extra_headers
9
+ attr_reader :http_method, :url, :body, :extra_headers, :timeout
10
10
 
11
- def initialize(http_method, url, body, extra_headers = {})
11
+ DEFAULT_TIMEOUT = ENV.fetch('JSON_API_TOOLBOX_TIMEOUT', 60).to_i
12
+
13
+ def initialize(http_method, url, body, timeout, extra_headers = {})
12
14
  @http_method = http_method
13
15
  @url = url
14
16
  @body = body
17
+ @timeout = timeout
15
18
  @extra_headers = extra_headers
16
19
  end
17
20
 
@@ -24,7 +27,8 @@ module JsonApiToolbox
24
27
  method: http_method,
25
28
  url: url,
26
29
  payload: build_body,
27
- headers: build_header
30
+ headers: build_header,
31
+ timeout: timeout
28
32
  )
29
33
  end
30
34
 
@@ -44,21 +48,21 @@ module JsonApiToolbox
44
48
  end
45
49
 
46
50
  class << self
47
- def get(url: nil, includes: nil, query_string: nil, headers: {})
51
+ def get(url: nil, includes: nil, query_string: nil, timeout: DEFAULT_TIMEOUT, headers: {})
48
52
  body = build_query_string(includes, query_string)
49
- new(:get, url, body, headers).execute
53
+ new(:get, url, body, timeout, headers).execute
50
54
  end
51
55
 
52
- def post(url: nil, body: nil, headers: {})
53
- new(:post, url, body, headers).execute
56
+ def post(url: nil, body: nil, timeout: DEFAULT_TIMEOUT, headers: {})
57
+ new(:post, url, body, timeout, headers).execute
54
58
  end
55
59
 
56
- def patch(url: nil, body: nil, headers: {})
57
- new(:patch, url, body, headers).execute
60
+ def patch(url: nil, body: nil, timeout: DEFAULT_TIMEOUT, headers: {})
61
+ new(:patch, url, body, timeout, headers).execute
58
62
  end
59
63
 
60
- def put(url: nil, body: nil, headers: {})
61
- new(:put, url, body, headers).execute
64
+ def put(url: nil, body: nil, timeout: DEFAULT_TIMEOUT, headers: {})
65
+ new(:put, url, body, timeout, headers).execute
62
66
  end
63
67
 
64
68
  def parse_response(response)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adriano Bacha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2022-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -216,12 +216,14 @@ files:
216
216
  - ".gitignore"
217
217
  - ".rspec"
218
218
  - ".rubocop.yml"
219
+ - ".version"
219
220
  - CHANGELOG.md
220
221
  - Dockerfile
221
222
  - Gemfile
222
223
  - Gemfile.lock
223
224
  - README.md
224
225
  - Rakefile
226
+ - bin/docker
225
227
  - bin/setup.sh
226
228
  - bitbucket-pipelines.yml
227
229
  - docker-entrypoint.sh
@@ -257,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
259
  - !ruby/object:Gem::Version
258
260
  version: '0'
259
261
  requirements: []
260
- rubygems_version: 3.2.25
262
+ rubygems_version: 3.3.25
261
263
  signing_key:
262
264
  specification_version: 4
263
265
  summary: Json API usefull tools