trophonius 1.2.4.2 → 1.2.4.10
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/lib/trophonius_connection.rb +3 -4
- data/lib/trophonius_model.rb +34 -0
- data/lib/trophonius_redis_manager.rb +6 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c79101c445307adbbb319a9cf07fed8e2b0fb3ae6d17a213833452ff9252f6cd
|
4
|
+
data.tar.gz: 21e0bc3a18a443f3576699100c48cf4f1db6b9efe4a031d5c52a26c95a4cb464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfef37d5c0ddca6ac545d76ed5b62df8b8f1514f247cdf6749ab0925ac33a0d889fe6f11ba9a75985164c81e7b8ffb91c24c13df79ba53e4475aa53f3e27ec37
|
7
|
+
data.tar.gz: 6afb02d5bc0d8d8a33853ffc1eff5f1f7cceb4026a665e74f6ff01d3b7189a616e9cc127b8e9962ea8fa23abb381661d5c8dbb4602588668abf8168d2784be7d
|
@@ -70,18 +70,17 @@ module Trophonius
|
|
70
70
|
|
71
71
|
begin
|
72
72
|
parsed = JSON.parse(temp.response_body)
|
73
|
-
Error.throw_error(response['messages'][0]['code']) if parsed['messages'][0]['code'] != '0'
|
74
|
-
return parsed['response']['token']
|
75
73
|
rescue Exception => e
|
76
74
|
Error.throw_error('1631')
|
77
75
|
end
|
76
|
+
Error.throw_error(parsed['messages'][0]['code']) if parsed['messages'][0]['code'] != '0'
|
77
|
+
return parsed['response']['token']
|
78
78
|
end
|
79
79
|
|
80
80
|
##
|
81
81
|
# Returns the last received token
|
82
82
|
# @return [String] the last valid *token* used to connect with the FileMaker data api
|
83
83
|
def self.token
|
84
|
-
token = Trophonius::RedisManager.get_key(key: 'token')
|
85
84
|
return Trophonius.config.redis_connection ? Trophonius::RedisManager.get_key(key: 'token') : @token
|
86
85
|
end
|
87
86
|
|
@@ -89,7 +88,7 @@ module Trophonius
|
|
89
88
|
# Returns the receive time of the last received token
|
90
89
|
# @return [Time] Returns the receive time of the last received token
|
91
90
|
def self.last_connection
|
92
|
-
last = Trophonius::RedisManager.get_key(key: 'last_connection')
|
91
|
+
last = Trophonius.config.redis_connection ? Trophonius::RedisManager.get_key(key: 'last_connection') : nil
|
93
92
|
last = last.nil? ? nil : Time.parse(last)
|
94
93
|
Trophonius.config.redis_connection ? last : @last_connection
|
95
94
|
end
|
data/lib/trophonius_model.rb
CHANGED
@@ -32,6 +32,40 @@ module Trophonius
|
|
32
32
|
@limit = ''
|
33
33
|
end
|
34
34
|
|
35
|
+
##
|
36
|
+
# Sets up the configuration for the model.
|
37
|
+
#
|
38
|
+
# @param [Hash] configuration: the hash containing the config to setup the model correctly.
|
39
|
+
# configuration = {layout_name: "theFileMakerLayoutForThisModel", non_modifiable_fields: ["an", "array", "containing", "calculation_fields", "etc."]}
|
40
|
+
def self.config(configuration)
|
41
|
+
@configuration ||= Configuration.new
|
42
|
+
@configuration.layout_name = configuration[:layout_name]
|
43
|
+
@configuration.non_modifiable_fields = configuration[:non_modifiable_fields]
|
44
|
+
@configuration.all_fields = {}
|
45
|
+
@configuration.translations = {}
|
46
|
+
@offset = ''
|
47
|
+
@limit = ''
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# Add a has many relationship.
|
52
|
+
#
|
53
|
+
# @param [Symbol] model_name: the name of the model to build a relation with
|
54
|
+
# @param [String] primary_key: the name of the field containing the primary to build the relation over
|
55
|
+
# @param [String] foreign_key: the name of the field containing the primary to build the relation over
|
56
|
+
#
|
57
|
+
# @return [Trophonius::Model] Self
|
58
|
+
def self.has_many(model_name, primary_key:, foreign_key:)
|
59
|
+
@configuration ||= Configuration.new
|
60
|
+
@configuration.layout_name = configuration[:layout_name]
|
61
|
+
@configuration.non_modifiable_fields = configuration[:non_modifiable_fields]
|
62
|
+
@configuration.all_fields = {}
|
63
|
+
@configuration.translations = {}
|
64
|
+
@offset = ''
|
65
|
+
@limit = ''
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
35
69
|
##
|
36
70
|
# Limits the found record set.
|
37
71
|
#
|
@@ -2,10 +2,12 @@ module Trophonius
|
|
2
2
|
# the RedisManager module is used to create a (single) connection to a redis store.
|
3
3
|
module Trophonius::RedisManager
|
4
4
|
def self.connect
|
5
|
-
if
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
if Trophonius.config.redis_connection
|
6
|
+
if ENV['REDIS_URL'] && ENV['REDIS_URL'] != ''
|
7
|
+
@redis ||= Redis.new(url: ENV['REDIS_URL'])
|
8
|
+
else
|
9
|
+
@redis ||= Redis.new
|
10
|
+
end
|
9
11
|
end
|
10
12
|
return nil
|
11
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trophonius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.4.
|
4
|
+
version: 1.2.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kempen Automatisering
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 6.x
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 6.x
|
55
55
|
description: An easy to use link between Ruby (on Rails) and FileMaker using the FileMaker
|
56
56
|
Data-API.
|
57
57
|
email:
|