cloudflare-ruby 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7b6b2639357377a873b7f3210578d60f8166999dae878c8f0f7936ead3a4e2e
4
- data.tar.gz: 50e29bc2641f8d92eca7b3f72866245c0be6d91515bb3096993575bda1346e9e
3
+ metadata.gz: 34abbed5de44bea42cd384a2602a5d45094794aa7694e3d86b1f155c83763592
4
+ data.tar.gz: 43a0ca6645bfea99c48d4a8b77f6e6369d00e9b6ad4e768f9d2b1e95e4518aec
5
5
  SHA512:
6
- metadata.gz: eec80fb84dbd9ee66181bb557751ce430fb8921ca6111eba8866a05f5bfe33b2fc061e5b1a00ffeff426d3574e75fe18fbef1de5a075e560b66a00d88fd6c12a
7
- data.tar.gz: f7004207e8e592e0da8afc823ceda1f0dbd81ecafac5da44f4d7d592b9a8629283b2520a60e22a9080d8c1f0e418668f9311b4eb7ec43540f6120c95324b25ab
6
+ metadata.gz: 9622372146fdf8ceefe8c93613cac98ae2dc73d8f74eea67ceee0507eff17573d3dec863bdcfc90e6a59a5f607a33ae76d34821f1ec5dd7b0ed0918e6c27157e
7
+ data.tar.gz: 91d65615c93a24ba1ec205828ef937098e99cf30d63ea83acafeebf43af2b4888af496b9871eeed01f6bc0fa89508590ce27b6f6f8a0b31f236953684fc6fda3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ - **`Cloudflare::TimeoutError`** — the no-response family (read/open
6
+ timeouts, connect-level failures) now maps to its own error class
7
+ instead of the terminal base `Error`. Subclasses `ServerError`, so
8
+ consumers that retry `ServerError` self-heal through upstream slow
9
+ patches. Previously a `Net::ReadTimeout` arrived with no status,
10
+ missed the status table, and surfaced as the catch-all `Error` that
11
+ retry policies deliberately don't touch.
12
+
3
13
  ## 0.4.0
4
14
 
5
15
  - **`App.current`** — convenience that returns the App matching
@@ -51,8 +51,20 @@ module Cloudflare
51
51
  def translate_error(faraday_error)
52
52
  status = faraday_error.response_status
53
53
  body = faraday_error.response_body
54
- klass = ERROR_BY_STATUS[status] || (status && status >= 500 ? ServerError : Error)
54
+ klass = if no_response?(faraday_error)
55
+ TimeoutError
56
+ else
57
+ ERROR_BY_STATUS[status] || (status && status >= 500 ? ServerError : Error)
58
+ end
55
59
  klass.new(faraday_error.message, status: status, body: body)
56
60
  end
61
+
62
+ # Faraday::TimeoutError wraps Net::ReadTimeout; Faraday::ConnectionFailed
63
+ # wraps Net::OpenTimeout and connect-level failures. Checked before the
64
+ # status table because these carry no status at all — without this they
65
+ # would fall through to the terminal base Error.
66
+ def no_response?(faraday_error)
67
+ faraday_error.is_a?(Faraday::TimeoutError) || faraday_error.is_a?(Faraday::ConnectionFailed)
68
+ end
57
69
  end
58
70
  end
@@ -28,6 +28,12 @@ module Cloudflare
28
28
  class RateLimitError < Error; end
29
29
  class ServerError < Error; end
30
30
 
31
+ # The no-response family: read/open timeouts and connect-level failures.
32
+ # No status, no body — the upstream never answered. Subclasses ServerError
33
+ # because the remedy is the same (transient; retry), so consumers that
34
+ # retry ServerError get timeouts for free.
35
+ class TimeoutError < ServerError; end
36
+
31
37
  ERROR_BY_STATUS = {
32
38
  401 => AuthenticationError,
33
39
  403 => AuthenticationError,
@@ -30,9 +30,17 @@ module Cloudflare
30
30
  # POST /meetings/{meeting_id}/participants/{id}/token
31
31
  # Mints a fresh token for an existing participant (e.g., when their
32
32
  # previous token expired or was leaked).
33
+ #
34
+ # Unlike +update+ / +replace+, this endpoint returns only the new
35
+ # token (`{ "data": { "token": "..." } }`) — NOT the full participant
36
+ # object. We merge into +@attrs+ rather than replace via
37
+ # +set_attrs_from_response+, otherwise +id+, +custom_participant_id+,
38
+ # +name+, and friends get clobbered to nil.
33
39
  def regenerate_token
34
40
  response = request(:post, "#{member_path}/token")
35
- set_attrs_from_response(response)
41
+ inner = self.class.unwrap_envelope(response)
42
+ @attrs.merge!(inner.transform_keys(&:to_s)) if inner.is_a?(Hash)
43
+ @loaded = true
36
44
  self
37
45
  end
38
46
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudflare
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tokimonki
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 4.0.11
107
+ rubygems_version: 4.0.14
108
108
  specification_version: 4
109
109
  summary: Ruby SDK for the Cloudflare API.
110
110
  test_files: []