fmrest-spyke 0.21.0.rc1 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/CHANGELOG.md +15 -0
- data/README.md +8 -1
- data/lib/fmrest/spyke/model/orm.rb +7 -7
- data/lib/fmrest/spyke/relation.rb +17 -3
- 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: f9956beb060ba224625cbc91c6d15169fcc24002d8868c8736fa8ee474d64afc
|
4
|
+
data.tar.gz: 9991f5c849f766a9a0660c3072f2ac6cb677d311888a9d536ecbe0c0c18dfeb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b11f7d8f9e582185534aec7ba8497d2f74a371a8bc5322e4f48849ec8fe84f841bca705cf0cfb884b8f96298c677883ccaaf98e5816a7923b414a4dd6f815bc3
|
7
|
+
data.tar.gz: 41063c5e3993b525131ab84c27eda309eadfec7fe5ba4c0458605221a707e1e60ce87e3ba7f6737476e7cdb2b735fe686aeba68064b66e130b905a5d6550e3d3
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 0.23.0
|
4
|
+
|
5
|
+
* Add `find_one!` (aliased as `first!`) exception-raising method
|
6
|
+
* Add mapping of API exceptions to HTTP responses in Rails
|
7
|
+
|
8
|
+
### 0.22.0
|
9
|
+
|
10
|
+
* Add `fmrest-rails` gem with Rails integration (initializer, generators)
|
11
|
+
|
12
|
+
### 0.21.0
|
13
|
+
|
14
|
+
* Support for Spyke 7 and Faraday 2
|
15
|
+
* Drop support for Faraday 1
|
16
|
+
* Drop support for Ruby 2.5
|
17
|
+
|
3
18
|
### 0.20.0
|
4
19
|
|
5
20
|
* Forward proxy options to AWS Client when using `fmrest-cloud` gem
|
data/README.md
CHANGED
@@ -19,13 +19,14 @@ Need Ruby or FileMaker consulting? Contact us at
|
|
19
19
|
|
20
20
|
## Gems
|
21
21
|
|
22
|
-
The `fmrest` gem is a wrapper for
|
22
|
+
The `fmrest` gem is a wrapper for these gems:
|
23
23
|
|
24
24
|
* `fmrest-spyke`, providing an ActiveRecord-like ORM library built on top
|
25
25
|
of `fmrest-core` and [Spyke](https://github.com/balvig/spyke).
|
26
26
|
* `fmrest-core`, providing the core
|
27
27
|
[Faraday](https://github.com/lostisland/faraday) connection builder, session
|
28
28
|
management, and other core utilities.
|
29
|
+
* `fmrest-rails`, providing Rails integration.
|
29
30
|
|
30
31
|
In addition, the optional `fmrest-cloud` gem adds support for FileMaker Cloud.
|
31
32
|
See the [main document on connecting to FileMaker
|
@@ -42,6 +43,12 @@ gem 'fmrest'
|
|
42
43
|
gem 'fmrest-cloud'
|
43
44
|
```
|
44
45
|
|
46
|
+
If you're using Rails you can now run:
|
47
|
+
|
48
|
+
```
|
49
|
+
rails generate fmrest:config
|
50
|
+
```
|
51
|
+
|
45
52
|
## Simple example
|
46
53
|
|
47
54
|
```ruby
|
@@ -18,10 +18,6 @@ module FmRest
|
|
18
18
|
class_attribute :default_limit, instance_accessor: false, instance_predicate: false
|
19
19
|
|
20
20
|
class_attribute :default_sort, instance_accessor: false, instance_predicate: false
|
21
|
-
|
22
|
-
# Whether to raise an FmRest::APIError::NoMatchingRecordsError when a
|
23
|
-
# _find request has no results
|
24
|
-
class_attribute :raise_on_no_matching_records, instance_accessor: false, instance_predicate: false
|
25
21
|
end
|
26
22
|
|
27
23
|
class_methods do
|
@@ -42,10 +38,14 @@ module FmRest
|
|
42
38
|
# options, as well as using the appropriate HTTP method/URL depending
|
43
39
|
# on whether there's a query present in the current scope.
|
44
40
|
#
|
41
|
+
# @option options [Boolean] :raise_on_no_matching_records whether to
|
42
|
+
# raise `APIError::NoMatchingRecordsError` when no records match (FM
|
43
|
+
# error 401). If not given it returns an empty resultset.
|
44
|
+
#
|
45
45
|
# @example
|
46
46
|
# Person.query(first_name: "Stefan").fetch # -> POST .../_find
|
47
47
|
#
|
48
|
-
def fetch
|
48
|
+
def fetch(options = {})
|
49
49
|
if current_scope.has_query?
|
50
50
|
scope = extend_scope_with_fm_params(current_scope, prefixed: false)
|
51
51
|
scope = scope.where(query: scope.query_params)
|
@@ -60,9 +60,9 @@ module FmRest
|
|
60
60
|
# nothing matches a _find request, so we need to catch it in order
|
61
61
|
# to provide sane behavior (i.e. return an empty resultset)
|
62
62
|
begin
|
63
|
-
current_scope.has_query? ? scoped_request(:post) : super
|
63
|
+
current_scope.has_query? ? scoped_request(:post) : super()
|
64
64
|
rescue FmRest::APIError::NoMatchingRecordsError => e
|
65
|
-
raise e if raise_on_no_matching_records
|
65
|
+
raise e if options[:raise_on_no_matching_records]
|
66
66
|
::Spyke::Result.new({})
|
67
67
|
end
|
68
68
|
ensure
|
@@ -276,13 +276,15 @@ module FmRest
|
|
276
276
|
# Finds a single instance of the model by forcing limit = 1, or simply
|
277
277
|
# fetching the record by id if the primary key was set
|
278
278
|
#
|
279
|
+
# @option (see FmRest::Spyke::Model::ORM.fetch)
|
280
|
+
#
|
279
281
|
# @return [FmRest::Spyke::Base]
|
280
|
-
def find_one
|
282
|
+
def find_one(options = {})
|
281
283
|
@find_one ||=
|
282
284
|
if primary_key_set?
|
283
|
-
without_collection_params { super }
|
285
|
+
without_collection_params { super() }
|
284
286
|
else
|
285
|
-
klass.new_collection_from_result(limit(1).fetch).first
|
287
|
+
klass.new_collection_from_result(limit(1).fetch(options)).first
|
286
288
|
end
|
287
289
|
rescue ::Spyke::ConnectionError => error
|
288
290
|
fallback_or_reraise(error, default: nil)
|
@@ -290,6 +292,18 @@ module FmRest
|
|
290
292
|
alias_method :first, :find_one
|
291
293
|
alias_method :any, :find_one
|
292
294
|
|
295
|
+
# Same as `#find_one`, but raises `APIError::NoMatchingRecordsError` when
|
296
|
+
# no records match.
|
297
|
+
# Equivalent to calling `find_one(raise_on_no_matching_records: true)`.
|
298
|
+
#
|
299
|
+
# @option (see FmRest::Spyke::Model::ORM.fetch)
|
300
|
+
#
|
301
|
+
# @return [FmRest::Spyke::Base]
|
302
|
+
def find_one!(options = {})
|
303
|
+
find_one(options.merge(raise_on_no_matching_records: true))
|
304
|
+
end
|
305
|
+
alias_method :first!, :find_one!
|
306
|
+
|
293
307
|
# Yields each batch of records that was found by the find options.
|
294
308
|
#
|
295
309
|
# NOTE: By its nature, batch processing is subject to race conditions if
|
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.
|
4
|
+
version: 0.23.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: 2022-
|
11
|
+
date: 2022-06-24 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.
|
19
|
+
version: 0.23.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.
|
26
|
+
version: 0.23.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.3.3
|
96
96
|
signing_key:
|