restful_resource 2.10.1 → 2.10.3

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: '081a984e1de78fc016fefc2780fcb3704500150aadbd9522ed7ef2f853974280'
4
- data.tar.gz: b6c1c0c81446ad5bd91425331a8da03e41472dde92f5b212cc77fb135b259fac
3
+ metadata.gz: 68a4372ef797bce4031a74263c47edd86898a4f10c7a3516d08cfecdb52b59c5
4
+ data.tar.gz: 46ebcfbb5dbdda37c06c678369e838bdf646f0b3e4d6ea103ddd25407e3e98bb
5
5
  SHA512:
6
- metadata.gz: ea91622af6f36d6a3263ffe856bd86eb625e67114391409dce009622091924cb4f6b7e994925f2f76aa994184b8043a031c4e40ea65abd0b8c274cf6f2569e06
7
- data.tar.gz: 1dc365a6041eeb909e6f3c70450682a90ad1203aaecd26a6fd48335330ab6ec8608a9c10bf034100c235d1ed3a9e2fda82787a48773d45251eca582cdf6f6d84
6
+ metadata.gz: 58bec55b531529a570598f66ab67c7fd113a9315ee7f8fa1cbb9219b7ac326c734a43f8697feb81debb59cb02447c9853d37e8b630a7f0d477c6ce388261c4a8
7
+ data.tar.gz: 7dd64a01a76e08587f2c1f9b122648b2a00a0436b4dc8233b8fb94f3677c96e21e03ff829f829e7c8450dbb8c8536c2c2851cb717c0c89239aa0ea9b56dcaa7c
@@ -2,7 +2,7 @@ version: 2
2
2
  jobs:
3
3
  build:
4
4
  docker:
5
- - image: circleci/ruby:2.6
5
+ - image: circleci/ruby:2.7
6
6
  steps:
7
7
  - checkout
8
8
  - run:
@@ -1,130 +1,132 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-09-11 09:24:50 +0000 using RuboCop version 0.59.0.
3
+ # on 2020-11-12 16:45:32 UTC using RuboCop version 1.3.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'restful_resource.gemspec'
15
+
16
+ # Offense count: 2
17
+ # Cop supports --auto-correct.
18
+ # Configuration parameters: Width, IgnoredPatterns.
19
+ Layout/IndentationWidth:
20
+ Exclude:
21
+ - 'lib/restful_resource/associations.rb'
22
+
9
23
  # Offense count: 2
10
24
  # Cop supports --auto-correct.
11
25
  Layout/RescueEnsureAlignment:
12
26
  Exclude:
13
27
  - 'lib/restful_resource/associations.rb'
14
28
 
15
- # Offense count: 10
16
- Lint/IneffectiveAccessModifier:
29
+ # Offense count: 2
30
+ # Cop supports --auto-correct.
31
+ # Configuration parameters: EnforcedStyleForEmptyBraces.
32
+ # SupportedStyles: space, no_space, compact
33
+ # SupportedStylesForEmptyBraces: space, no_space
34
+ Layout/SpaceInsideHashLiteralBraces:
35
+ EnforcedStyle: space
36
+
37
+ # Offense count: 6
38
+ # Configuration parameters: AllowedMethods.
39
+ Lint/ConstantDefinitionInBlock:
17
40
  Exclude:
18
- - 'lib/restful_resource/base.rb'
41
+ - 'spec/restful_resource/base_authorization_spec.rb'
42
+ - 'spec/restful_resource/http_client_configuration_spec.rb'
19
43
 
20
44
  # Offense count: 1
45
+ Lint/DuplicateBranch:
46
+ Exclude:
47
+ - 'lib/restful_resource/http_client.rb'
48
+
49
+ # Offense count: 1
50
+ # Cop supports --auto-correct.
21
51
  Lint/Loop:
22
52
  Exclude:
23
53
  - 'lib/restful_resource/base.rb'
24
54
 
25
55
  # Offense count: 2
26
- Lint/ParenthesesAsGroupedExpression:
56
+ Lint/MissingSuper:
27
57
  Exclude:
