ncore 3.6.2 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/example/lib/my_api/api_config.rb +1 -1
- data/lib/ncore/builder.rb +2 -2
- data/lib/ncore/client.rb +11 -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: d88aebda2989bb9112e2e0a6a90a0eb4fb6224db0563560df03fa70f602dc03d
|
4
|
+
data.tar.gz: e1933d625a8771f26a6697ad3d4d1bd34cc63c67ae69b07516b935d25389c55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29288f675a0ba7efe0a79ece9235bb793258c216a48f3874a0129aa089e4fe59eb82572aaf04a9a4810f6bd57d9bcc98b3abab00d516f3c3511ecd0edf73de07
|
7
|
+
data.tar.gz: 610ae4cdf2d632b06a4938f22c2f95dd7c2904ae9a98a12b721f6113fa99b0e67125c85fd973a346e3d128121e3f7a4324a204acf987e38a2873ede293462286
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
#### 3.7.0
|
2
|
+
|
3
|
+
- Allow request params to be or contain ActionController::Parameters
|
4
|
+
Unless MultiJson is present, this changes json generation to use the
|
5
|
+
configured encoder in ActiveSupport::JSON::Encoding.json_encoder instead
|
6
|
+
of directly using ::JSON.
|
7
|
+
- Change request header names to lowercase
|
8
|
+
- Log 404, 409, 422 responses at :debug instead of :error
|
9
|
+
|
10
|
+
#### 3.6.2
|
11
|
+
|
12
|
+
- Ensure cache key is stable
|
13
|
+
|
1
14
|
#### 3.6.1
|
2
15
|
|
3
16
|
- 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 = ''
|
@@ -153,6 +153,7 @@ module NCore
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def pool
|
156
|
+
# is actually fiber-local
|
156
157
|
Thread.current[:ncore_pool] ||= {}
|
157
158
|
end
|
158
159
|
|
@@ -171,7 +172,6 @@ module NCore
|
|
171
172
|
response = nil
|
172
173
|
begin
|
173
174
|
ActiveSupport::Notifications.instrument(instrument_key, rest_opts) do
|
174
|
-
|
175
175
|
connection = excon_client(rest_opts[:url])
|
176
176
|
begin
|
177
177
|
tries += 1
|
@@ -286,9 +286,9 @@ module NCore
|
|
286
286
|
creds.inject({}) do |h,(k,v)|
|
287
287
|
if v.present?
|
288
288
|
if k == bearer_credential_key
|
289
|
-
h[
|
289
|
+
h['authorization'] = "Bearer #{v}"
|
290
290
|
else
|
291
|
-
h["#{auth_header_prefix}-#{k}"] = v
|
291
|
+
h["#{auth_header_prefix}-#{k}"] = v
|
292
292
|
end
|
293
293
|
end
|
294
294
|
h
|
@@ -325,6 +325,7 @@ module NCore
|
|
325
325
|
|
326
326
|
def debug_response(response)
|
327
327
|
return unless logger.debug?
|
328
|
+
headers = response.headers.transform_keys(&:downcase)
|
328
329
|
if defined? MultiJson
|
329
330
|
json = MultiJson.load(response.body||'', symbolize_keys: false) rescue response.body
|
330
331
|
else
|
@@ -332,8 +333,8 @@ module NCore
|
|
332
333
|
end
|
333
334
|
logger << <<~DBG
|
334
335
|
RESPONSE:
|
335
|
-
#{response.
|
336
|
-
#{
|
336
|
+
#{response.status} | #{headers['content-type']} | #{response.body.size} bytes
|
337
|
+
#{headers.except('status', 'connection', 'content-length', 'content-type').map{|h,d| "#{h}: #{d}"}.join("\n ")}
|
337
338
|
#{json.pretty_inspect.split("\n").join("\n ")}
|
338
339
|
#{'-=- '*18}
|
339
340
|
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.0
|
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-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|