fmrest-spyke 0.18.0.rc3 → 0.18.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 +3 -0
- data/lib/fmrest/spyke/model/connection.rb +2 -2
- data/lib/fmrest/spyke/model/rescuable.rb +48 -4
- data/lib/fmrest/spyke/spyke_formatter.rb +0 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19357358bdb618c8e8f600c7a427bd7b779d17a192145e040f455403fe53e000
|
|
4
|
+
data.tar.gz: da2227cf47f7c920e367fdfda08bb9e0ac19e696b73930beacf98d975dac8fee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b00414dc29c9ec01317b47210fd4808f766fcaaa2744ed56ffd943180dd80e994c67b7749c3a619b5d1176e7c5bb3bf0b884f82517617e3e39b963e4094d84e7
|
|
7
|
+
data.tar.gz: 45ba0c02eede56150923029863a6a6301271967b8c6cde342b0ab1baf6c6089f7452f763e463138e4095a6b2b9de1178e8135b0e1d045ed00913b774780a531f
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* Defining an attribute on a model that would collide with an existing method
|
|
8
8
|
now raises an error
|
|
9
9
|
* Cleared Faraday deprecation messages on authentication methods
|
|
10
|
+
* Handle FileMaker Cloud case where HTTP 401 Unauthorized with content-type
|
|
11
|
+
text/html is returned after token expiry
|
|
12
|
+
* Add retry option to Rescuable mixin
|
|
10
13
|
* Added fmrest-ruby/VERSION to User-Agent headers
|
|
11
14
|
|
|
12
15
|
### 0.17.1
|
|
@@ -140,8 +140,8 @@ module FmRest
|
|
|
140
140
|
|
|
141
141
|
conn.use FmRest::V1::TypeCoercer, config
|
|
142
142
|
|
|
143
|
-
# FmRest::Spyke::
|
|
144
|
-
conn.response :json, parser_options: { symbolize_names: true }
|
|
143
|
+
# FmRest::Spyke::SpykeFormatter expects symbol keys
|
|
144
|
+
conn.response :json, parser_options: { symbolize_names: true }, content_type: /\bjson$/
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
@fmrest_connection = connection if memoize
|
|
@@ -3,9 +3,46 @@
|
|
|
3
3
|
module FmRest
|
|
4
4
|
module Spyke
|
|
5
5
|
module Model
|
|
6
|
+
# This mixin allows rescuing from errors raised during HTTP requests,
|
|
7
|
+
# with optional retry (useful for solving expired auth). This is based
|
|
8
|
+
# off ActiveSupport::Rescuable, with minimal added functionality. Its
|
|
9
|
+
# usage is analogous to `rescue_from` in Rails' controllers.
|
|
10
|
+
#
|
|
11
|
+
# Example usage:
|
|
12
|
+
#
|
|
13
|
+
# MyLayout < FmRest::Layout
|
|
14
|
+
# # Mix-in module
|
|
15
|
+
# include FmRest::Spyke::Model::Rescuable
|
|
16
|
+
#
|
|
17
|
+
# # Define an error handler
|
|
18
|
+
# rescue_from FmRest::APIError::SomeError, with: :report_error
|
|
19
|
+
#
|
|
20
|
+
# # Define block-based error handler
|
|
21
|
+
# rescue_from FmRest::APIError::SomeOtherError, with: -> { ... }
|
|
22
|
+
#
|
|
23
|
+
# private
|
|
24
|
+
#
|
|
25
|
+
# def report_error(exception)
|
|
26
|
+
# ErrorNotifier.notify(exception)
|
|
27
|
+
# ene
|
|
28
|
+
# end
|
|
29
|
+
#
|
|
30
|
+
# This module also extends upon ActiveSupport's implementation by
|
|
31
|
+
# allowing to request a retry of the failed request, which can be useful
|
|
32
|
+
# in situations where an auth token has expired and credentials need to
|
|
33
|
+
# be manually reset.
|
|
34
|
+
#
|
|
35
|
+
# To request a retry use `throw :retry` within the handler method.
|
|
36
|
+
#
|
|
37
|
+
# Finally, since it's the most common use case, there's a shorthand
|
|
38
|
+
# method for handling Data API authentication errors:
|
|
39
|
+
#
|
|
40
|
+
# rescue_account_error with: -> { CredentialsManager.refresh_credentials }
|
|
41
|
+
#
|
|
42
|
+
# This method will always issue a retry.
|
|
43
|
+
#
|
|
6
44
|
module Rescuable
|
|
7
45
|
extend ::ActiveSupport::Concern
|
|
8
|
-
|
|
9
46
|
include ::ActiveSupport::Rescuable
|
|
10
47
|
|
|
11
48
|
class_methods do
|
|
@@ -13,12 +50,19 @@ module FmRest
|
|
|
13
50
|
begin
|
|
14
51
|
super
|
|
15
52
|
rescue => e
|
|
16
|
-
|
|
53
|
+
catch :retry do
|
|
54
|
+
rescue_with_handler(e) || raise
|
|
55
|
+
return
|
|
56
|
+
end
|
|
57
|
+
super
|
|
17
58
|
end
|
|
18
59
|
end
|
|
19
60
|
|
|
20
|
-
def rescue_account_error(with: nil
|
|
21
|
-
rescue_from
|
|
61
|
+
def rescue_account_error(with: nil)
|
|
62
|
+
rescue_from(APIError::AccountError, with: with) do
|
|
63
|
+
yield
|
|
64
|
+
throw :retry
|
|
65
|
+
end
|
|
22
66
|
end
|
|
23
67
|
end
|
|
24
68
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fmrest-spyke
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.18.0
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pedro Carbajal
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-09-
|
|
11
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fmrest-core
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.18.0
|
|
19
|
+
version: 0.18.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.18.0
|
|
26
|
+
version: 0.18.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: spyke
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -88,9 +88,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
88
88
|
version: '0'
|
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
|
91
|
-
- - "
|
|
91
|
+
- - ">="
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
|
-
version:
|
|
93
|
+
version: '0'
|
|
94
94
|
requirements: []
|
|
95
95
|
rubygems_version: 3.2.3
|
|
96
96
|
signing_key:
|