28
- - 'spec/restful_resource/base_spec.rb'
58
+ - 'lib/restful_resource/http_client.rb'
59
+ - 'lib/restful_resource/parameter_missing_error.rb'
29
60
 
30
61
  # Offense count: 2
31
62
  # Cop supports --auto-correct.
32
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
63
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
33
64
  Lint/UnusedMethodArgument:
34
65
  Exclude:
35
66
  - 'lib/restful_resource/redirections.rb'
36
67
 
37
- # Offense count: 3
38
- # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
39
- Lint/UselessAccessModifier:
40
- Exclude:
41
- - 'lib/restful_resource/base.rb'
42
- - 'lib/restful_resource/redirections.rb'
43
-
44
- # Offense count: 5
68
+ # Offense count: 4
45
69
  Lint/UselessAssignment:
46
70
  Exclude:
47
- - 'lib/restful_resource/rails_validations.rb'
48
71
  - 'lib/restful_resource/redirections.rb'
49
72
  - 'spec/restful_resource/base_spec.rb'
73
+ - 'spec/restful_resource/http_client_spec.rb'
50
74
  - 'spec/restful_resource/redirections_spec.rb'
51
75
 
52
76
  # Offense count: 8
77
+ # Configuration parameters: IgnoredMethods.
53
78
  Metrics/AbcSize:
54
- Max: 101
55
-
56
- # Offense count: 1
57
- # Configuration parameters: CountComments, ExcludedMethods.
58
- # ExcludedMethods: refine
59
- Metrics/BlockLength:
60
- Max: 27
79
+ Max: 102
61
80
 
62
81
  # Offense count: 2
63
- # Configuration parameters: CountComments.
82
+ # Configuration parameters: CountComments, CountAsOne.
64
83
  Metrics/ClassLength:
65
- Max: 162
84
+ Max: 195
66
85
 
67
- # Offense count: 2
86
+ # Offense count: 5
87
+ # Configuration parameters: IgnoredMethods.
68
88
  Metrics/CyclomaticComplexity:
69
89
  Max: 13
70
90
 
71
- # Offense count: 42
72
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
73
- # URISchemes: http, https
74
- Metrics/LineLength:
75
- Max: 201
76
-
77
91
  # Offense count: 10
78
- # Configuration parameters: CountComments.
92
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
79
93
  Metrics/MethodLength:
80
94
  Max: 56
81
95
 
82
- # Offense count: 8
96
+ # Offense count: 9
83
97
  # Configuration parameters: CountKeywordArgs.
84
98
  Metrics/ParameterLists:
85
- Max: 10
99
+ Max: 11
86
100
 
87
- # Offense count: 1
101
+ # Offense count: 2
102
+ # Configuration parameters: IgnoredMethods.
88
103
  Metrics/PerceivedComplexity:
89
- Max: 8
104
+ Max: 11
90
105
 
91
106
  # Offense count: 2
92
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
107
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
93
108
  # NamePrefix: is_, has_, have_
94
- # NamePrefixBlacklist: is_, has_, have_
95
- # NameWhitelist: is_a?
109
+ # ForbiddenPrefixes: is_, has_, have_
110
+ # AllowedMethods: is_a?
96
111
  # MethodDefinitionMacros: define_method, define_singleton_method
97
112
  Naming/PredicateName:
98
113
  Exclude:
99
114
  - 'spec/**/*'
100
115
  - 'lib/restful_resource/associations.rb'
101
116
 
102
- # Offense count: 14
103
- # Configuration parameters: Prefixes.
104
- # Prefixes: when, with, without
105
- RSpec/ContextWording:
106
- Exclude:
107
- - 'spec/restful_resource/http_client_configuration_spec.rb'
108
- - 'spec/restful_resource/rails_validations_spec.rb'
109
- - 'spec/restful_resource/request_spec.rb'
110
-
111
117
  # Offense count: 1
112
118
  RSpec/DescribeMethod:
113
119
  Exclude:
114
120
  - 'spec/restful_resource/base_authorization_spec.rb'
115
121
 
116
- # Offense count: 19
122
+ # Offense count: 2
117
123
  # Configuration parameters: Max.
118
124
  RSpec/ExampleLength:
119
125
  Exclude:
120
126
  - 'spec/restful_resource/base_spec.rb'
