contentful 2.18.0 → 2.20.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 +8 -0
- data/README.md +19 -2
- data/lib/contentful/client.rb +10 -3
- data/lib/contentful/error.rb +1 -1
- data/lib/contentful/response.rb +10 -6
- data/lib/contentful/version.rb +1 -1
- metadata +5 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5b438ba31c476508694b1c294d2881789d186aa3177a35be94d17e8921a9014
|
|
4
|
+
data.tar.gz: 993a24776cff08778e8b6b473933bdf234f31f6ccdd5742c907d05a4d4f05a10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83c52658865579070c024434d1bc6ad1ca115e00c8f60f32d8354cf7b5bf71a08092ba640ab109f98d0a84b3853347741628cc9a1202a5f893fe45c98d22058b
|
|
7
|
+
data.tar.gz: 547b64d7a90788e3dfae97a03b17356b5dd0f9cd6a00fdb72d4b98d742c8597b907127b2670acb1691002f1198d2afd0edc81831df924056761157e661f59edb
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 2.20.0
|
|
6
|
+
* Allow `http` gem `6.x` by widening the dependency constraint to `'> 0.8', '< 7.0'`. Resolves [#278](https://github.com/contentful/contentful.rb/issues/278).
|
|
7
|
+
* Adapted error response handling for `http` 6.x: status codes are now coerced to integers for class lookup (`HTTP::Response::Status` no longer inherits from `Delegator`), and the rate-limit reset header is read via `raw.headers[...]` (the `[]` delegator on `HTTP::Response` was removed).
|
|
8
|
+
|
|
9
|
+
## 2.19.0
|
|
10
|
+
* Added `http_instrumenter` configuration option to allow instrumenting HTTP requests. [#266](https://github.com/contentful/contentful.rb/pull/266)
|
|
11
|
+
* Updated `http` gem version to `> 4`
|
|
12
|
+
|
|
5
13
|
## 2.18.0
|
|
6
14
|
* Added support for Taxonomy endpoints
|
|
7
15
|
|
data/README.md
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License" />
|
|
22
22
|
</a>
|
|
23
23
|
|
|
24
|
-
<a href="https://
|
|
25
|
-
<img src="https://
|
|
24
|
+
<a href="https://github.com/contentful/contentful.rb/actions/workflows/ci.yml">
|
|
25
|
+
<img src="https://github.com/contentful/contentful.rb/actions/workflows/ci.yml/badge.svg" alt="CI">
|
|
26
26
|
</a>
|
|
27
27
|
</p>
|
|
28
28
|
|
|
@@ -369,6 +369,15 @@ client = Contentful::Client.new(
|
|
|
369
369
|
the original log_level on the logger, for example when using Rails.logger.
|
|
370
370
|
</td>
|
|
371
371
|
</tr>
|
|
372
|
+
<tr>
|
|
373
|
+
<td><code>http_instrumenter</code></td>
|
|
374
|
+
<td><code>nil</code></td>
|
|
375
|
+
<td>
|
|
376
|
+
An HTTP instrumenter object that implements the <code>HTTP::Features::Instrumentation::Instrumenter</code> interface.
|
|
377
|
+
When provided, it will be used to instrument all HTTP requests made by the client.
|
|
378
|
+
This is useful for monitoring, logging, or tracking HTTP requests.
|
|
379
|
+
</td>
|
|
380
|
+
</tr>
|
|
372
381
|
</tbody>
|
|
373
382
|
</table>
|
|
374
383
|
|
|
@@ -749,6 +758,14 @@ For more information on the internal changes present in the 2.x release, please
|
|
|
749
758
|
|
|
750
759
|
We appreciate any help on our repositories. For more details about how to contribute see our [CONTRIBUTING.md](CONTRIBUTING.md) document.
|
|
751
760
|
|
|
761
|
+
For a reproducible local setup, open this repository in its included dev container. The container installs the project dependencies automatically when it is created.
|
|
762
|
+
|
|
763
|
+
After the container is ready, run:
|
|
764
|
+
|
|
765
|
+
```bash
|
|
766
|
+
bundle exec rake rspec_rubocop
|
|
767
|
+
```
|
|
768
|
+
|
|
752
769
|
## License
|
|
753
770
|
|
|
754
771
|
This repository is published under the [MIT](LICENSE.txt) license.
|
data/lib/contentful/client.rb
CHANGED
|
@@ -44,16 +44,18 @@ module Contentful
|
|
|
44
44
|
application_name: nil,
|
|
45
45
|
application_version: nil,
|
|
46
46
|
integration_name: nil,
|
|
47
|
-
integration_version: nil
|
|
47
|
+
integration_version: nil,
|
|
48
|
+
http_instrumenter: nil
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
attr_reader :configuration, :logger, :proxy
|
|
51
52
|
|
|
52
53
|
# Wraps the actual HTTP request via proxy
|
|
53
54
|
# @private
|
|
54
|
-
def self.get_http(url, query, headers = {}, proxy = {}, timeout = {})
|
|
55
|
+
def self.get_http(url, query, headers = {}, proxy = {}, timeout = {}, instrumenter)
|
|
55
56
|
http = HTTP[headers]
|
|
56
57
|
http = http.timeout(timeout) if timeout.any?
|
|
58
|
+
http = http.use(instrumentation: { instrumenter: instrumenter }) if instrumenter
|
|
57
59
|
if proxy[:host]
|
|
58
60
|
http.via(proxy[:host], proxy[:port], proxy[:username], proxy[:password]).get(url, params: query)
|
|
59
61
|
else
|
|
@@ -92,6 +94,10 @@ module Contentful
|
|
|
92
94
|
# @option given_configuration [String] :application_version
|
|
93
95
|
# @option given_configuration [String] :integration_name
|
|
94
96
|
# @option given_configuration [String] :integration_version
|
|
97
|
+
# @option given_configuration [HTTP::Features::Instrumentation::Instrumenter, nil] :http_instrumenter
|
|
98
|
+
# An HTTP instrumenter object that implements the instrumentation interface.
|
|
99
|
+
# When provided, it will be used to instrument all HTTP requests made by the client.
|
|
100
|
+
# This is useful for monitoring, logging, or tracking HTTP requests.
|
|
95
101
|
def initialize(given_configuration = {})
|
|
96
102
|
@configuration = default_configuration.merge(given_configuration)
|
|
97
103
|
normalize_configuration!
|
|
@@ -410,7 +416,8 @@ module Contentful
|
|
|
410
416
|
request_query(request.query),
|
|
411
417
|
request_headers,
|
|
412
418
|
proxy_params,
|
|
413
|
-
timeout_params
|
|
419
|
+
timeout_params,
|
|
420
|
+
configuration[:http_instrumenter]
|
|
414
421
|
), request
|
|
415
422
|
)
|
|
416
423
|
end
|
data/lib/contentful/error.rb
CHANGED
|
@@ -149,7 +149,7 @@ module Contentful
|
|
|
149
149
|
|
|
150
150
|
# Time until next available request, in seconds.
|
|
151
151
|
def reset_time
|
|
152
|
-
@reset_time ||= @response.raw[RATE_LIMIT_RESET_HEADER_KEY]
|
|
152
|
+
@reset_time ||= @response.raw.headers[RATE_LIMIT_RESET_HEADER_KEY]
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
protected
|
data/lib/contentful/response.rb
CHANGED
|
@@ -58,31 +58,35 @@ module Contentful
|
|
|
58
58
|
parse_http_error
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
def status_code
|
|
62
|
+
raw.status.to_i
|
|
63
|
+
end
|
|
64
|
+
|
|
61
65
|
def valid_http_response?
|
|
62
|
-
[200, 201].include?(
|
|
66
|
+
[200, 201].include?(status_code)
|
|
63
67
|
end
|
|
64
68
|
|
|
65
69
|
def service_unavailable_response?
|
|
66
|
-
|
|
70
|
+
status_code == 503
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
def service_unavailable_error
|
|
70
74
|
@status = :error
|
|
71
75
|
@error_message = '503 - Service Unavailable'
|
|
72
|
-
@object = Error[
|
|
76
|
+
@object = Error[status_code].new(self)
|
|
73
77
|
end
|
|
74
78
|
|
|
75
79
|
def parse_http_error
|
|
76
80
|
@status = :error
|
|
77
|
-
@object = Error[
|
|
81
|
+
@object = Error[status_code].new(self)
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
def invalid_response?
|
|
81
|
-
[400, 404].include?(
|
|
85
|
+
[400, 404].include?(status_code)
|
|
82
86
|
end
|
|
83
87
|
|
|
84
88
|
def no_content_response?
|
|
85
|
-
raw.to_s == '' &&
|
|
89
|
+
raw.to_s == '' && status_code == 204
|
|
86
90
|
end
|
|
87
91
|
|
|
88
92
|
def parse_json!
|
data/lib/contentful/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: contentful
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Contentful GmbH (Jan Lelis)
|
|
8
8
|
- Contentful GmbH (Andreas Tiefenthaler)
|
|
9
9
|
- Contentful GmbH (David Litvak Bruno)
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: http
|
|
@@ -21,7 +20,7 @@ dependencies:
|
|
|
21
20
|
version: '0.8'
|
|
22
21
|
- - "<"
|
|
23
22
|
- !ruby/object:Gem::Version
|
|
24
|
-
version: '
|
|
23
|
+
version: '7.0'
|
|
25
24
|
type: :runtime
|
|
26
25
|
prerelease: false
|
|
27
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -31,7 +30,7 @@ dependencies:
|
|
|
31
30
|
version: '0.8'
|
|
32
31
|
- - "<"
|
|
33
32
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
33
|
+
version: '7.0'
|
|
35
34
|
- !ruby/object:Gem::Dependency
|
|
36
35
|
name: multi_json
|
|
37
36
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -286,7 +285,6 @@ homepage: https://github.com/contentful/contentful.rb
|
|
|
286
285
|
licenses:
|
|
287
286
|
- MIT
|
|
288
287
|
metadata: {}
|
|
289
|
-
post_install_message:
|
|
290
288
|
rdoc_options: []
|
|
291
289
|
require_paths:
|
|
292
290
|
- lib
|
|
@@ -301,8 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
301
299
|
- !ruby/object:Gem::Version
|
|
302
300
|
version: '0'
|
|
303
301
|
requirements: []
|
|
304
|
-
rubygems_version: 3.
|
|
305
|
-
signing_key:
|
|
302
|
+
rubygems_version: 3.6.7
|
|
306
303
|
specification_version: 4
|
|
307
304
|
summary: contentful
|
|
308
305
|
test_files: []
|