filemaker 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +116 -0
- data/Rakefile +6 -0
- data/diagram.png +0 -0
- data/filemaker.gemspec +30 -0
- data/lib/filemaker.rb +13 -0
- data/lib/filemaker/api.rb +13 -0
- data/lib/filemaker/api/query_commands/delete.rb +16 -0
- data/lib/filemaker/api/query_commands/dup.rb +22 -0
- data/lib/filemaker/api/query_commands/edit.rb +26 -0
- data/lib/filemaker/api/query_commands/find.rb +46 -0
- data/lib/filemaker/api/query_commands/findall.rb +34 -0
- data/lib/filemaker/api/query_commands/findany.rb +26 -0
- data/lib/filemaker/api/query_commands/findquery.rb +84 -0
- data/lib/filemaker/api/query_commands/new.rb +21 -0
- data/lib/filemaker/api/query_commands/view.rb +11 -0
- data/lib/filemaker/configuration.rb +28 -0
- data/lib/filemaker/core_ext/hash.rb +32 -0
- data/lib/filemaker/database.rb +29 -0
- data/lib/filemaker/error.rb +391 -0
- data/lib/filemaker/layout.rb +38 -0
- data/lib/filemaker/metadata/field.rb +71 -0
- data/lib/filemaker/record.rb +64 -0
- data/lib/filemaker/resultset.rb +124 -0
- data/lib/filemaker/script.rb +9 -0
- data/lib/filemaker/server.rb +197 -0
- data/lib/filemaker/store/database_store.rb +21 -0
- data/lib/filemaker/store/layout_store.rb +23 -0
- data/lib/filemaker/store/script_store.rb +23 -0
- data/lib/filemaker/version.rb +3 -0
- data/spec/filemaker/api/query_commands/compound_find_spec.rb +69 -0
- data/spec/filemaker/error_spec.rb +257 -0
- data/spec/filemaker/layout_spec.rb +229 -0
- data/spec/filemaker/metadata/field_spec.rb +62 -0
- data/spec/filemaker/record_spec.rb +47 -0
- data/spec/filemaker/resultset_spec.rb +65 -0
- data/spec/filemaker/server_spec.rb +106 -0
- data/spec/filemaker/store/database_store_spec.rb +34 -0
- data/spec/filemaker/store/layout_store_spec.rb +31 -0
- data/spec/filemaker/store/script_store_spec.rb +31 -0
- data/spec/spec_helper.rb +84 -0
- data/spec/support/responses/dbnames.xml +34 -0
- data/spec/support/responses/employment.xml +55 -0
- data/spec/support/responses/jobs.xml +199 -0
- data/spec/support/responses/layoutnames.xml +39 -0
- data/spec/support/responses/portal.xml +108 -0
- data/spec/support/responses/scriptnames.xml +29 -0
- data/spec/support/xml_loader.rb +29 -0
- metadata +227 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: da908ea60c24ec21422e5405e5c18e149825bb78
|
4
|
+
data.tar.gz: cf777449498d727f9c15ab765f5e610b292d0f8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6d6523f795649e9f2b09cc66ce21fff013586713a677b002734ffbc03eb3d5cdec949198764361d594c896851d1c7000f58e2adb28c76293091cd37b9acc029
|
7
|
+
data.tar.gz: 2b44e3649cfce1a9fa65ce5d7264f717ede0c86f63eafd695b9370deebd14f4870d2d5eb626860317e9cd5013e7f579cfa4bf64bd81125bd3ca7c38c1a49eda0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 mech
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# Filemaker
|
2
|
+
|
3
|
+
[](https://travis-ci.org/mech/filemaker-ruby)
|
4
|
+
|
5
|
+
A Ruby wrapper to FileMaker XML API.
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Put this in your Gemfile and you are ready to go:
|
12
|
+
|
13
|
+
```
|
14
|
+
gem 'filemaker'
|
15
|
+
```
|
16
|
+
|
17
|
+
## Initializing the Server
|
18
|
+
|
19
|
+
Ensure you have Web Publishing Engine (XML Publishing) enabled. Please turn on SSL also or credential will not be protected. Remember to also set the "Extended Privileges" to this keyword: `fmxml`.
|
20
|
+
|
21
|
+
Configuration for initializing a server:
|
22
|
+
|
23
|
+
* `host` - IP or hostname
|
24
|
+
* `ssl` - `{ 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](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
|
25
|
+
* `account` - Please use `ENV` variable like `ENV['FILEMAKER_ACCOUNT']`
|
26
|
+
* `password` - Please use `ENV` variable like `ENV['FILEMAKER_PASSWORD']`
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
server = Filemaker::Server.new do |config|
|
30
|
+
config.host = 'localhost'
|
31
|
+
config.account = ENV['FILEMAKER_ACCOUNT']
|
32
|
+
config.password = ENV['FILEMAKER_PASSWORD']
|
33
|
+
config.ssl = { verify: false }
|
34
|
+
config.log = :curl
|
35
|
+
end
|
36
|
+
|
37
|
+
server.databases.all # Using -dbnames
|
38
|
+
server.database['candidates'].layouts # Using -layoutnames and -db=candidates
|
39
|
+
|
40
|
+
api = server.db['candidates'].lay['profile']
|
41
|
+
api = server.db['candidates']['profile']
|
42
|
+
api = server.database['candidates'].layout['profile']
|
43
|
+
```
|
44
|
+
|
45
|
+
Once you are able to grab the `api`, you are golden and can make request to read/write to FileMaker API.
|
46
|
+
|
47
|
+
## Using the API
|
48
|
+
|
49
|
+
`Filemaker::Api::QueryCommands` is the main modules to use the API.
|
50
|
+
|
51
|
+
* `api.find()` for `-find`
|
52
|
+
* `api.findany()` for `-findany`
|
53
|
+
* `api.findquery()` for `-findquery`
|
54
|
+
* `api.new()` for `-new`
|
55
|
+
* `api.edit()` for `-edit`
|
56
|
+
* `api.delete()` for `-delete`
|
57
|
+
* `api.dup()` for `-dup`
|
58
|
+
* `api.view()` for `-view`
|
59
|
+
|
60
|
+
Most API will be smart enough to reject invalid query parameters if passed in incorrectly.
|
61
|
+
|
62
|
+
## Using Filemaker::Model
|
63
|
+
|
64
|
+
If you want ActiveModel-like access with a decent query DSL like `where`, `find`, `all`, you can include `Filemaker::Model` to your model. Your Rails form will work as well as JSON serialization.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
class Job
|
68
|
+
include Filemaker::Model
|
69
|
+
|
70
|
+
server :default # Taken from filemaker.yml config file
|
71
|
+
database :jobs
|
72
|
+
layout :job
|
73
|
+
|
74
|
+
string :title, :requirements
|
75
|
+
datetime :created_at, :published_at
|
76
|
+
|
77
|
+
validates :title, presence: true
|
78
|
+
|
79
|
+
def as_json(options = {})
|
80
|
+
options[:except] ||= [:created_at]
|
81
|
+
super(options)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
```yml
|
87
|
+
# filemaker.yml
|
88
|
+
|
89
|
+
development:
|
90
|
+
default:
|
91
|
+
host: localhost
|
92
|
+
ssl: true
|
93
|
+
```
|
94
|
+
|
95
|
+
## Query DSL
|
96
|
+
|
97
|
+
## Credits
|
98
|
+
|
99
|
+
This project is heavily inspired by the following Filemaker Ruby effort and several other ORM gems.
|
100
|
+
|
101
|
+
* [Rfm](https://github.com/lardawge/rfm)
|
102
|
+
* [ginjo/rfm](https://github.com/ginjo/rfm)
|
103
|
+
* [mongoid](https://github.com/mongoid/mongoid)
|
104
|
+
* [elasticsearch-ruby](https://github.com/elasticsearch/elasticsearch-ruby)
|
105
|
+
|
106
|
+
## Contributing
|
107
|
+
|
108
|
+
We welcome pull request with specs.
|
109
|
+
|
110
|
+
1. Fork it ( https://github.com/mech/filemaker-ruby/fork )
|
111
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
112
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
113
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
114
|
+
5. Create a new Pull Request
|
115
|
+
|
116
|
+
Do run `rubocop -D -f simple` before committing.
|
data/Rakefile
ADDED
data/diagram.png
ADDED
Binary file
|
data/filemaker.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'filemaker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'filemaker'
|
8
|
+
spec.version = Filemaker::VERSION
|
9
|
+
spec.authors = ['mech']
|
10
|
+
spec.email = ['mech@me.com']
|
11
|
+
spec.summary = 'A Ruby wrapper to FileMaker XML API.'
|
12
|
+
spec.description = 'Provides ActiveModel-like object to read and write.'
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'faraday'
|
22
|
+
spec.add_runtime_dependency 'typhoeus'
|
23
|
+
spec.add_runtime_dependency 'nokogiri'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
spec.add_development_dependency 'rubocop'
|
29
|
+
spec.add_development_dependency 'pry-byebug'
|
30
|
+
end
|
data/lib/filemaker.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'filemaker/version'
|
2
|
+
require 'filemaker/core_ext/hash'
|
3
|
+
require 'filemaker/server'
|
4
|
+
require 'filemaker/api'
|
5
|
+
require 'filemaker/database'
|
6
|
+
require 'filemaker/store/database_store'
|
7
|
+
require 'filemaker/store/layout_store'
|
8
|
+
require 'filemaker/store/script_store'
|
9
|
+
require 'filemaker/resultset'
|
10
|
+
require 'filemaker/record'
|
11
|
+
require 'filemaker/layout'
|
12
|
+
require 'filemaker/script'
|
13
|
+
require 'filemaker/error'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Dir[File.expand_path('../api/query_commands/**/*.rb', __FILE__)].each do |lib|
|
2
|
+
require lib
|
3
|
+
end
|
4
|
+
|
5
|
+
module Filemaker
|
6
|
+
module Api
|
7
|
+
module QueryCommands; end
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.send :include, Filemaker::Api::QueryCommands
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Filemaker
|
2
|
+
module Api
|
3
|
+
module QueryCommands
|
4
|
+
# Delete record.
|
5
|
+
#
|
6
|
+
# -recid
|
7
|
+
# -script
|
8
|
+
# -script.param
|
9
|
+
#
|
10
|
+
def delete(id, options = {})
|
11
|
+
valid_options(options, :script)
|
12
|
+
perform_request('-delete', { '-recid' => id }, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Filemaker
|
2
|
+
module Api
|
3
|
+
module QueryCommands
|
4
|
+
# Duplicate record.
|
5
|
+
#
|
6
|
+
# -recid
|
7
|
+
# -script
|
8
|
+
# -script.param
|
9
|
+
# -relatedsets.filter
|
10
|
+
# -relatedsets.max
|
11
|
+
#
|
12
|
+
def dup(id, options = {})
|
13
|
+
valid_options(options,
|
14
|
+
:script,
|
15
|
+
:relatedsets_filter,
|
16
|
+
:relatedsets_max)
|
17
|
+
|
18
|
+
perform_request('-dup', { '-recid' => id }, options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Filemaker
|
2
|
+
module Api
|
3
|
+
module QueryCommands
|
4
|
+
# Edit record.
|
5
|
+
#
|
6
|
+
# -recid
|
7
|
+
# -modid
|
8
|
+
# -script
|
9
|
+
# -script.param
|
10
|
+
# -relatedsets.filter
|
11
|
+
# -relatedsets.max
|
12
|
+
# -delete.related
|
13
|
+
#
|
14
|
+
def edit(id, values, options = {})
|
15
|
+
valid_options(options,
|
16
|
+
:modid,
|
17
|
+
:script,
|
18
|
+
:relatedsets_filter,
|
19
|
+
:relatedsets_max,
|
20
|
+
:delete_related)
|
21
|
+
|
22
|
+
perform_request('-edit', { '-recid' => id }.merge(values), options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Filemaker
|
2
|
+
module Api
|
3
|
+
module QueryCommands
|
4
|
+
# Find record(s).
|
5
|
+
#
|
6
|
+
# -max
|
7
|
+
# -skip
|
8
|
+
# -sortfield.[1-9]
|
9
|
+
# -sortorder.[1-9]
|
10
|
+
# -fieldname
|
11
|
+
# -fieldname.op
|
12
|
+
# -lop
|
13
|
+
# -recid
|
14
|
+
# -lay.response
|
15
|
+
# -script
|
16
|
+
# -script.param
|
17
|
+
# -script.prefind
|
18
|
+
# -script.prefind.param
|
19
|
+
# -script.presort
|
20
|
+
# -script.presort.param
|
21
|
+
# -relatedsets.filter
|
22
|
+
# -relatedsets.max
|
23
|
+
#
|
24
|
+
def find(id_or_hash, options = {})
|
25
|
+
valid_options(options,
|
26
|
+
:max,
|
27
|
+
:skip,
|
28
|
+
:sortfield,
|
29
|
+
:sortorder,
|
30
|
+
:lop,
|
31
|
+
:lay_response,
|
32
|
+
:script,
|
33
|
+
:script_prefind,
|
34
|
+
:script_presort,
|
35
|
+
:relatedsets_filter,
|
36
|
+
:relatedsets_max)
|
37
|
+
|
38
|
+
if id_or_hash.is_a? Hash
|
39
|
+
perform_request('-find', id_or_hash, options)
|
40
|
+
else
|
41
|
+
perform_request('-find', { '-recid' => id_or_hash }, options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Filemaker
|
2
|
+
module Api
|
3
|
+
module QueryCommands
|
4
|
+
# Find all records.
|
5
|
+
# Sorting may be slow for huge records.
|
6
|
+
#
|
7
|
+
# Acceptable params are:
|
8
|
+
# -max
|
9
|
+
# -skip
|
10
|
+
# -sortfield.[1-9]
|
11
|
+
# -sortorder.[1-9]
|
12
|
+
# -script
|
13
|
+
# -script.param
|
14
|
+
# -script.prefind
|
15
|
+
# -script.prefind.param
|
16
|
+
# -script.presort
|
17
|
+
# -script.presort.param
|
18
|
+
# -relatedsets.filter
|
19
|
+
#
|
20
|
+
def findall(options = {})
|
21
|
+
valid_options(options,
|
22
|
+
:max,
|
23
|
+
:skip,
|
24
|
+
:sortfield,
|
25
|
+
:sortorder,
|
26
|
+
:script,
|
27
|
+
:script_prefind,
|
28
|
+
:relatedsets_filter)
|
29
|
+
|
30
|
+
perform_request('-findall', {}, options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Filemaker
|
2
|
+
module Api
|
3
|
+
module QueryCommands
|
4
|
+
# Find a random record.
|
5
|
+
#
|
6
|
+
# If data cannot be coerced, it will crash!
|
7
|
+
# Acceptable params are:
|
8
|
+
# -script
|
9
|
+
# -script.param
|
10
|
+
# -script.prefind
|
11
|
+
# -script.prefind.param
|
12
|
+
# -relatedsets.filter
|
13
|
+
# -relatedsets.max
|
14
|
+
#
|
15
|
+
def findany(options = {})
|
16
|
+
valid_options(options,
|
17
|
+
:script,
|
18
|
+
:script_prefind,
|
19
|
+
:relatedsets_filter,
|
20
|
+
:relatedsets_max)
|
21
|
+
|
22
|
+
perform_request('-findany', {}, options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|