121
- - 'spec/restful_resource/http_client_configuration_spec.rb'
122
- - 'spec/restful_resource/http_client_spec.rb'
123
127
  - 'spec/restful_resource/open_object_spec.rb'
124
- - 'spec/restful_resource/rails_validations_spec.rb'
125
- - 'spec/restful_resource/redirections_spec.rb'
126
128
 
127
- # Offense count: 53
129
+ # Offense count: 71
128
130
  # Configuration parameters: AssignmentOnly.
129
131
  RSpec/InstanceVariable:
130
132
  Exclude:
@@ -134,7 +136,13 @@ RSpec/InstanceVariable:
134
136
  - 'spec/restful_resource/rails_validations_spec.rb'
135
137
  - 'spec/restful_resource/redirections_spec.rb'
136
138
 
137
- # Offense count: 14
139
+ # Offense count: 6
140
+ RSpec/LeakyConstantDeclaration:
141
+ Exclude:
142
+ - 'spec/restful_resource/base_authorization_spec.rb'
143
+ - 'spec/restful_resource/http_client_configuration_spec.rb'
144
+
145
+ # Offense count: 17
138
146
  # Configuration parameters: EnforcedStyle.
139
147
  # SupportedStyles: have_received, receive
140
148
  RSpec/MessageSpies:
@@ -143,27 +151,38 @@ RSpec/MessageSpies:
143
151
  - 'spec/restful_resource/redirections_spec.rb'
144
152
  - 'spec/spec_helper.rb'
145
153
 
146
- # Offense count: 22
147
- # Configuration parameters: AggregateFailuresByDefault.
154
+ # Offense count: 24
148
155
  RSpec/MultipleExpectations:
149
156
  Max: 7
150
157
 
151
- # Offense count: 6
158
+ # Offense count: 1
159
+ # Configuration parameters: AllowSubject.
160
+ RSpec/MultipleMemoizedHelpers:
161
+ Max: 10
162
+
163
+ # Offense count: 13
164
+ # Configuration parameters: IgnoreSharedExamples.
152
165
  RSpec/NamedSubject:
153
166
  Exclude:
167
+ - 'spec/restful_resource/rails_validations_spec.rb'
154
168
  - 'spec/restful_resource/redirections_spec.rb'
155
169
 
156
- # Offense count: 10
170
+ # Offense count: 12
157
171
  RSpec/NestedGroups:
158
172
  Max: 5
159
173
 
160
- # Offense count: 2
174
+ # Offense count: 4
161
175
  RSpec/RepeatedDescription:
162
176
  Exclude:
163
177
  - 'spec/restful_resource/base_spec.rb'
164
178
 
165
- # Offense count: 3
166
- # Configuration parameters: IgnoreSymbolicNames.
179
+ # Offense count: 10
180
+ RSpec/StubbedMock:
181
+ Exclude:
182
+ - 'spec/spec_helper.rb'
183
+
184
+ # Offense count: 4
185
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
167
186
  RSpec/VerifiedDoubles:
168
187
  Exclude:
169
188
  - 'spec/restful_resource/base_spec.rb'
@@ -176,28 +195,58 @@ Style/AsciiComments:
176
195
  Exclude:
177
196
  - 'lib/restful_resource/instrumentation.rb'
178
197
 
198
+ # Offense count: 3
199
+ # Cop supports --auto-correct.
200
+ # Configuration parameters: Keywords.
201
+ # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE
202
+ Style/CommentAnnotation:
203
+ Exclude:
204
+ - 'spec/restful_resource/http_client_spec.rb'
205
+
179
206
  # Offense count: 1
180
- Style/MethodMissingSuper:
207
+ # Cop supports --auto-correct.
208
+ # Configuration parameters: EnforcedStyle.
209
+ # SupportedStyles: braces, no_braces
210
+ Style/HashAsLastArrayItem:
181
211
  Exclude:
182
- - 'lib/restful_resource/open_object.rb'
212
+ - 'lib/restful_resource/base.rb'
183
213
 
184
214
  # Offense count: 1
185
215
  Style/MissingRespondToMissing:
186
216
  Exclude:
