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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cede78f266ad81e49d80fcd0cbd423a824ebf630fafe562fc44c01544714c8e0
4
- data.tar.gz: 5d290aa99e21e9b0c4f538ff6b17078a7de9da1cf34314bf44f9a6e8de988c05
3
+ metadata.gz: 19357358bdb618c8e8f600c7a427bd7b779d17a192145e040f455403fe53e000
4
+ data.tar.gz: da2227cf47f7c920e367fdfda08bb9e0ac19e696b73930beacf98d975dac8fee
5
5
  SHA512:
6
- metadata.gz: e0b7cd1662a463f3a3a5cc938e9135f668cd137343b1256c128358efa18eb53597da2e96ac0c30616704401d7a1fdd4284bb22f8ec0d432a9221d73c9f856990
7
- data.tar.gz: ced9d235187d687d72b799fcc1d2b350ea7e8bb8440e7dece6cc9ff98170dc3aaab9c21dd4f762bfde725b17950a3ae568487bc5a2350c201fe32b9d6a8c37a6
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::JsonParse expects symbol keys
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
- rescue_with_handler(e) || raise
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, &block)
21
- rescue_from APIError::AccountError, with: with, &block
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
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "json"
4
3
  require "ostruct"
5
4
 
6
5
  module FmRest
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.rc3
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-08 00:00:00.000000000 Z
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.rc3
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.rc3
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: 1.3.1
93
+ version: '0'
94
94
  requirements: []
95
95
  rubygems_version: 3.2.3
96
96
  signing_key: