filemaker 0.0.2 → 0.0.5
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/README.md +21 -8
- data/filemaker.gemspec +1 -1
- data/lib/filemaker/model/criteria.rb +1 -1
- data/lib/filemaker/model/selectable.rb +2 -2
- data/lib/filemaker/railtie.rb +2 -2
- data/lib/filemaker/record.rb +1 -0
- data/lib/filemaker/server.rb +1 -1
- data/lib/filemaker/version.rb +1 -1
- data/spec/filemaker/model/criteria_spec.rb +15 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 313d37cb07a852df689318962b7161ef284e513d
|
4
|
+
data.tar.gz: a756e6010205d399622e87ec6c701645b817da90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc6aba202bd692e1a6502b16a7c867cee392e15bccd595e1d171f30063daf88b9c5e987e8d7286ac6b8b48a1bd6fb14abfb2f975fc11247c07901c97ba4b5cd7
|
7
|
+
data.tar.gz: 572d07b1406c44351d15cffd124d8b044a81b1c2aba5c05d7e6e6e8c8ced8574d75c2968e1d3282b2d32d601be89fcb8daeadfbf9ed0083aff9353c35a58a72c
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Configuration for initializing a server:
|
|
24
24
|
* `account` - Please use `ENV` variable like `ENV['FILEMAKER_ACCOUNT']`
|
25
25
|
* `password` - Please use `ENV` variable like `ENV['FILEMAKER_PASSWORD']`
|
26
26
|
* `ssl` - Use `{ verify: false }` if you are using FileMaker's unsigned certificate. You can also pass a hash which will be forwarded to Faraday directly like `ssl: { client_cert: '', client_key: '', ca_file: '', ca_path: '/path/to/certs', cert_store: '' }`. See [Setting up SSL certificates on the Faraday wiki](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
|
27
|
-
* `log` - A choice of `:simple`, `:curl` and `:curl_auth`.
|
27
|
+
* `log` - A choice of `:simple`, `:curl` and `:curl_auth`.
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
server = Filemaker::Server.new do |config|
|
@@ -65,20 +65,30 @@ Most API will be smart enough to reject invalid query parameters if passed in in
|
|
65
65
|
|
66
66
|
If you want ActiveModel-like access with a decent query DSL like `where`, `find`, `in`, you can include `Filemaker::Model` to your model. Your Rails form will work as well as JSON serialization.
|
67
67
|
|
68
|
+
The following data types can be used to register the fields: `string`, `integer`, `money`, `date` and `datetime`. If the field name has spaces, you can use `fm_name` to identify the real FileMaker field name.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
string :job_id, fm_name: 'JobOrderID', identity: true
|
72
|
+
```
|
73
|
+
|
74
|
+
You can also use 3 relations: `has_many`, `belongs_to` and `has_portal`.
|
75
|
+
|
76
|
+
`has_many` will refer to the model's own identity as the reference key while `belongs_to` will append `_id` for the reference key.
|
77
|
+
|
68
78
|
```ruby
|
69
79
|
class Job
|
70
80
|
include Filemaker::Model
|
71
81
|
|
72
82
|
database :jobs
|
73
83
|
layout :job
|
74
|
-
|
84
|
+
|
75
85
|
paginates_per 50
|
76
86
|
|
77
87
|
# Taken from filemaker.yml config file, default to :default
|
78
88
|
# Only use registry if you have multiple FileMaker servers you want to connect
|
79
89
|
registry :read_slave
|
80
90
|
|
81
|
-
string :job_id, fm_name: 'JobOrderID',
|
91
|
+
string :job_id, fm_name: 'JobOrderID', identity: true
|
82
92
|
string :title, :requirements
|
83
93
|
datetime :created_at
|
84
94
|
datetime :published_at, fm_name: 'ModifiedDate'
|
@@ -96,9 +106,9 @@ end
|
|
96
106
|
|
97
107
|
development:
|
98
108
|
default:
|
99
|
-
host:
|
100
|
-
account_name: ENV['FILEMAKER_ACCOUNT_NAME']
|
101
|
-
password: ENV['FILEMAKER_PASSWORD']
|
109
|
+
host: <%= ENV['FILEMAKER_HOSTNAME'] %>
|
110
|
+
account_name: <%= ENV['FILEMAKER_ACCOUNT_NAME'] %>
|
111
|
+
password: <%= ENV['FILEMAKER_PASSWORD'] %>
|
102
112
|
ssl: true
|
103
113
|
log: :curl
|
104
114
|
|
@@ -178,9 +188,13 @@ Model.not_in([{ name: 'Lee' }, { age: '< 40' }])
|
|
178
188
|
Model.in(nationality: %w(Singapore Malaysia)).not_in(name: 'Lee', age: '< 40')
|
179
189
|
```
|
180
190
|
|
191
|
+
Note: It is vitally important that you get the order right for mixing in the use of `in` with `not_in`. Likely you will want to do an `in` first to be inclusive and later omit using `not_in`.
|
192
|
+
|
181
193
|
- [x] Please test the above query with real data to ensure correctness!
|
182
194
|
- [x] Please test the comparison operators with keyword as well as applied to value.
|
183
195
|
- [x] Test serialization of BigDecimal and other types.
|
196
|
+
- [ ] Caching of relation models
|
197
|
+
- [ ] Test the order for `in` and `not_in` found set accuracy.
|
184
198
|
|
185
199
|
## Pagination
|
186
200
|
|
@@ -197,9 +211,8 @@ class Job
|
|
197
211
|
|
198
212
|
database :jobs
|
199
213
|
layout :job
|
200
|
-
|
201
|
-
paginates_per 50
|
202
214
|
|
215
|
+
paginates_per 50
|
203
216
|
end
|
204
217
|
|
205
218
|
Job.per_page # => 50
|
data/filemaker.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
29
29
|
spec.add_development_dependency 'rubocop'
|
30
30
|
spec.add_development_dependency 'pry-byebug'
|
31
31
|
end
|
@@ -89,7 +89,7 @@ module Filemaker
|
|
89
89
|
models = Filemaker::Model::Builder.collection(resultset, klass)
|
90
90
|
|
91
91
|
if defined?(Kaminari) && paginated
|
92
|
-
Kaminari.paginate_array(models, resultset.count)
|
92
|
+
Kaminari.paginate_array(models, total_count: resultset.count)
|
93
93
|
.page(@_page)
|
94
94
|
.per(options[:max])
|
95
95
|
else
|
@@ -46,9 +46,9 @@ module Filemaker
|
|
46
46
|
def recid(id)
|
47
47
|
return nil if id.blank?
|
48
48
|
|
49
|
-
@selector
|
49
|
+
@selector = {} # We want to clear the selector when it comes to recid
|
50
50
|
selector['-recid'] = id
|
51
|
-
chains.push(:where)
|
51
|
+
chains.push(:where) unless chains.include?(:where) # No double :where
|
52
52
|
first
|
53
53
|
end
|
54
54
|
|
data/lib/filemaker/railtie.rb
CHANGED
@@ -7,9 +7,9 @@ module Rails
|
|
7
7
|
config_file = Rails.root.join('config', 'filemaker.yml')
|
8
8
|
|
9
9
|
if config_file.file?
|
10
|
-
Filemaker.load!(config_file, Rails.env)
|
10
|
+
::Filemaker.load!(config_file, Rails.env)
|
11
11
|
else
|
12
|
-
fail Error::ConfigurationError, 'No config file provided'
|
12
|
+
fail ::Filemaker::Error::ConfigurationError, 'No config file provided'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/filemaker/record.rb
CHANGED
@@ -16,6 +16,7 @@ module Filemaker
|
|
16
16
|
@record_id = record['record-id']
|
17
17
|
@portals = HashWithIndifferentAndCaseInsensitiveAccess.new
|
18
18
|
@dirty = {} # Keep track of field modification
|
19
|
+
@ready = false
|
19
20
|
|
20
21
|
record.xpath('field').each do |field|
|
21
22
|
# `field` is Nokogiri::XML::Element
|
data/lib/filemaker/server.rb
CHANGED
@@ -182,7 +182,7 @@ module Filemaker
|
|
182
182
|
auth = " -H 'Authorization: #{@connection.headers['Authorization']}'" if \
|
183
183
|
has_auth
|
184
184
|
|
185
|
-
warn 'Pretty print like so: `curl XXX | xmllint --format -`'
|
185
|
+
# warn 'Pretty print like so: `curl XXX | xmllint --format -`'
|
186
186
|
warn "curl -XGET '#{full_url}'#{curl_ssl_option} -i#{auth}"
|
187
187
|
end
|
188
188
|
|
data/lib/filemaker/version.rb
CHANGED
@@ -41,6 +41,21 @@ describe Filemaker::Model::Criteria do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
describe 'find' do
|
45
|
+
it 'resets the selector and will not double :where' do
|
46
|
+
allow(criteria).to receive(:first).and_return(nil)
|
47
|
+
criteria.find(12)
|
48
|
+
expect(criteria.selector).to eq({ '-recid' => 12 })
|
49
|
+
expect(criteria.chains).to eq [:where]
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'will use the identity to find' do
|
53
|
+
allow(criteria).to receive(:first).and_return([])
|
54
|
+
criteria.find(22)
|
55
|
+
expect(criteria.selector).to eq({ 'ca id' => '=22' })
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
44
59
|
describe 'or' do
|
45
60
|
it 'chains `or` as logical OR option' do
|
46
61
|
criteria.where(name: 'Bob').or(email: 'bob@cern.org')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filemaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
103
|
+
version: '3.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '3.
|
110
|
+
version: '3.1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|