187
217
  - 'lib/restful_resource/open_object.rb'
188
218
 
219
+ # Offense count: 2
220
+ # Configuration parameters: AllowedMethods.
221
+ # AllowedMethods: respond_to_missing?
222
+ Style/OptionalBooleanParameter:
223
+ Exclude:
224
+ - 'lib/restful_resource/open_object.rb'
225
+
189
226
  # Offense count: 1
190
227
  # Cop supports --auto-correct.
191
- # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
192
- # SupportedStyles: slashes, percent_r, mixed
193
- Style/RegexpLiteral:
228
+ Style/RedundantFileExtensionInRequire:
229
+ Exclude:
230
+ - 'lib/restful_resource.rb'
231
+
232
+ # Offense count: 2
233
+ # Cop supports --auto-correct.
234
+ Style/StringConcatenation:
194
235
  Exclude:
236
+ - 'lib/restful_resource/authorization.rb'
195
237
  - 'lib/restful_resource/base.rb'
196
238
 
197
239
  # Offense count: 1
198
240
  # Cop supports --auto-correct.
199
- # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
200
- # Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
241
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods.
242
+ # AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
201
243
  Style/TrivialAccessors:
202
244
  Exclude:
203
245
  - 'lib/restful_resource/base.rb'
246
+
247
+ # Offense count: 29
248
+ # Cop supports --auto-correct.
249
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
250
+ # URISchemes: http, https
251
+ Layout/LineLength:
252
+ Max: 201
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- restful_resource (2.10.1)
4
+ restful_resource (2.10.3)
5
5
  activesupport (~> 6.0)
6
6
  faraday (~> 1.0)
7
7
  faraday-cdn-metrics (~> 0.2)
@@ -15,24 +15,25 @@ PATH
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- activesupport (6.0.3.3)
18
+ activesupport (6.0.3.4)
19
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
20
  i18n (>= 0.7, < 2)
21
21
  minitest (~> 5.1)
22
22
  tzinfo (~> 1.1)
23
23
  zeitwerk (~> 2.2, >= 2.2.2)
24
- ast (2.4.0)
25
- carwow_rubocop (3.3.0)
26
- rubocop (>= 0.78)
24
+ ast (2.4.1)
25
+ carwow_rubocop (3.4.1)
26
+ rubocop (>= 0.93)
27
27
  rubocop-performance
28
28
  rubocop-rspec
29
29
  coderay (1.1.2)
30
30
  concurrent-ruby (1.1.7)
31
- diff-lcs (1.3)
31
+ diff-lcs (1.4.4)
32
32
  ethon (0.12.0)
33
33
  ffi (>= 1.3.0)
34
- faraday (1.0.1)
34
+ faraday (1.1.0)
35
35
  multipart-post (>= 1.2, < 3)
36
+ ruby2_keywords
36
37
  faraday-cdn-metrics (0.2.0)
37
38
  faraday (~> 1)
38
39
  faraday-encoding (0.0.5)
@@ -48,49 +49,54 @@ GEM
48
49
  method_source (1.0.0)
49
50
  minitest (5.14.2)
50
51
  multipart-post (2.1.1)
51
- parallel (1.19.1)
52
- parser (2.7.1.2)
53
- ast (~> 2.4.0)
52
+ parallel (1.20.0)
53
+ parser (2.7.2.0)
54
+ ast (~> 2.4.1)
54
55
  pry (0.13.1)
55
56
  coderay (~> 1.1)
56
57
  method_source (~> 1.0)
57
58
  rack (2.2.3)
58
59
  rainbow (3.0.0)
59
60
  rake (13.0.1)
61
+ regexp_parser (1.8.2)
60
62
  rexml (3.2.4)
61
- rspec (3.9.0)
62
- rspec-core (~> 3.9.0)
63
- rspec-expectations (~> 3.9.0)
64
- rspec-mocks (~> 3.9.0)
65
- rspec-core (3.9.0)
66
- rspec-support (~> 3.9.0)
67
- rspec-expectations (3.9.0)
63
+ rspec (3.10.0)
64
+ rspec-core (~> 3.10.0)
65
+ rspec-expectations (~> 3.10.0)
66
+ rspec-mocks (~> 3.10.0)
67
+ rspec-core (3.10.0)
68
+ rspec-support (~> 3.10.0)
69
+ rspec-expectations (3.10.0)
68
70
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.9.0)
71
+ rspec-support (~> 3.10.0)
70
72
  rspec-its (1.3.0)
