restful_resource 2.10.0 → 2.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.rubocop_todo.yml +119 -70
- data/Gemfile.lock +53 -46
- data/lib/restful_resource.rb +3 -1
- data/lib/restful_resource/base.rb +19 -23
- data/lib/restful_resource/deprecator.rb +25 -0
- data/lib/restful_resource/open_object.rb +1 -1
- data/lib/restful_resource/redirections.rb +6 -4
- data/lib/restful_resource/strict_open_struct.rb +5 -0
- data/lib/restful_resource/version.rb +1 -1
- data/restful_resource.gemspec +1 -1
- data/spec/restful_resource/associations_spec.rb +0 -2
- data/spec/restful_resource/base_spec.rb +14 -14
- data/spec/restful_resource/http_client_spec.rb +5 -5
- data/spec/restful_resource/rails_validations_spec.rb +8 -8
- data/spec/restful_resource/strict_open_struct_spec.rb +21 -0
- data/spec/spec_helper.rb +1 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d99c38a79730e832e99b155798ae920f45eed26dd44435ce71efcb58fd6094c
|
4
|
+
data.tar.gz: 46ea4b63768ee7cf60ee5aa33fe02c96f5e715e6512d0a0cff38483ff975325b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc155eb1cd1fd0d3e70654dd6d5b4b6824409533f8d3d72a0aed79eca56501b8eea9745732fb7fd26406df9051edfde3a20fe31e9042666cfe1b7f8e47b7a735
|
7
|
+
data.tar.gz: 9f7bb0b92f5dcff2161547829cc4b798d00e5ac1a614559e6785dee231a0a4552e54998d927c8d947dba005e555b81144eba8f78e8e5eabee707ea70aff2c422
|
data/.circleci/config.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,130 +1,132 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
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:
|
16
|
-
|
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
|
-
- '
|
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/
|
56
|
+
Lint/MissingSuper:
|
27
57
|
Exclude:
|
28
|
-
- '
|
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:
|
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:
|
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:
|
84
|
+
Max: 195
|
66
85
|
|
67
|
-
# Offense count:
|
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:
|
96
|
+
# Offense count: 9
|
83
97
|
# Configuration parameters: CountKeywordArgs.
|
84
98
|
Metrics/ParameterLists:
|
85
|
-
Max:
|
99
|
+
Max: 11
|
86
100
|
|
87
|
-
# Offense count:
|
101
|
+
# Offense count: 2
|
102
|
+
# Configuration parameters: IgnoredMethods.
|
88
103
|
Metrics/PerceivedComplexity:
|
89
|
-
Max:
|
104
|
+
Max: 11
|
90
105
|
|
91
106
|
# Offense count: 2
|
92
|
-
# Configuration parameters: NamePrefix,
|
107
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
93
108
|
# NamePrefix: is_, has_, have_
|
94
|
-
#
|
95
|
-
#
|
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:
|
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:
|
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:
|
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:
|
147
|
-
# Configuration parameters: AggregateFailuresByDefault.
|
154
|
+
# Offense count: 24
|
148
155
|
RSpec/MultipleExpectations:
|
149
156
|
Max: 7
|
150
157
|
|
151
|
-
# Offense count:
|
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:
|
170
|
+
# Offense count: 12
|
157
171
|
RSpec/NestedGroups:
|
158
172
|
Max: 5
|
159
173
|
|
160
|
-
# Offense count:
|
174
|
+
# Offense count: 4
|
161
175
|
RSpec/RepeatedDescription:
|
162
176
|
Exclude:
|
163
177
|
- 'spec/restful_resource/base_spec.rb'
|
164
178
|
|
165
|
-
# Offense count:
|
166
|
-
|
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
|
-
|
207
|
+
# Cop supports --auto-correct.
|
208
|
+
# Configuration parameters: EnforcedStyle.
|
209
|
+
# SupportedStyles: braces, no_braces
|
210
|
+
Style/HashAsLastArrayItem:
|
181
211
|
Exclude:
|
182
|
-
- 'lib/restful_resource/
|
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
|
-
|
192
|
-
|
193
|
-
|
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,
|
200
|
-
#
|
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
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
restful_resource (2.
|
4
|
+
restful_resource (2.12.1)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
faraday (~> 1.0)
|
7
7
|
faraday-cdn-metrics (~> 0.2)
|
@@ -15,89 +15,96 @@ PATH
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
17
17
|
specs:
|
18
|
-
activesupport (6.
|
18
|
+
activesupport (6.1.3.1)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
-
i18n (>=
|
21
|
-
minitest (
|
22
|
-
tzinfo (~>
|
23
|
-
zeitwerk (~> 2.
|
24
|
-
ast (2.4.
|
25
|
-
carwow_rubocop (3.
|
26
|
-
rubocop (>= 0.
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
minitest (>= 5.1)
|
22
|
+
tzinfo (~> 2.0)
|
23
|
+
zeitwerk (~> 2.3)
|
24
|
+
ast (2.4.1)
|
25
|
+
carwow_rubocop (3.4.1)
|
26
|
+
rubocop (>= 0.93)
|
27
27
|
rubocop-performance
|
28
28
|
rubocop-rspec
|
29
|
-
coderay (1.1.
|
30
|
-
concurrent-ruby (1.1.
|
31
|
-
diff-lcs (1.
|
29
|
+
coderay (1.1.3)
|
30
|
+
concurrent-ruby (1.1.8)
|
31
|
+
diff-lcs (1.4.4)
|
32
32
|
ethon (0.12.0)
|
33
33
|
ffi (>= 1.3.0)
|
34
|
-
faraday (1.0
|
34
|
+
faraday (1.3.0)
|
35
|
+
faraday-net_http (~> 1.0)
|
35
36
|
multipart-post (>= 1.2, < 3)
|
37
|
+
ruby2_keywords
|
36
38
|
faraday-cdn-metrics (0.2.0)
|
37
39
|
faraday (~> 1)
|
38
40
|
faraday-encoding (0.0.5)
|
39
41
|
faraday
|
40
42
|
faraday-http-cache (2.2.0)
|
41
43
|
faraday (>= 0.8)
|
44
|
+
faraday-net_http (1.0.1)
|
42
45
|
faraday_middleware (1.0.0)
|
43
46
|
faraday (~> 1.0)
|
44
|
-
ffi (1.
|
45
|
-
i18n (1.8.
|
47
|
+
ffi (1.15.0)
|
48
|
+
i18n (1.8.10)
|
46
49
|
concurrent-ruby (~> 1.0)
|
47
50
|
link_header (0.0.8)
|
48
51
|
method_source (1.0.0)
|
49
|
-
minitest (5.14.
|
52
|
+
minitest (5.14.4)
|
50
53
|
multipart-post (2.1.1)
|
51
|
-
parallel (1.
|
52
|
-
parser (2.7.
|
53
|
-
ast (~> 2.4.
|
54
|
-
pry (0.
|
54
|
+
parallel (1.20.0)
|
55
|
+
parser (2.7.2.0)
|
56
|
+
ast (~> 2.4.1)
|
57
|
+
pry (0.14.0)
|
55
58
|
coderay (~> 1.1)
|
56
59
|
method_source (~> 1.0)
|
57
|
-
rack (2.2.
|
60
|
+
rack (2.2.3)
|
58
61
|
rainbow (3.0.0)
|
59
|
-
rake (13.0.
|
62
|
+
rake (13.0.3)
|
63
|
+
regexp_parser (1.8.2)
|
60
64
|
rexml (3.2.4)
|
61
|
-
rspec (3.
|
62
|
-
rspec-core (~> 3.
|
63
|
-
rspec-expectations (~> 3.
|
64
|
-
rspec-mocks (~> 3.
|
65
|
-
rspec-core (3.
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-expectations (3.
|
65
|
+
rspec (3.10.0)
|
66
|
+
rspec-core (~> 3.10.0)
|
67
|
+
rspec-expectations (~> 3.10.0)
|
68
|
+
rspec-mocks (~> 3.10.0)
|
69
|
+
rspec-core (3.10.0)
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-expectations (3.10.0)
|
68
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
73
|
+
rspec-support (~> 3.10.0)
|
70
74
|
rspec-its (1.3.0)
|
71
75
|
rspec-core (>= 3.0.0)
|
72
76
|
rspec-expectations (>= 3.0.0)
|
73
|
-
rspec-mocks (3.
|
77
|
+
rspec-mocks (3.10.0)
|
74
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
-
rspec-support (~> 3.
|
76
|
-
rspec-support (3.
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-support (3.10.0)
|
77
81
|
rspec_junit_formatter (0.4.1)
|
78
82
|
rspec-core (>= 2, < 4, != 2.12.0)
|
79
|
-
rubocop (
|
83
|
+
rubocop (1.3.0)
|
80
84
|
parallel (~> 1.10)
|
81
|
-
parser (>= 2.7.
|
85
|
+
parser (>= 2.7.1.5)
|
82
86
|
rainbow (>= 2.2.2, < 4.0)
|
87
|
+
regexp_parser (>= 1.8)
|
83
88
|
rexml
|
84
|
-
rubocop-ast (>=
|
89
|
+
rubocop-ast (>= 1.1.1)
|
85
90
|
ruby-progressbar (~> 1.7)
|
86
91
|
unicode-display_width (>= 1.4.0, < 2.0)
|
87
|
-
rubocop-ast (
|
88
|
-
parser (>= 2.7.
|
89
|
-
rubocop-performance (1.
|
90
|
-
rubocop (>= 0.
|
91
|
-
|
92
|
-
|
92
|
+
rubocop-ast (1.1.1)
|
93
|
+
parser (>= 2.7.1.5)
|
94
|
+
rubocop-performance (1.8.1)
|
95
|
+
rubocop (>= 0.87.0)
|
96
|
+
rubocop-ast (>= 0.4.0)
|
97
|
+
rubocop-rspec (2.0.0)
|
98
|
+
rubocop (~> 1.0)
|
99
|
+
rubocop-ast (>= 1.1.0)
|
93
100
|
ruby-progressbar (1.10.1)
|
94
|
-
|
101
|
+
ruby2_keywords (0.0.4)
|
95
102
|
typhoeus (1.4.0)
|
96
103
|
ethon (>= 0.9.0)
|
97
|
-
tzinfo (
|
98
|
-
|
104
|
+
tzinfo (2.0.4)
|
105
|
+
concurrent-ruby (~> 1.0)
|
99
106
|
unicode-display_width (1.7.0)
|
100
|
-
zeitwerk (2.
|
107
|
+
zeitwerk (2.4.2)
|
101
108
|
|
102
109
|
PLATFORMS
|
103
110
|
ruby
|
data/lib/restful_resource.rb
CHANGED
@@ -8,12 +8,14 @@ require 'faraday_cdn_metrics'
|
|
8
8
|
require 'faraday/encoding'
|
9
9
|
require 'active_support'
|
10
10
|
require 'active_support/all'
|
11
|
-
require 'resolv-replace
|
11
|
+
require 'resolv-replace'
|
12
|
+
require_relative 'restful_resource/deprecator'
|
12
13
|
require_relative 'restful_resource/version'
|
13
14
|
require_relative 'restful_resource/null_logger'
|
14
15
|
require_relative 'restful_resource/paginated_array'
|
15
16
|
require_relative 'restful_resource/parameter_missing_error'
|
16
17
|
require_relative 'restful_resource/resource_id_missing_error'
|
18
|
+
require_relative 'restful_resource/strict_open_struct'
|
17
19
|
require_relative 'restful_resource/open_object'
|
18
20
|
require_relative 'restful_resource/response'
|
19
21
|
require_relative 'restful_resource/request'
|
@@ -34,58 +34,58 @@ 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
|
-
response = http.get(member_url(id, params_without_options), **options)
|
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)
|
60
|
-
response = http.delete(member_url(id, params_without_options), **options)
|
59
|
+
params_without_options, options = format_params(**params)
|
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
|
-
url = member_url(id, params_without_options)
|
68
|
+
url = member_url(id, **params_without_options)
|
69
69
|
|
70
70
|
response = http.patch(url, data: data, headers: headers, **options)
|
71
71
|
new(parse_json(response.body))
|
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
|
-
url = member_url(id, params_without_options)
|
78
|
+
url = member_url(id, **params_without_options)
|
79
79
|
|
80
80
|
response = http.put(url, data: data, headers: headers, **options)
|
81
81
|
new(parse_json(response.body))
|
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)
|
@@ -158,7 +154,7 @@ module RestfulResource
|
|
158
154
|
raise ResourceIdMissingError if id.blank?
|
159
155
|
|
160
156
|
url = merge_url_paths(base_url, @resource_path, CGI.escape(id.to_s), @action_prefix)
|
161
|
-
replace_parameters(url, params)
|
157
|
+
replace_parameters(url, **params)
|
162
158
|
end
|
163
159
|
|
164
160
|
def self.new_collection(json)
|
@@ -177,7 +173,7 @@ module RestfulResource
|
|
177
173
|
missing_params = []
|
178
174
|
params = params.with_indifferent_access
|
179
175
|
|
180
|
-
url_params = url.scan(
|
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?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RestfulResource
|
4
|
+
class Deprecator < ActiveSupport::Deprecation
|
5
|
+
GEM_NAME = 'restful_resource'
|
6
|
+
|
7
|
+
def self.build(horizon: 'soon')
|
8
|
+
@deprecators ||= {}
|
9
|
+
@deprecators["#{GEM_NAME}@#{horizon}"] ||= new(horizon)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(horizon)
|
13
|
+
super(horizon, GEM_NAME)
|
14
|
+
|
15
|
+
@app_deprecator = ActiveSupport::Deprecation.instance
|
16
|
+
end
|
17
|
+
|
18
|
+
# inherit the default configured behavior for the app
|
19
|
+
delegate :behavior, to: :app_deprecator
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :app_deprecator
|
24
|
+
end
|
25
|
+
end
|
@@ -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(
|
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
|
data/restful_resource.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
|
-
spec.required_ruby_version = '>= 2.4'
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler'
|
22
22
|
spec.add_development_dependency 'carwow_rubocop'
|
@@ -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
|
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
|
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(''
|
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
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
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 "
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RestfulResource::StrictOpenStruct do
|
4
|
+
let(:instance) { described_class.new(foo: 'bar') }
|
5
|
+
|
6
|
+
describe '#dig' do
|
7
|
+
it 'is deprecated' do
|
8
|
+
expect { instance.dig(:foo) }.to output(
|
9
|
+
/dig is deprecated and will be removed from restful_resource soon/
|
10
|
+
).to_stderr
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#[]' do
|
15
|
+
it 'is deprecated' do
|
16
|
+
expect { instance[:foo] }.to output(
|
17
|
+
/\[\] is deprecated and will be removed from restful_resource soon/
|
18
|
+
).to_stderr
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Santoro
|
8
8
|
- Federico Rebora
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/restful_resource/associations.rb
|
261
261
|
- lib/restful_resource/authorization.rb
|
262
262
|
- lib/restful_resource/base.rb
|
263
|
+
- lib/restful_resource/deprecator.rb
|
263
264
|
- lib/restful_resource/http_client.rb
|
264
265
|
- lib/restful_resource/instrumentation.rb
|
265
266
|
- lib/restful_resource/null_logger.rb
|
@@ -271,6 +272,7 @@ files:
|
|
271
272
|
- lib/restful_resource/request.rb
|
272
273
|
- lib/restful_resource/resource_id_missing_error.rb
|
273
274
|
- lib/restful_resource/response.rb
|
275
|
+
- lib/restful_resource/strict_open_struct.rb
|
274
276
|
- lib/restful_resource/version.rb
|
275
277
|
- restful_resource.gemspec
|
276
278
|
- spec/fixtures.rb
|
@@ -283,12 +285,13 @@ files:
|
|
283
285
|
- spec/restful_resource/rails_validations_spec.rb
|
284
286
|
- spec/restful_resource/redirections_spec.rb
|
285
287
|
- spec/restful_resource/request_spec.rb
|
288
|
+
- spec/restful_resource/strict_open_struct_spec.rb
|
286
289
|
- spec/spec_helper.rb
|
287
290
|
homepage: http://www.github.com/carwow/restful_resource
|
288
291
|
licenses:
|
289
292
|
- MIT
|
290
293
|
metadata: {}
|
291
|
-
post_install_message:
|
294
|
+
post_install_message:
|
292
295
|
rdoc_options: []
|
293
296
|
require_paths:
|
294
297
|
- lib
|
@@ -296,7 +299,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
296
299
|
requirements:
|
297
300
|
- - ">="
|
298
301
|
- !ruby/object:Gem::Version
|
299
|
-
version:
|
302
|
+
version: 2.4.0
|
300
303
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
301
304
|
requirements:
|
302
305
|
- - ">="
|
@@ -304,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
307
|
version: '0'
|
305
308
|
requirements: []
|
306
309
|
rubygems_version: 3.1.2
|
307
|
-
signing_key:
|
310
|
+
signing_key:
|
308
311
|
specification_version: 4
|
309
312
|
summary: A simple activerecord inspired rest resource base class implemented using
|
310
313
|
rest-client
|
@@ -319,4 +322,5 @@ test_files:
|
|
319
322
|
- spec/restful_resource/rails_validations_spec.rb
|
320
323
|
- spec/restful_resource/redirections_spec.rb
|
321
324
|
- spec/restful_resource/request_spec.rb
|
325
|
+
- spec/restful_resource/strict_open_struct_spec.rb
|
322
326
|
- spec/spec_helper.rb
|