restful_resource 2.0.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/restful_resource.rb +1 -0
- data/lib/restful_resource/base.rb +24 -16
- data/lib/restful_resource/http_client.rb +71 -22
- data/lib/restful_resource/instrumentation.rb +39 -5
- data/lib/restful_resource/rails_validations.rb +26 -33
- data/lib/restful_resource/redirections.rb +4 -4
- data/lib/restful_resource/request.rb +10 -6
- data/lib/restful_resource/version.rb +1 -1
- data/restful_resource.gemspec +1 -0
- data/spec/restful_resource/http_client_configuration_spec.rb +1 -0
- data/spec/spec_helper.rb +19 -11
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78cdc6fe007f825644ca02011bd4331d3d5f2087
|
4
|
+
data.tar.gz: dd4d619d9d2f4a0e020824de651f58a5f339cf84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4876da8d8cd7a11501035d975e7511d1481d19c2f40a5423c9c10fbb5331ed963da3607461003677df03f8e138375584a8a9c86a0086a029f3365553f870befe
|
7
|
+
data.tar.gz: eb793fe38f0e1fdddf30f49d695b5bd9cf05e92cc74a7ed16a8651d624655137d75480650b5662cbc01a37d2561f789daebc997b92da8e0b6354afb6a426245e
|
data/CHANGELOG.md
CHANGED
data/lib/restful_resource.rb
CHANGED
@@ -23,44 +23,50 @@ module RestfulResource
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.find(id, params={})
|
26
|
-
|
26
|
+
params_without_options, options = format_params(params)
|
27
27
|
|
28
|
-
response = http.get(member_url(id,
|
28
|
+
response = http.get(member_url(id, params_without_options), **options)
|
29
29
|
self.new(parse_json(response.body))
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.where(params={})
|
33
|
-
|
33
|
+
params_without_options, options = format_params(params)
|
34
34
|
|
35
|
-
url = collection_url(
|
36
|
-
response = http.get(url,
|
35
|
+
url = collection_url(params_without_options)
|
36
|
+
response = http.get(url, **options)
|
37
37
|
self.paginate_response(response)
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.get(params = {})
|
41
|
-
|
41
|
+
params_without_options, options = format_params(params)
|
42
42
|
|
43
|
-
response = http.get(collection_url(
|
43
|
+
response = http.get(collection_url(params_without_options), **options)
|
44
44
|
self.new(parse_json(response.body))
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.delete(id, **params)
|
48
|
-
|
49
|
-
|
50
|
-
response = http.delete(member_url(id, params), headers: headers)
|
48
|
+
params_without_options, options = format_params(params)
|
49
|
+
response = http.delete(member_url(id, params_without_options), **options)
|
51
50
|
RestfulResource::OpenObject.new(parse_json(response.body))
|
52
51
|
end
|
53
52
|
|
54
53
|
def self.put(id, data: {}, headers: {}, **params)
|
55
|
-
|
56
|
-
|
54
|
+
params_without_options, options = format_params(params)
|
55
|
+
options.delete(:headers)
|
56
|
+
|
57
|
+
url = member_url(id, params_without_options)
|
58
|
+
|
59
|
+
response = http.put(url, data: data, headers: headers, **options)
|
57
60
|
self.new(parse_json(response.body))
|
58
61
|
end
|
59
62
|
|
60
63
|
def self.post(data: {}, headers: {}, **params)
|
61
|
-
|
64
|
+
params_without_options, options = format_params(params)
|
65
|
+
options.delete(:headers)
|
66
|
+
|
67
|
+
url = collection_url(params_without_options)
|
62
68
|
|
63
|
-
response = http.post(url, data: data, headers: headers)
|
69
|
+
response = http.post(url, data: data, headers: headers, **options)
|
64
70
|
|
65
71
|
self.new(parse_json(response.body))
|
66
72
|
end
|
@@ -113,12 +119,14 @@ module RestfulResource
|
|
113
119
|
|
114
120
|
private
|
115
121
|
|
116
|
-
def self.
|
122
|
+
def self.format_params(params = {})
|
117
123
|
headers = params.delete(:headers) || {}
|
118
124
|
|
119
125
|
headers.merge!(cache_control: 'no-cache') if params.delete(:no_cache)
|
126
|
+
open_timeout = params.delete(:open_timeout)
|
127
|
+
timeout = params.delete(:timeout)
|
120
128
|
|
121
|
-
[params, headers]
|
129
|
+
[params, headers: headers, open_timeout: open_timeout, timeout: timeout]
|
122
130
|
end
|
123
131
|
|
124
132
|
def self.merge_url_paths(uri, *paths)
|
@@ -65,15 +65,21 @@ module RestfulResource
|
|
65
65
|
logger: nil,
|
66
66
|
cache_store: nil,
|
67
67
|
connection: nil,
|
68
|
-
instrumentation: {}
|
69
|
-
|
70
|
-
|
71
|
-
api_name = instrumentation[:api_name]
|
72
|
-
instrumentation[:request_instrument_name]
|
73
|
-
instrumentation[:cache_instrument_name]
|
68
|
+
instrumentation: {},
|
69
|
+
open_timeout: 2,
|
70
|
+
timeout: 10)
|
71
|
+
api_name = instrumentation[:api_name] ||= 'api'
|
72
|
+
instrumentation[:request_instrument_name] ||= "http.#{api_name}"
|
73
|
+
instrumentation[:cache_instrument_name] ||= "http_cache.#{api_name}"
|
74
|
+
instrumentation[:server_cache_instrument_name] ||= "cdn_metrics.#{api_name}"
|
74
75
|
|
75
76
|
if instrumentation[:metric_class]
|
76
|
-
@metrics = Instrumentation.new(instrumentation.slice(:app_name,
|
77
|
+
@metrics = Instrumentation.new(instrumentation.slice(:app_name,
|
78
|
+
:api_name,
|
79
|
+
:request_instrument_name,
|
80
|
+
:cache_instrument_name,
|
81
|
+
:server_cache_instrument_name,
|
82
|
+
:metric_class))
|
77
83
|
@metrics.subscribe_to_notifications
|
78
84
|
end
|
79
85
|
|
@@ -82,36 +88,74 @@ module RestfulResource
|
|
82
88
|
cache_store: cache_store,
|
83
89
|
instrumenter: ActiveSupport::Notifications,
|
84
90
|
request_instrument_name: instrumentation.fetch(:request_instrument_name, nil),
|
85
|
-
cache_instrument_name: instrumentation.fetch(:cache_instrument_name, nil)
|
91
|
+
cache_instrument_name: instrumentation.fetch(:cache_instrument_name, nil),
|
92
|
+
server_cache_instrument_name: instrumentation.fetch(:server_cache_instrument_name, nil))
|
86
93
|
|
87
|
-
if username && password
|
88
|
-
|
89
|
-
|
94
|
+
@connection.basic_auth(username, password) if username && password
|
95
|
+
@default_open_timeout = open_timeout
|
96
|
+
@default_timeout = timeout
|
90
97
|
end
|
91
98
|
|
92
|
-
def get(url, headers: {})
|
93
|
-
http_request(
|
99
|
+
def get(url, headers: {}, open_timeout: nil, timeout: nil)
|
100
|
+
http_request(
|
101
|
+
Request.new(
|
102
|
+
:get,
|
103
|
+
url,
|
104
|
+
headers: headers,
|
105
|
+
open_timeout: open_timeout,
|
106
|
+
timeout: timeout
|
107
|
+
)
|
108
|
+
)
|
94
109
|
end
|
95
110
|
|
96
|
-
def delete(url, headers: {})
|
97
|
-
http_request(
|
111
|
+
def delete(url, headers: {}, open_timeout: nil, timeout: nil)
|
112
|
+
http_request(
|
113
|
+
Request.new(
|
114
|
+
:delete,
|
115
|
+
url,
|
116
|
+
headers: headers,
|
117
|
+
open_timeout: open_timeout,
|
118
|
+
timeout: timeout
|
119
|
+
)
|
120
|
+
)
|
98
121
|
end
|
99
122
|
|
100
|
-
def put(url, data: {}, headers: {})
|
101
|
-
http_request(
|
123
|
+
def put(url, data: {}, headers: {}, open_timeout: nil, timeout: nil)
|
124
|
+
http_request(
|
125
|
+
Request.new(
|
126
|
+
:put,
|
127
|
+
url,
|
128
|
+
body: data,
|
129
|
+
headers: headers,
|
130
|
+
open_timeout: open_timeout,
|
131
|
+
timeout: timeout
|
132
|
+
)
|
133
|
+
)
|
102
134
|
end
|
103
135
|
|
104
|
-
def post(url, data: {}, headers: {})
|
105
|
-
http_request(
|
136
|
+
def post(url, data: {}, headers: {}, open_timeout: nil, timeout: nil)
|
137
|
+
http_request(
|
138
|
+
Request.new(
|
139
|
+
:post,
|
140
|
+
url,
|
141
|
+
body: data,
|
142
|
+
headers: headers,
|
143
|
+
open_timeout: open_timeout,
|
144
|
+
timeout: timeout
|
145
|
+
)
|
146
|
+
)
|
106
147
|
end
|
107
148
|
|
108
149
|
private
|
109
150
|
|
151
|
+
attr_reader :default_open_timeout, :default_timeout
|
152
|
+
|
110
153
|
def initialize_connection(logger: nil,
|
111
154
|
cache_store: nil,
|
112
155
|
instrumenter: nil,
|
113
156
|
request_instrument_name: nil,
|
114
|
-
cache_instrument_name: nil
|
157
|
+
cache_instrument_name: nil,
|
158
|
+
server_cache_instrument_name: nil)
|
115
159
|
|
116
160
|
@connection = Faraday.new do |b|
|
117
161
|
b.request :json
|
@@ -121,6 +165,11 @@ module RestfulResource
|
|
121
165
|
b.response :logger, logger
|
122
166
|
end
|
123
167
|
|
168
|
+
if server_cache_instrument_name
|
169
|
+
b.use :cdn_metrics, instrumenter: instrumenter,
|
170
|
+
instrument_name: server_cache_instrument_name
|
171
|
+
end
|
172
|
+
|
124
173
|
if cache_store
|
125
174
|
b.use :http_cache, store: cache_store,
|
126
175
|
logger: logger,
|
@@ -141,8 +190,8 @@ module RestfulResource
|
|
141
190
|
|
142
191
|
def http_request(request)
|
143
192
|
response = @connection.send(request.method) do |req|
|
144
|
-
req.options.open_timeout =
|
145
|
-
req.options.timeout =
|
193
|
+
req.options.open_timeout = request.open_timeout || default_open_timeout # seconds
|
194
|
+
req.options.timeout = request.timeout || default_timeout # seconds
|
146
195
|
|
147
196
|
req.body = request.body unless request.body.nil?
|
148
197
|
req.url request.url
|
@@ -3,15 +3,17 @@ require 'active_support/notifications'
|
|
3
3
|
module RestfulResource
|
4
4
|
class Instrumentation
|
5
5
|
|
6
|
-
def initialize(app_name:, api_name:, request_instrument_name:, cache_instrument_name:, metric_class:)
|
6
|
+
def initialize(app_name:, api_name:, request_instrument_name:, cache_instrument_name:, server_cache_instrument_name:, metric_class:)
|
7
7
|
@app_name = app_name
|
8
8
|
@api_name = api_name
|
9
9
|
@request_instrument_name = request_instrument_name
|
10
10
|
@cache_instrument_name = cache_instrument_name
|
11
|
+
@server_cache_instrument_name = server_cache_instrument_name
|
11
12
|
@metric_class = metric_class
|
12
13
|
end
|
13
14
|
|
14
|
-
attr_reader :app_name, :api_name, :request_instrument_name, :cache_instrument_name,
|
15
|
+
attr_reader :app_name, :api_name, :request_instrument_name, :cache_instrument_name,
|
16
|
+
:server_cache_instrument_name, :metric_class
|
15
17
|
|
16
18
|
def subscribe_to_notifications
|
17
19
|
validate_metric_class!
|
@@ -62,6 +64,39 @@ module RestfulResource
|
|
62
64
|
metric_class.count cache_notifier_namespace(metric: 'cache_bypass', event: event), 1
|
63
65
|
end
|
64
66
|
end
|
67
|
+
|
68
|
+
# Subscribes to events from Faraday::Cdn::Metrics
|
69
|
+
ActiveSupport::Notifications.subscribe server_cache_instrument_name do |*args|
|
70
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
71
|
+
client_cache_status = event.payload.fetch(:client_cache_status, nil)
|
72
|
+
server_cache_status = event.payload.fetch(:server_cache_status, nil)
|
73
|
+
|
74
|
+
if client_cache_status.nil? || !client_cache_status.in?([:fresh, :valid])
|
75
|
+
# Outputs log lines like:
|
76
|
+
# count#quotes_site.research_site_api.server_cache_hit=1
|
77
|
+
# count#quotes_site.research_site_api.api_v2_cap_derivatives.server_cache_hit=1
|
78
|
+
case server_cache_status
|
79
|
+
when :fresh
|
80
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_hit'), 1
|
81
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_hit', event: event), 1
|
82
|
+
when :valid
|
83
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_hit_while_revalidate'), 1
|
84
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_hit_while_revalidate', event: event), 1
|
85
|
+
when :invalid, :miss
|
86
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_miss'), 1
|
87
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_miss', event: event), 1
|
88
|
+
when :unacceptable
|
89
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_not_cacheable'), 1
|
90
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_not_cacheable', event: event), 1
|
91
|
+
when :bypass
|
92
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_bypass'), 1
|
93
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_bypass', event: event), 1
|
94
|
+
when :unknown
|
95
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_unknown'), 1
|
96
|
+
metric_class.count cache_notifier_namespace(metric: 'server_cache_unknown', event: event), 1
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
65
100
|
end
|
66
101
|
|
67
102
|
def validate_metric_class!
|
@@ -75,9 +110,9 @@ module RestfulResource
|
|
75
110
|
[app_name, api_name, base_request_path(event), metric].compact.join('.')
|
76
111
|
end
|
77
112
|
|
78
|
-
# Converts a path like "/api/v2/cap_derivatives/75423" to "
|
113
|
+
# Converts a path like "/api/v2/cap_derivatives/75423/with_colours" to "api_v2_cap_derivatives_with_colours"
|
79
114
|
def base_request_path(event)
|
80
|
-
path_from_event(event).split('/').drop(1).
|
115
|
+
path_from_event(event).split('/').drop(1).select {|a| a.match(/\d+/).nil? }.join('_') if event
|
81
116
|
end
|
82
117
|
|
83
118
|
def path_from_event(event)
|
@@ -93,4 +128,3 @@ module RestfulResource
|
|
93
128
|
end
|
94
129
|
end
|
95
130
|
end
|
96
|
-
|
@@ -1,48 +1,41 @@
|
|
1
1
|
module RestfulResource
|
2
2
|
module RailsValidations
|
3
3
|
module ClassMethods
|
4
|
-
def put(id, data: {},
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
result = data.merge(errors: errors)
|
14
|
-
end
|
15
|
-
result = result.merge(id: id)
|
16
|
-
self.new(result)
|
4
|
+
def put(id, data: {}, **)
|
5
|
+
super
|
6
|
+
rescue HttpClient::UnprocessableEntity => e
|
7
|
+
errors = parse_json(e.response.body)
|
8
|
+
result = nil
|
9
|
+
if errors.is_a?(Hash) && errors.has_key?('errors')
|
10
|
+
result = data.merge(errors)
|
11
|
+
else
|
12
|
+
result = data.merge(errors: errors)
|
17
13
|
end
|
14
|
+
result = result.merge(id: id)
|
15
|
+
self.new(result)
|
18
16
|
end
|
19
17
|
|
20
|
-
def post(data: {},
|
21
|
-
with_validations(data: data)
|
22
|
-
super(data: data, headers: {}, **params)
|
23
|
-
end
|
18
|
+
def post(data: {}, **)
|
19
|
+
with_validations(data: data) { super }
|
24
20
|
end
|
25
21
|
|
26
|
-
def get(
|
27
|
-
with_validations
|
28
|
-
super(params)
|
29
|
-
end
|
22
|
+
def get(*)
|
23
|
+
with_validations { super }
|
30
24
|
end
|
31
25
|
|
32
26
|
private
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
self.new(result)
|
27
|
+
|
28
|
+
def with_validations(data: {})
|
29
|
+
yield
|
30
|
+
rescue HttpClient::UnprocessableEntity => e
|
31
|
+
errors = parse_json(e.response.body)
|
32
|
+
result = nil
|
33
|
+
if errors.is_a?(Hash) && errors.has_key?('errors')
|
34
|
+
result = data.merge(errors)
|
35
|
+
else
|
36
|
+
result = data.merge(errors: errors)
|
45
37
|
end
|
38
|
+
self.new(result)
|
46
39
|
end
|
47
40
|
end
|
48
41
|
|
@@ -8,10 +8,10 @@ module RestfulResource
|
|
8
8
|
module Redirections
|
9
9
|
def self.included(base)
|
10
10
|
base.instance_eval do
|
11
|
-
def post(data: {}, delay: 1.0, max_attempts: 10, headers: {}, **params)
|
11
|
+
def post(data: {}, delay: 1.0, max_attempts: 10, headers: {}, open_timeout: nil, timeout: nil, **params)
|
12
12
|
url = collection_url(params)
|
13
13
|
|
14
|
-
response = self.accept_redirected_result(response: http.post(url, data: data, headers: headers), delay: delay, max_attempts: max_attempts)
|
14
|
+
response = self.accept_redirected_result(response: http.post(url, data: data, headers: headers, open_timeout: nil, timeout: nil), delay: delay, max_attempts: max_attempts)
|
15
15
|
|
16
16
|
self.new(parse_json(response.body))
|
17
17
|
end
|
@@ -24,12 +24,12 @@ module RestfulResource
|
|
24
24
|
resource_location = response.headers[:location]
|
25
25
|
|
26
26
|
RestfulResource::Redirections.wait(delay)
|
27
|
-
new_response = http.get(resource_location, headers: {})
|
27
|
+
new_response = http.get(resource_location, headers: {}, open_timeout: nil, timeout: nil)
|
28
28
|
|
29
29
|
while (new_response.status == 202) && (attempts < max_attempts)
|
30
30
|
attempts += 1
|
31
31
|
RestfulResource::Redirections.wait(delay)
|
32
|
-
new_response = http.get(resource_location, headers: {})
|
32
|
+
new_response = http.get(resource_location, headers: {}, open_timeout: nil, timeout: nil)
|
33
33
|
end
|
34
34
|
|
35
35
|
if attempts == max_attempts
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module RestfulResource
|
2
2
|
class Request
|
3
|
-
attr_reader :body, :method, :url
|
3
|
+
attr_reader :body, :method, :url, :open_timeout, :timeout
|
4
4
|
|
5
|
-
def initialize(method, url, headers: {}, body: nil)
|
6
|
-
@method
|
5
|
+
def initialize(method, url, headers: {}, body: nil, open_timeout: nil, timeout: nil)
|
6
|
+
@method = method
|
7
|
+
@url = url
|
8
|
+
@headers = headers
|
9
|
+
@body = body
|
10
|
+
@open_timeout = open_timeout
|
11
|
+
@timeout = timeout
|
7
12
|
end
|
8
13
|
|
9
14
|
def headers
|
@@ -14,9 +19,8 @@ module RestfulResource
|
|
14
19
|
|
15
20
|
# Formats all keys in Word-Word format
|
16
21
|
def format_headers
|
17
|
-
@headers.stringify_keys.
|
18
|
-
|
19
|
-
h
|
22
|
+
@headers.stringify_keys.each_with_object({}) do |key_with_value, headers|
|
23
|
+
headers[format_key(key_with_value.first)] = key_with_value.last
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
data/restful_resource.gemspec
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,39 +9,47 @@ RSpec.configure do |config|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
|
12
|
-
def expect_get(url, response, headers: {})
|
13
|
-
expect(@mock_http).to receive(:get)
|
12
|
+
def expect_get(url, response, headers: {}, open_timeout: nil, timeout: nil)
|
13
|
+
expect(@mock_http).to receive(:get)
|
14
|
+
.with(url, headers: headers, open_timeout: open_timeout, timeout: timeout)
|
15
|
+
.and_return(response)
|
14
16
|
end
|
15
17
|
|
16
|
-
def expect_delete(url, response, headers: {})
|
17
|
-
expect(@mock_http).to receive(:delete)
|
18
|
+
def expect_delete(url, response, headers: {}, open_timeout: nil, timeout: nil)
|
19
|
+
expect(@mock_http).to receive(:delete)
|
20
|
+
.with(url, headers: headers, open_timeout: open_timeout, timeout: timeout)
|
21
|
+
.and_return(response)
|
18
22
|
end
|
19
23
|
|
20
|
-
def expect_put(url, response, data: {}, headers: {})
|
21
|
-
expect(@mock_http).to receive(:put)
|
24
|
+
def expect_put(url, response, data: {}, headers: {}, open_timeout: nil, timeout: nil)
|
25
|
+
expect(@mock_http).to receive(:put)
|
26
|
+
.with(url, data: data, headers: headers, open_timeout: open_timeout, timeout: timeout)
|
27
|
+
.and_return(response)
|
22
28
|
end
|
23
29
|
|
24
|
-
def expect_post(url, response, data: {}, headers: {})
|
25
|
-
expect(@mock_http).to receive(:post)
|
30
|
+
def expect_post(url, response, data: {}, headers: {}, open_timeout: nil, timeout: nil)
|
31
|
+
expect(@mock_http).to receive(:post)
|
32
|
+
.with(url, data: data, headers: headers, open_timeout: open_timeout, timeout: timeout)
|
33
|
+
.and_return(response)
|
26
34
|
end
|
27
35
|
|
28
36
|
def expect_get_with_unprocessable_entity(url, response)
|
29
37
|
request = RestfulResource::Request.new(:get, url)
|
30
38
|
rest_client_response = OpenStruct.new({body: response.body, headers: response.headers, code: response.status})
|
31
39
|
exception = RestfulResource::HttpClient::UnprocessableEntity.new(request, rest_client_response)
|
32
|
-
expect(@mock_http).to receive(:get).with(url, headers: {}).and_raise(exception)
|
40
|
+
expect(@mock_http).to receive(:get).with(url, headers: {}, open_timeout: nil, timeout: nil).and_raise(exception)
|
33
41
|
end
|
34
42
|
|
35
43
|
def expect_put_with_unprocessable_entity(url, response, data: {})
|
36
44
|
request = RestfulResource::Request.new(:put, url, body: data)
|
37
45
|
rest_client_response = OpenStruct.new({body: response.body, headers: response.headers, code: response.status})
|
38
46
|
exception = RestfulResource::HttpClient::UnprocessableEntity.new(request, rest_client_response)
|
39
|
-
expect(@mock_http).to receive(:put).with(url, data: data, headers: {}).and_raise(exception)
|
47
|
+
expect(@mock_http).to receive(:put).with(url, data: data, headers: {}, open_timeout: nil, timeout: nil).and_raise(exception)
|
40
48
|
end
|
41
49
|
|
42
50
|
def expect_post_with_unprocessable_entity(url, response, data: {})
|
43
51
|
request = RestfulResource::Request.new(:put, url, body: data)
|
44
52
|
rest_client_response = OpenStruct.new({body: response.body, headers: response.headers, code: response.status})
|
45
53
|
exception = RestfulResource::HttpClient::UnprocessableEntity.new(request, rest_client_response)
|
46
|
-
expect(@mock_http).to receive(:post).with(url, data: data, headers: {}).and_raise(exception)
|
54
|
+
expect(@mock_http).to receive(:post).with(url, data: data, headers: {}, open_timeout: nil, timeout: nil).and_raise(exception)
|
47
55
|
end
|
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.0
|
4
|
+
version: 2.2.0
|
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: 2017-10-
|
12
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -179,6 +179,20 @@ dependencies:
|
|
179
179
|
- - ">="
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: faraday-cdn-metrics
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
type: :runtime
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
182
196
|
description: A simple activerecord inspired rest resource base class implemented using
|
183
197
|
rest-client
|
184
198
|
email:
|