71
73
  rspec-core (>= 3.0.0)
72
74
  rspec-expectations (>= 3.0.0)
73
- rspec-mocks (3.9.0)
75
+ rspec-mocks (3.10.0)
74
76
  diff-lcs (>= 1.2.0, < 2.0)
75
- rspec-support (~> 3.9.0)
76
- rspec-support (3.9.0)
77
+ rspec-support (~> 3.10.0)
78
+ rspec-support (3.10.0)
77
79
  rspec_junit_formatter (0.4.1)
78
80
  rspec-core (>= 2, < 4, != 2.12.0)
79
- rubocop (0.84.0)
81
+ rubocop (1.3.0)
80
82
  parallel (~> 1.10)
81
- parser (>= 2.7.0.1)
83
+ parser (>= 2.7.1.5)
82
84
  rainbow (>= 2.2.2, < 4.0)
85
+ regexp_parser (>= 1.8)
83
86
  rexml
84
- rubocop-ast (>= 0.0.3)
87
+ rubocop-ast (>= 1.1.1)
85
88
  ruby-progressbar (~> 1.7)
86
89
  unicode-display_width (>= 1.4.0, < 2.0)
87
- rubocop-ast (0.0.3)
88
- parser (>= 2.7.0.1)
89
- rubocop-performance (1.6.0)
90
- rubocop (>= 0.71.0)
91
- rubocop-rspec (1.39.0)
92
- rubocop (>= 0.68.1)
90
+ rubocop-ast (1.1.1)
91
+ parser (>= 2.7.1.5)
92
+ rubocop-performance (1.8.1)
93
+ rubocop (>= 0.87.0)
94
+ rubocop-ast (>= 0.4.0)
95
+ rubocop-rspec (2.0.0)
96
+ rubocop (~> 1.0)
97
+ rubocop-ast (>= 1.1.0)
93
98
  ruby-progressbar (1.10.1)
99
+ ruby2_keywords (0.0.2)
94
100
  thread_safe (0.3.6)
95
101
  typhoeus (1.4.0)
96
102
  ethon (>= 0.9.0)
@@ -8,7 +8,7 @@ require 'faraday_cdn_metrics'
8
8
  require 'faraday/encoding'
9
9
  require 'active_support'
10
10
  require 'active_support/all'
11
- require 'resolv-replace.rb'
11
+ require 'resolv-replace'
12
12
  require_relative 'restful_resource/version'
13
13
  require_relative 'restful_resource/null_logger'
14
14
  require_relative 'restful_resource/paginated_array'
@@ -34,35 +34,35 @@ module RestfulResource
34
34
  end
35
35
 
36
36
  def self.find(id, **params)
37
- params_without_options, options = format_params(params)
37
+ params_without_options, options = format_params(**params)
38
38
 
39
39
  response = http.get(member_url(id, **params_without_options), **options)
40
40
  new(parse_json(response.body))
41
41
  end
42
42
 
43
43
  def self.where(**params)
44
- params_without_options, options = format_params(params)
44
+ params_without_options, options = format_params(**params)
45
45
 
46
- url = collection_url(params_without_options)
46
+ url = collection_url(**params_without_options)
47
47
  response = http.get(url, **options)
48
48
  paginate_response(response)
49
49
  end
50
50
 
51
51
  def self.get(**params)
52
- params_without_options, options = format_params(params)
52
+ params_without_options, options = format_params(**params)
53
53
 
54
- response = http.get(collection_url(params_without_options), **options)
54
+ response = http.get(collection_url(**params_without_options), **options)
55
55
  new(parse_json(response.body))
56
56
  end
57
57
 
58
58
  def self.delete(id, **params)
59
- params_without_options, options = format_params(params)
59
+ params_without_options, options = format_params(**params)
60
60
  response = http.delete(member_url(id, **params_without_options), **options)
61
61
  new(parse_json(response.body))
62
62
  end
