fmrest-spyke 0.16.0 → 0.17.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a91619fdca8717119b8b299648d3388948551e653bececb0a90a422850be0a2
4
- data.tar.gz: 9e666b8f8162522b1269a3b4d18cda8724ad7439d0398672c02d228149cb636d
3
+ metadata.gz: d90ab7cfdd1a358ceb0c8abcea9d456f3b97a1b9629346a208c72cdf9b627860
4
+ data.tar.gz: 65888738c1d5ceff390c10a86f012162b3659ca75319b9f0c70a326ba5d7178e
5
5
  SHA512:
6
- metadata.gz: 6fee0ccdc7bb75ae47f620c0cbf3da137806394225a565f5227d9a63e4ea4612b78200997dfc84594ba4eb2db84a156a28d3b05109d9dfb95f6851434bd94f6b
7
- data.tar.gz: bab901d8024b1331358325f149ebc297c206e549aba81b73187748b2f168c7eecac2409170722e7a062901317084348c4ac3811bddffa07613bf944aa0f61f00
6
+ metadata.gz: 5b5deb4e31f490766dbd17ef17c822fe38f1387c5b5e16ed7dea9d343983e470352c0be482758901ae9fe1c28e145ad8f49102e0b4aa8ff4d9f381e20e42130d
7
+ data.tar.gz: f5f500c34a809a34bc375cc62d9c7d7a39318a4172db72c2466a0fe906738406eca3c46493db7df0e1e8a1d0427cc64ee586e3134e6d53dbc8b69977adf07a69
data/CHANGELOG.md CHANGED
@@ -1,13 +1,19 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.17.0
4
+
5
+ * Added support for Claris ID token login
6
+ * Added ability to use procs in settings
7
+ * Added `Rescuable` mixin
8
+
3
9
  ### 0.16.0
4
10
 
5
- * Add `FmRest.logger=`
11
+ * Added `FmRest.logger=`
6
12
  * Handle serialization of `nil`, `true` and `false` values
7
13
 
8
14
  ### 0.15.2
9
15
 
10
- * Fix autoloading of `FmRest::Layout`
16
+ * Fixed autoloading of `FmRest::Layout`
11
17
 
12
18
  ### 0.15.0
13
19
 
@@ -23,13 +29,13 @@
23
29
 
24
30
  ### 0.13.1
25
31
 
26
- * Fix downloading of container field data from FMS19+
32
+ * Fixed downloading of container field data from FMS19+
27
33
 
28
34
  ### 0.13.0
29
35
 
30
36
  * Split `fmrest` gem into `fmrest-core` and `fmrest-spyke`. `fmrest` becomes a
31
37
  wrapper for the two new gems.
32
- * Fix bug preventing connection databases with spaces in their names.
38
+ * Fixed bug preventing connection databases with spaces in their names.
33
39
  * Improved portal support with ability to delete portal records, and better
34
40
  refreshing of portal records after saving the parent.
35
41
  * `FmRest::Spyke::Base#__record_id` and `FmRest::Spyke::Base#__mod_id` now
@@ -44,7 +50,7 @@
44
50
 
45
51
  ### 0.11.1
46
52
 
47
- * Fix a couple crashes due to missing constants
53
+ * Fixed a couple crashes due to missing constants
48
54
 
49
55
  ### 0.11.0
50
56
 
@@ -59,7 +65,7 @@
59
65
 
60
66
  ### 0.10.1
61
67
 
62
- * Fix `URI.escape` obsolete warning messages in Ruby 2.7 by replacing it with
68
+ * Fixed `URI.escape` obsolete warning messages in Ruby 2.7 by replacing it with
63
69
  `URI.encode_www_form_component`
