fmrest-spyke 0.18.0.rc2 → 0.18.0.rc3
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/orm.rb +0 -12
- data/lib/fmrest/spyke/model/script_execution.rb +64 -0
- data/lib/fmrest/spyke/model.rb +2 -0
- data/lib/fmrest/spyke/spyke_formatter.rb +13 -7
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cede78f266ad81e49d80fcd0cbd423a824ebf630fafe562fc44c01544714c8e0
|
4
|
+
data.tar.gz: 5d290aa99e21e9b0c4f538ff6b17078a7de9da1cf34314bf44f9a6e8de988c05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b7cd1662a463f3a3a5cc938e9135f668cd137343b1256c128358efa18eb53597da2e96ac0c30616704401d7a1fdd4284bb22f8ec0d432a9221d73c9f856990
|
7
|
+
data.tar.gz: ced9d235187d687d72b799fcc1d2b350ea7e8bb8440e7dece6cc9ff98170dc3aaab9c21dd4f762bfde725b17950a3ae568487bc5a2350c201fe32b9d6a8c37a6
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,11 @@
|
|
3
3
|
### 0.18.0
|
4
4
|
|
5
5
|
* Better support for portals with mismatching field qualifiers
|
6
|
+
* Better ergonomics for script execution, improved documentation
|
6
7
|
* Defining an attribute on a model that would collide with an existing method
|
7
8
|
now raises an error
|
9
|
+
* Cleared Faraday deprecation messages on authentication methods
|
10
|
+
* Added fmrest-ruby/VERSION to User-Agent headers
|
8
11
|
|
9
12
|
### 0.17.1
|
10
13
|
|
@@ -78,18 +78,6 @@ module FmRest
|
|
78
78
|
new(attributes).tap(&:save!)
|
79
79
|
end
|
80
80
|
|
81
|
-
# Requests execution of a FileMaker script.
|
82
|
-
#
|
83
|
-
# @param script_name [String] the name of the FileMaker script to
|
84
|
-
# execute
|
85
|
-
# @param param [String] an optional paramater for the script
|
86
|
-
#
|
87
|
-
def execute_script(script_name, param: nil)
|
88
|
-
params = {}
|
89
|
-
params = {"script.param" => param} unless param.nil?
|
90
|
-
request(:get, FmRest::V1::script_path(layout, script_name), params)
|
91
|
-
end
|
92
|
-
|
93
81
|
private
|
94
82
|
|
95
83
|
def extend_scope_with_fm_params(scope, prefixed: false)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FmRest
|
4
|
+
module Spyke
|
5
|
+
module Model
|
6
|
+
# This module adds and extends various ORM features in Spyke models,
|
7
|
+
# including custom query methods, remote script execution and
|
8
|
+
# exception-raising persistence methods.
|
9
|
+
#
|
10
|
+
module ScriptExecution
|
11
|
+
extend ::ActiveSupport::Concern
|
12
|
+
|
13
|
+
class_methods do
|
14
|
+
# Requests execution of a FileMaker script, returning its result
|
15
|
+
# object.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# response = MyLayout.execute("Uppercasing Script", "hello")
|
19
|
+
#
|
20
|
+
# response.result # => "HELLO"
|
21
|
+
# response.error # => "0"
|
22
|
+
# response.success? # => true
|
23
|
+
#
|
24
|
+
# @param script_name [String] the name of the FileMaker script to
|
25
|
+
# execute
|
26
|
+
# @param param [String] an optional paramater for the script
|
27
|
+
# @return [FmRest::Spyke::ScriptResult] the script result object
|
28
|
+
# containing the return value and error code
|
29
|
+
#
|
30
|
+
def execute(script_name, param = nil)
|
31
|
+
# Allow keyword argument format for compatibility with execute_script
|
32
|
+
if param.respond_to?(:has_key?) && param.has_key?(:param)
|
33
|
+
param = param[:param]
|
34
|
+
end
|
35
|
+
|
36
|
+
response = execute_script(script_name, param: param)
|
37
|
+
response.metadata.script.after
|
38
|
+
end
|
39
|
+
|
40
|
+
# Requests execution of a FileMaker script, returning the entire
|
41
|
+
# response object.
|
42
|
+
#
|
43
|
+
# The execution results will be in `response.metadata.script.after`
|
44
|
+
#
|
45
|
+
# In general you'd want to use the simpler `.execute` instead of this
|
46
|
+
# method, as it provides more direct access to the script results.
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# response = MyLayout.execute_script("My Script", param: "hello")
|
50
|
+
#
|
51
|
+
# @param script_name [String] the name of the FileMaker script to
|
52
|
+
# execute
|
53
|
+
# @param param [String] an optional paramater for the script
|
54
|
+
# @return the complete response object
|
55
|
+
#
|
56
|
+
def execute_script(script_name, param: nil)
|
57
|
+
params = param.nil? ? {} : {"script.param" => param}
|
58
|
+
request(:get, FmRest::V1::script_path(layout, script_name), params)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/fmrest/spyke/model.rb
CHANGED
@@ -11,6 +11,7 @@ require "fmrest/spyke/model/container_fields"
|
|
11
11
|
require "fmrest/spyke/model/global_fields"
|
12
12
|
require "fmrest/spyke/model/http"
|
13
13
|
require "fmrest/spyke/model/auth"
|
14
|
+
require "fmrest/spyke/model/script_execution"
|
14
15
|
|
15
16
|
module FmRest
|
16
17
|
module Spyke
|
@@ -28,6 +29,7 @@ module FmRest
|
|
28
29
|
include GlobalFields
|
29
30
|
include Http
|
30
31
|
include Auth
|
32
|
+
include ScriptExecution
|
31
33
|
|
32
34
|
autoload :Rescuable, "fmrest/spyke/model/rescuable"
|
33
35
|
end
|
@@ -6,7 +6,7 @@ require "ostruct"
|
|
6
6
|
module FmRest
|
7
7
|
module Spyke
|
8
8
|
# Metadata class to be passed to Spyke::Collection#metadata
|
9
|
-
|
9
|
+
Metadata = Struct.new(:messages, :script, :data_info) do
|
10
10
|
alias_method :scripts, :script
|
11
11
|
end
|
12
12
|
|
@@ -16,6 +16,11 @@ module FmRest
|
|
16
16
|
def returned_count; returnedCount; end
|
17
17
|
end
|
18
18
|
|
19
|
+
ScriptResult = Struct.new(:result, :error) do
|
20
|
+
def success?; error == "0"; end
|
21
|
+
def error?; !success?; end
|
22
|
+
end
|
23
|
+
|
19
24
|
# Response Faraday middleware for converting FM API's response JSON into
|
20
25
|
# Spyke's expected format
|
21
26
|
class SpykeFormatter < ::Faraday::Response::Middleware
|
@@ -119,17 +124,18 @@ module FmRest
|
|
119
124
|
|
120
125
|
[:prerequest, :presort].each do |s|
|
121
126
|
if json[:response][:"scriptError.#{s}"]
|
122
|
-
results[s] =
|
123
|
-
|
124
|
-
|
127
|
+
results[s] = ScriptResult.new(
|
128
|
+
json[:response][:"scriptResult.#{s}"],
|
129
|
+
json[:response][:"scriptError.#{s}"]
|
125
130
|
).freeze
|
126
131
|
end
|
127
132
|
end
|
128
133
|
|
134
|
+
# after/default script
|
129
135
|
if json[:response][:scriptError]
|
130
|
-
results[:after] =
|
131
|
-
|
132
|
-
|
136
|
+
results[:after] = ScriptResult.new(
|
137
|
+
json[:response][:scriptResult],
|
138
|
+
json[:response][:scriptError]
|
133
139
|
).freeze
|
134
140
|
end
|
135
141
|
|
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.rc3
|
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-08 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.rc3
|
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.rc3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spyke
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/fmrest/spyke/model/orm.rb
|
66
66
|
- lib/fmrest/spyke/model/record_id.rb
|
67
67
|
- lib/fmrest/spyke/model/rescuable.rb
|
68
|
+
- lib/fmrest/spyke/model/script_execution.rb
|
68
69
|
- lib/fmrest/spyke/model/serialization.rb
|
69
70
|
- lib/fmrest/spyke/model/uri.rb
|
70
71
|
- lib/fmrest/spyke/portal.rb
|