63
63
 
64
64
  def self.patch(id, data: {}, headers: {}, **params)
65
- params_without_options, options = format_params(params)
65
+ params_without_options, options = format_params(**params)
66
66
  options.delete(:headers)
67
67
 
68
68
  url = member_url(id, **params_without_options)
@@ -72,7 +72,7 @@ module RestfulResource
72
72
  end
73
73
 
74
74
  def self.put(id, data: {}, headers: {}, **params)
75
- params_without_options, options = format_params(params)
75
+ params_without_options, options = format_params(**params)
76
76
  options.delete(:headers)
77
77
 
78
78
  url = member_url(id, **params_without_options)
@@ -82,10 +82,10 @@ module RestfulResource
82
82
  end
83
83
 
84
84
  def self.post(data: {}, headers: {}, **params)
85
- params_without_options, options = format_params(params)
85
+ params_without_options, options = format_params(**params)
86
86
  options.delete(:headers)
87
87
 
88
- url = collection_url(params_without_options)
88
+ url = collection_url(**params_without_options)
89
89
 
90
90
  response = http.post(url, data: data, headers: headers, **options)
91
91
 
@@ -93,7 +93,7 @@ module RestfulResource
93
93
  end
94
94
 
95
95
  def self.all(**params)
96
- where(params)
96
+ where(**params)
97
97
  end
98
98
 
99
99
  def self.action(action_name)
@@ -119,8 +119,6 @@ module RestfulResource
119
119
  end
120
120
  end
121
121
 
122
- protected
123
-
124
122
  def self.http
125
123
  @http || superclass.http
126
124
  end
@@ -135,11 +133,9 @@ module RestfulResource
135
133
 
136
134
  def self.collection_url(**params)
137
135
  url = merge_url_paths(base_url, @resource_path, @action_prefix)
138
- replace_parameters(url, params)
136
+ replace_parameters(url, **params)
139
137
  end
140
138
 
141
- private
142
-
143
139
  def self.format_params(**params)
144
140
  headers = params.delete(:headers) || {}
145
141
 
@@ -147,7 +143,7 @@ module RestfulResource
147
143
  open_timeout = params.delete(:open_timeout)
148
144
  timeout = params.delete(:timeout)
149
145
 
150
- [params, headers: headers, open_timeout: open_timeout, timeout: timeout]
146
+ [params, { headers: headers, open_timeout: open_timeout, timeout: timeout }]
151
147
  end
152
148
 
153
149
  def self.merge_url_paths(uri, *paths)
@@ -177,7 +173,7 @@ module RestfulResource
177
173
  missing_params = []
178
174
  params = params.with_indifferent_access
179
175
 
180
- url_params = url.scan(/:([A-Za-z][^\/]*)/).flatten
176
+ url_params = url.scan(%r{:([A-Za-z][^/]*)}).flatten
181
177
  url_params.each do |key|
182
178
  value = params.delete(key)
183
179
  if value.nil?
@@ -9,15 +9,17 @@ module RestfulResource
9
9
  def self.included(base)
10
10
  base.instance_eval do
11
11
  def post(data: {}, delay: 1.0, max_attempts: 10, headers: {}, open_timeout: nil, timeout: nil, **params)
12
- url = collection_url(params)
12
+ url = collection_url(**params)
13
13
 
14
- response = accept_redirected_result(response: http.post(url, data: data, headers: headers, open_timeout: nil, timeout: nil), delay: delay, max_attempts: max_attempts)
14
+ response = accept_redirected_result(
15
+ response: http.post(url, data: data, headers: headers, open_timeout: nil, timeout: nil),
16
+ delay: delay,
17
+ max_attempts: max_attempts
18
+ )
15
19
 
16
20
  new(parse_json(response.body))
17
21
  end
18
22
 
19
- private
20
-
21
23
  def self.accept_redirected_result(response:, delay:, max_attempts:)
22
24
  new_response = response
23
25
  if response.status == 303
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = '2.10.1'.freeze
2
+ VERSION = '2.10.3'.freeze
3
3
  end
@@ -11,7 +11,6 @@ describe RestfulResource::Associations do
11
11
  { first_name: 'David', second_name: 'Doe' },
