ncore 3.6.2 → 3.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/example/lib/my_api/api_config.rb +1 -1
- data/lib/ncore/builder.rb +2 -2
- data/lib/ncore/client.rb +15 -10
- data/lib/ncore/client_cache.rb +1 -1
- data/lib/ncore/configuration.rb +1 -1
- data/lib/ncore/methods/delete_bulk.rb +1 -1
- data/lib/ncore/methods/update_bulk.rb +1 -1
- data/lib/ncore/rails/log_subscriber.rb +3 -1
- data/lib/ncore/util.rb +1 -1
- data/lib/ncore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c6562d9f0e6fca58cc5ad061d9461006dc509f92e960a55ed83bd127fd1d503
|
4
|
+
data.tar.gz: f61859177171d285d7442dfdee1a66964b318bb14824b7e409da2e3e27b92e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b702ea0bc616e2aabbd685ac53579759e59176865e562f383aff61682f3cb6defc5aa177ec398a0a9b18229bd8f5a78d5fc5e390f61ce722998e5301bd7dfa1
|
7
|
+
data.tar.gz: e2ab8234b5fc0358ba38f2460065dfe029ee92d59d575dbb7f35c9d5b8edb71aff8d15fb0278a50678401a71bea55705eb12bda756e4c99295430d45ae16cbee
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
#### 3.7.1
|
2
|
+
|
3
|
+
- Don't send both mixed and lowercase headers for accept, user-agent
|
4
|
+
|
5
|
+
#### 3.7.0
|
6
|
+
|
7
|
+
- Allow request params to be or contain ActionController::Parameters
|
8
|
+
Unless MultiJson is present, this changes json generation to use the
|
9
|
+
configured encoder in ActiveSupport::JSON::Encoding.json_encoder instead
|
10
|
+
of directly using ::JSON.
|
11
|
+
- Change request header names to lowercase
|
12
|
+
- Log 404, 409, 422 responses at :debug instead of :error
|
13
|
+
|
14
|
+
#### 3.6.2
|
15
|
+
|
16
|
+
- Ensure cache key is stable
|
17
|
+
|
1
18
|
#### 3.6.1
|
2
19
|
|
3
20
|
- Restore usage of Resource.new(some_attr: 'value')
|
data/lib/ncore/builder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module NCore
|
2
2
|
module Builder
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
4
|
+
|
5
5
|
included do
|
6
6
|
class_eval <<-INCL, __FILE__, __LINE__+1
|
7
7
|
include NCore::Exceptions
|
@@ -24,7 +24,7 @@ module NCore
|
|
24
24
|
|
25
25
|
class << self
|
26
26
|
def configure(&block)
|
27
|
-
Api.instance_eval
|
27
|
+
Api.instance_eval(&block)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
INCL
|
data/lib/ncore/client.rb
CHANGED
@@ -26,15 +26,15 @@ module NCore
|
|
26
26
|
|
27
27
|
path = URI.parse(url).path
|
28
28
|
if [:get, :head, :delete].include? method
|
29
|
-
qs = build_query_string params
|
29
|
+
qs = build_query_string params.as_json
|
30
30
|
url += qs
|
31
31
|
path += qs
|
32
32
|
payload = nil
|
33
33
|
else
|
34
34
|
if defined? MultiJson
|
35
|
-
payload = MultiJson.encode params
|
35
|
+
payload = MultiJson.encode params.as_json
|
36
36
|
else
|
37
|
-
payload =
|
37
|
+
payload = params.to_json
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -79,7 +79,7 @@ module NCore
|
|
79
79
|
h = {}
|
80
80
|
[default_headers, auth_headers(req_credentials), headers].each do |set|
|
81
81
|
set.each do |k,v|
|
82
|
-
k = k.to_s.tr('_','-').
|
82
|
+
k = k.to_s.tr('_','-').downcase
|
83
83
|
h[k] = v.respond_to?(:call) ? v.call : v
|
84
84
|
end
|
85
85
|
end
|
@@ -118,7 +118,7 @@ module NCore
|
|
118
118
|
|
119
119
|
# create a new excon client if necessary
|
120
120
|
# keeps a pool of the last 10 urls
|
121
|
-
# in almost all cases this will be more than enough
|
121
|
+
# in almost all cases this will be more than enough
|
122
122
|
def excon_client(uri)
|
123
123
|
u = URI.parse uri
|
124
124
|
u.path = ''
|
@@ -138,6 +138,10 @@ module NCore
|
|
138
138
|
end
|
139
139
|
ex_opts = {
|
140
140
|
connect_timeout: 10,
|
141
|
+
headers: {
|
142
|
+
'accept' => '*/*',
|
143
|
+
'user-agent' => "ncore/ruby v#{VERSION}",
|
144
|
+
},
|
141
145
|
persistent: true
|
142
146
|
}
|
143
147
|
if verify_ssl_cert?
|
@@ -153,6 +157,7 @@ module NCore
|
|
153
157
|
end
|
154
158
|
|
155
159
|
def pool
|
160
|
+
# is actually fiber-local
|
156
161
|
Thread.current[:ncore_pool] ||= {}
|
157
162
|
end
|
158
163
|
|
@@ -171,7 +176,6 @@ module NCore
|
|
171
176
|
response = nil
|
172
177
|
begin
|
173
178
|
ActiveSupport::Notifications.instrument(instrument_key, rest_opts) do
|
174
|
-
|
175
179
|
connection = excon_client(rest_opts[:url])
|
176
180
|
begin
|
177
181
|
tries += 1
|
@@ -286,9 +290,9 @@ module NCore
|
|
286
290
|
creds.inject({}) do |h,(k,v)|
|
287
291
|
if v.present?
|
288
292
|
if k == bearer_credential_key
|
289
|
-
h[
|
293
|
+
h['authorization'] = "Bearer #{v}"
|
290
294
|
else
|
291
|
-
h["#{auth_header_prefix}-#{k}"] = v
|
295
|
+
h["#{auth_header_prefix}-#{k}"] = v
|
292
296
|
end
|
293
297
|
end
|
294
298
|
h
|
@@ -325,6 +329,7 @@ module NCore
|
|
325
329
|
|
326
330
|
def debug_response(response)
|
327
331
|
return unless logger.debug?
|
332
|
+
headers = response.headers.transform_keys(&:downcase)
|
328
333
|
if defined? MultiJson
|
329
334
|
json = MultiJson.load(response.body||'', symbolize_keys: false) rescue response.body
|
330
335
|
else
|
@@ -332,8 +337,8 @@ module NCore
|
|
332
337
|
end
|
333
338
|
logger << <<~DBG
|
334
339
|
RESPONSE:
|
335
|
-
#{response.
|
336
|
-
#{
|
340
|
+
#{response.status} | #{headers['content-type']} | #{response.body.size} bytes
|
341
|
+
#{headers.except('status', 'connection', 'content-length', 'content-type').map{|h,d| "#{h}: #{d}"}.join("\n ")}
|
337
342
|
#{json.pretty_inspect.split("\n").join("\n ")}
|
338
343
|
#{'-=- '*18}
|
339
344
|
DBG
|
data/lib/ncore/client_cache.rb
CHANGED
data/lib/ncore/configuration.rb
CHANGED
@@ -7,7 +7,7 @@ module NCore
|
|
7
7
|
raise(module_parent::RecordNotFound, "ids must not be empty") if ids.blank?
|
8
8
|
params[:ids] = ids
|
9
9
|
params = parse_request_params(params)
|
10
|
-
parsed,
|
10
|
+
parsed, _creds = request(:delete, resource_path, params)
|
11
11
|
if parsed[:errors].any?
|
12
12
|
raise module_parent::BulkActionError, parsed[:errors]
|
13
13
|
else
|
@@ -7,7 +7,7 @@ module NCore
|
|
7
7
|
raise(module_parent::RecordNotFound, "ids must not be empty") if ids.blank?
|
8
8
|
params = parse_request_params(params, json_root: json_root)
|
9
9
|
params[:ids] = ids
|
10
|
-
parsed,
|
10
|
+
parsed, _creds = request(:put, resource_path, params)
|
11
11
|
if parsed[:errors].any?
|
12
12
|
raise module_parent::BulkActionError, parsed[:errors]
|
13
13
|
else
|
@@ -26,6 +26,8 @@ module NCore
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
DEBUG_STATUSES = (200..299).to_a + [404, 409, 422]
|
30
|
+
|
29
31
|
def log_request(event)
|
30
32
|
self.class.runtime += event.duration
|
31
33
|
|
@@ -45,7 +47,7 @@ module NCore
|
|
45
47
|
res = color(res, :red, bold: true)
|
46
48
|
end
|
47
49
|
|
48
|
-
if
|
50
|
+
if DEBUG_STATUSES.include? http_status
|
49
51
|
debug " #{msg}"
|
50
52
|
debug " #{res}"
|
51
53
|
else
|
data/lib/ncore/util.rb
CHANGED
data/lib/ncore/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Notioneer Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|