64
70
  ([PR#40](https://github.com/beezwax/fmrest-ruby/pull/40))
65
71
 
@@ -133,20 +139,20 @@
133
139
 
134
140
  ### 0.3.2
135
141
 
136
- * Fix support for ActiveSupport < 5.2
142
+ * Fixed support for ActiveSupport < 5.2
137
143
  ([#27](https://github.com/beezwax/fmrest-ruby/issues/27))
138
144
 
139
145
  ### 0.3.0
140
146
 
141
- * Add Moneta token store
147
+ * Added Moneta token store
142
148
 
143
149
  ### 0.2.5
144
150
 
145
- * Fix crash in `fetch_container_data` when no proxy options were set
151
+ * Fixed crash in `fetch_container_data` when no proxy options were set
146
152
 
147
153
  ### 0.2.4
148
154
 
149
155
  * Use `String#=~` instead of `String#match?` for Ruby <2.4 compatibility (Fixes
150
156
  [#26](https://github.com/beezwax/fmrest-ruby/issues/26))
151
- * Deprecate `FmRest.config` in favor of `FmRest.default_connection_settings`
157
+ * Deprecated `FmRest.config` in favor of `FmRest.default_connection_settings`
152
158
  * Honor Faraday SSL and proxy settings when fetching container files
data/README.md CHANGED
@@ -125,6 +125,10 @@ The minimum required connection settings are `:host`, `:database`, `:username`
125
125
  and `:password`, but fmrest-ruby has many other options you can pass when
126
126
  setting up a connection (see [full list](#full-list-of-available-options) below).
127
127
 
128
+ If you're using FileMaker Cloud you may need to pass `:fmid_token` instead
129
+ of the regular `:username` and `:password`. See the [main document on
130
+ connecting to FileMaker Cloud](docs/FileMakerCloud.md) for more info.
131
+
128
132
  `:ssl` and `:proxy` are forwarded to the underlying
129
133
  [Faraday](https://github.com/lostisland/faraday) connection. You can use this
130
134
  to, for instance, disable SSL verification:
@@ -149,6 +153,7 @@ Option | Description | Format
149
153
  `:username` | A Data API-ready account | String | None
150
154
  `:password` | Your password | String | None
151
155
  `:account_name` | Alias of `:username` | String | None
156
+ `:fmid_token` | Claris ID token (only needed for FileMaker Cloud) | String | None
152
157
  `:ssl` | SSL options to be forwarded to Faraday | Faraday SSL options | None
153
158
  `:proxy` | Proxy options to be forwarded to Faraday | Faraday proxy options | None
154
159
  `:log` | Log JSON responses to STDOUT | Boolean | `false`
@@ -283,10 +288,12 @@ Also, if not set, your model will try to use
283
288
  #### Connection settings overlays
284
289
 
285
290
  There may be cases where you want to use a different set of connection settings
286
- depending on context. For example, if you want to use username and password
287
- provided by the user in a web application. Since `.fmrest_config`
288
- is set at the class level, changing the username/password for the model in one
289
- context would also change it in all other contexts, leading to security issues.
291
+ depending on context, or simply change the connection settings over time. For
292
+ example, if you want to use username and password provided by the user in a web
293
+ application, or if you're connecting using an expiring Claris ID token. Since
294
+ `.fmrest_config` is set at the class level, changing the username/password for
295
+ the model in one context would also change it in all other contexts, leading to
296
+ security issues.
290
297
 
291
298
  To solve this scenario, fmrest-ruby provides a way of defining thread-local and
292
299
  reversible connection settings overlays through
@@ -323,7 +330,7 @@ Requests a Data API session token using the connection settings in
323
330
 
324
331
  You normally don't need to use this method as fmrest-ruby will automatically
325
332
  request and store session tokens for you (provided that `:autologin` is
326
- `true`).
333
+ `true` in the connection settings, which it is by default).
327
334
 
328
335
  ### FmRest::Layout.logout
329
336
 
@@ -452,6 +459,41 @@ field values on the database that model is configured for.
452
459
  See the [main document on setting global field values](docs/GlobalFields.md)
453
460
  for details.
454
461
 
462
+ ### Rescuable mixin
463
+
464
+ Sometimes you may want to handle Data API errors at the model level. For
465
+ instance, if you're logging in to a file hosted by FileMaker Cloud using a
466
+ Claris ID token, and you want to be able to renew said token when it fails to
467
+ log you in. For such cases fmrest-ruby provides an off-by-default mixin called
468
+ `Rescuable` that provides convenience macros for that. If you've used Ruby on
469
+ Rails you may be familiar with its syntax from controllers. E.g.
470
+
471
+ ```ruby
472
+ class BeeBase < FmRest::Layout
473
+ include FmRest::Spyke::Model::Rescuable
474
+
475
+ rescue_from FmRest::APIError::SystemError, with: :notify_admin_of_system_error
476
+
477
+ # Shorthand for rescue_with FmRest::APIError::AccountError, ...
478
+ rescue_account_error { ClarisIDTokenManager.expire_token }
479
+
480
+ def self.notify_admin_of_system_error(e)
481
+ # Shoot an email to the FM admin...
482
+ end
483
+ end
484
+ ```
485
+
486
+ Since `Rescuable` uses `ActiveSupport::Rescuable` internally, you may want to
487
+ check [Rails'
488
+ documentation](https://api.rubyonrails.org/classes/ActiveSupport/Rescuable/ClassMethods.html)
489
+ too for details on how it works.
490
+
491
+ One caveat of using `rescue_from` is that it always catches exceptions at the
492
+ class level, so if you pass a method name to `with:` that method has to be a
493
+ class method. Also note that this will only catch exceptions raised during an
494
+ API call to the Data API server (in other words, only on actions that perform
495
+ an HTTP request).
496
+
455
497
  ## Logging
456
498
 
457
499
  If using `fmrest-spyke` with Rails then pretty log output will be set up for
@@ -510,7 +552,7 @@ FM Data API reference: https://fmhelp.filemaker.com/docs/18/en/dataapi/
510
552
  | Log in using HTTP Basic Auth | Yes | Yes |
511
553
  | Log in using OAuth | No | No |
512
554
  | Log in to an external data source | No | No |
513
- | Log in using a FileMaker ID account | No | No |
555
+ | Log in using Claris ID account | Yes | Yes |
514
556
  | Log out | Yes | Yes |
515
557
  | Get product information | Manual* | No |
516
558
  | Get database names | Manual* | No |
@@ -28,6 +28,8 @@ module FmRest
28
28
  include GlobalFields
29
29
  include Http
30
30
  include Auth
31
+
32
+ autoload :Rescuable, "fmrest/spyke/model/rescuable"
31
33
  end
32
34
  end
33
35
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FmRest
4
+ module Spyke
5
+ module Model
6
+ module Rescuable
7
+ extend ::ActiveSupport::Concern
8
+
9
+ include ::ActiveSupport::Rescuable
10
+
11
+ class_methods do
12
+ def request(*args)
13
+ begin
14
+ super
15
+ rescue => e
16
+ rescue_with_handler(e) || raise
17
+ end
18
+ end
19
+
20
+ def rescue_account_error(with: nil, &block)
21
+ rescue_from APIError::AccountError, with: with, &block
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ 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.16.0
4
+ version: 0.17.0.rc1
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-04-14 00:00:00.000000000 Z
11
+ date: 2021-07-26 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.16.0
19
+ version: 0.17.0.rc1
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.16.0
26
+ version: 0.17.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: spyke
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -64,6 +64,7 @@ files:
64
64
  - lib/fmrest/spyke/model/http.rb
65
65
  - lib/fmrest/spyke/model/orm.rb
66
66
  - lib/fmrest/spyke/model/record_id.rb
67
+ - lib/fmrest/spyke/model/rescuable.rb
67
68
  - lib/fmrest/spyke/model/serialization.rb
68
69
  - lib/fmrest/spyke/model/uri.rb
69
70
  - lib/fmrest/spyke/portal.rb
@@ -85,11 +86,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
86
  version: '0'
86
87
  required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  requirements:
88
- - - ">="
89
+ - - ">"
89
90
  - !ruby/object:Gem::Version
90
- version: '0'
91
+ version: 1.3.1
91
92
  requirements: []
92
- rubygems_version: 3.0.6
93
+ rubygems_version: 3.2.3
93
94
  signing_key:
94
95
  specification_version: 4
95
96
  summary: FileMaker Data API ORM client library