12
12
  { first_name: 'Mary', second_name: 'Doe' }
13
13
  ]
14
-
15
14
  )
16
15
  end
17
16
 
@@ -39,7 +38,6 @@ describe RestfulResource::Associations do
39
38
  @child = ComplicatedModule::Child.new(
40
39
  first_name: 'David', second_name: 'Smith',
41
40
  parent: { name: 'John Smith' }
42
-
43
41
  )
44
42
  end
45
43
 
@@ -365,17 +365,17 @@ RSpec.describe RestfulResource::Base do
365
365
  end
366
366
 
367
367
  it 'does not return inner object table' do
368
- expect(@makes.first.as_json).to eq ({ 'name' => 'Audi', 'slug' => 'Audi-Slug' })
368
+ expect(@makes.first.as_json).to eq({ 'name' => 'Audi', 'slug' => 'Audi-Slug' })
369
369
  end
370
370
 
371
371
  it 'returns inner object table on selected fields' do
372
- expect(@makes.last.as_json(only: [:name])).to eq ({ 'name' => 'Fiat' })
372
+ expect(@makes.last.as_json(only: [:name])).to eq({ 'name' => 'Fiat' })
373
373
  end
374
374
  end
375
375
 
376
376
  describe '.member_url' do
377
377
  it 'requires a member ID' do
378
- expect { described_class.member_url('', {}) }.to raise_error(RestfulResource::ResourceIdMissingError)
378
+ expect { described_class.member_url('') }.to raise_error(RestfulResource::ResourceIdMissingError)
379
379
  end
380
380
  end
381
381
 
@@ -406,17 +406,17 @@ RSpec.describe RestfulResource::Base do
406
406
  )
407
407
 
408
408
  client.configure(base_url: 'http://foo.bar',
409
- username: username,
410
- password: password,
411
- auth_token: auth_token,
412
- logger: logger,
413
- cache_store: cache_store,
414
- instrumentation: instrumentation,
415
- timeout: timeout,
416
- open_timeout: open_timeout,
417
- faraday_config: faraday_config,
418
- faraday_options: faraday_options
419
- )
409
+ username: username,
410
+ password: password,
411
+ auth_token: auth_token,
412
+ logger: logger,
413
+ cache_store: cache_store,
414
+ instrumentation: instrumentation,
415
+ timeout: timeout,
416
+ open_timeout: open_timeout,
417
+ faraday_config: faraday_config,
418
+ faraday_options: faraday_options
419
+ )
420
420
  end
421
421
  end
422
422
 
@@ -17,7 +17,7 @@ RSpec.describe RestfulResource::HttpClient do
17
17
 
18
18
  describe 'Basic HTTP' do
19
19
  shared_examples 'error codes throw exception' do |verb, status, exception_class|
20
- it "should raise an error #{status}" do
20
+ it "raises an error #{status}" do
21
21
  url = "http://httpbin.org/status/#{status}"
22
22
 
23
23
  connection = faraday_connection do |stubs|
@@ -58,7 +58,7 @@ RSpec.describe RestfulResource::HttpClient do
58
58
 
59
59
  it 'executes patch' do
60
60
  connection = faraday_connection do |stubs|
61
- # Note: request body is serialized as url-encoded so the stub body must be in the same format to match
61
+ # NOTE: request body is serialized as url-encoded so the stub body must be in the same format to match
62
62
  stubs.patch('http://httpbin.org/patch', 'name=Alfred') { |_env| [200, {}, nil] }
63
63
  end
64
64
 
@@ -71,7 +71,7 @@ RSpec.describe RestfulResource::HttpClient do
71
71
  include_examples 'raise an exception on error responses', :put
72
72
  it 'executes put' do
73
73
  connection = faraday_connection do |stubs|
74
- # Note: request body is serialized as url-encoded so the stub body must be in the same format to match
74
+ # NOTE: request body is serialized as url-encoded so the stub body must be in the same format to match
75
75
  stubs.put('http://httpbin.org/put', 'name=Alfred') { |_env| [200, {}, nil] }
76
76
  end
77
77
 
@@ -84,7 +84,7 @@ RSpec.describe RestfulResource::HttpClient do
84
84
  include_examples 'raise an exception on error responses', :post
85
85
  it 'executes post' do
86
86
  connection = faraday_connection do |stubs|
87
- # Note: request body is serialized as url-encoded so the stub body must be in the same format to match
87
+ # NOTE: request body is serialized as url-encoded so the stub body must be in the same format to match
88
88
  stubs.post('http://httpbin.org/post', 'name=Alfred') { |_env| [200, {}, %("name": "Alfred")] }
89
89
  end
90
90
 
@@ -219,10 +219,10 @@ RSpec.describe RestfulResource::HttpClient do
219
219
  conn
220
220
  end
221
221
 
222
-
223
222
  context 'when explicit timeout set on connection' do
224
223
  let(:timeout) { 5 }
225
224
  let(:required_headers) { { 'X-Client-Timeout' => 5 } }
225
+
226
226
  it 'sets X-Client-Timeout correctly' do
227
227
  response = http_client.get('http://httpbin.org/get')
228
228
 
@@ -7,7 +7,7 @@ RSpec.describe RestfulResource::RailsValidations do
7
7
  allow(Dealer).to receive(:http).and_return(@mock_http)
8
8
  end
9
9
 
10
- context '#patch without errors' do
10
+ describe '#patch without errors' do
11
11
  before do
12
12
  data = { name: 'Barak' }
13
13
  expected_response = RestfulResource::Response.new(body: { name: 'Barak' }.to_json)
@@ -25,7 +25,7 @@ RSpec.describe RestfulResource::RailsValidations do
25
25
  end
26
26
  end
27
27
 
28
- context '#patch with errors' do
28
+ describe '#patch with errors' do
29
29
  before do
30
30
  data = { name: 'Leonardo' }
31
31
  @error = 'Cannot use Ninja Turtles names'
@@ -72,7 +72,7 @@ RSpec.describe RestfulResource::RailsValidations do
72
72
  end
73
73
  end
74
74
 
75
- context '#put without errors' do
75
+ describe '#put without errors' do
76
76
  before do
77
77
  data = { name: 'Barak' }
78
78
  expected_response = RestfulResource::Response.new(body: { name: 'Barak' }.to_json)
@@ -90,7 +90,7 @@ RSpec.describe RestfulResource::RailsValidations do
90
90
  end
91
91
  end
92
92
 
93
- context '#put with errors' do
93
+ describe '#put with errors' do
94
94
  before do
95
95
  data = { name: 'Leonardo' }
96
96
  @error = 'Cannot use Ninja Turtles names'
@@ -137,7 +137,7 @@ RSpec.describe RestfulResource::RailsValidations do
137
137
  end
138
138
  end
139
139
 
140
- context '#post without errors' do
140
+ describe '#post without errors' do
141
141
  before do
142
142
  data = { name: 'Barak' }
143
143
  expected_response = RestfulResource::Response.new(body: { name: 'Barak' }.to_json)
@@ -155,7 +155,7 @@ RSpec.describe RestfulResource::RailsValidations do
155
155
  end
156
156
  end
157
157
 
158
- context '#post with errors' do
158
+ describe '#post with errors' do
159
159
  before do
160
160
  data = { name: 'Leonardo' }
161
161
  @error = 'Cannot use Ninja Turtles names'
@@ -192,7 +192,7 @@ RSpec.describe RestfulResource::RailsValidations do
192
192
  end
193
193
  end
194
194
 
195
- context '#get without errors' do
195
+ describe '#get without errors' do
196
196
  before do
197
197
  expected_response = RestfulResource::Response.new(body: { name: 'Barak' }.to_json)
198
198
  expect_get('http://api.carwow.co.uk/dealers', expected_response)
@@ -209,7 +209,7 @@ RSpec.describe RestfulResource::RailsValidations do
209
209
  end
210
210
  end
211
211
 
212
- context '#get with errors' do
212
+ describe '#get with errors' do
213
213
  before do
214
214
  @error = 'Missing parameter'
215
215
  expected_response = RestfulResource::Response.new(body: { errors: [@error] }.to_json)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-01 00:00:00.000000000 Z
12
+ date: 2020-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler