ginjo-rfm 2.1.7 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTliMjcxMTMwOTViNmIyY2JlZTY4NTNiZGU2MjU2ZmFjMjhlOTYxMA==
5
+ data.tar.gz: !binary |-
6
+ YjA0MGJhNDhiZjZiZjM2NmQzNTBmYzI3MTE4ZGM3NGZjNmVkYjIwYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZGQ1N2U4ZDAyNGYxOGEyZDU2ZGVmMWRjMGM1N2NkMzU0MWYxYmYxNThhNGVh
10
+ ZGI1YTc2MjJjZWNkZWFlNDRlNGY4MjU5OTliNzU4YzEyMTNmZTg4MWZmMzNi
11
+ ODIwNGY4YmZhYzRlOGRlZjI3NDgwZTdkOTE2ODlkOTExOTI1MTQ=
12
+ data.tar.gz: !binary |-
13
+ MmEzZWU4ZWJmMTFiYTBiMGQxNDE1NTkxNjUxNzNjOGE5MTQ0ZTNiNDY1YTli
14
+ OGM5M2U4Y2M0MDc4NTM5YTdjZTQzNmM4YmY1YTkzODE2YmVhMzRlYzYwOGVk
15
+ M2EwNWYzMWEzNmQ3ZGU0MmE4ZDg1NWQyN2Q1OTMzMjcyYWI1YzI=
@@ -1,9 +1,38 @@
1
1
  # Changelog
2
2
 
3
- ## Ginjo-Rfm 2.1.7
4
-
5
- * Added field_mapping awareness to :sort_field query option.
6
- * Relaxed requirement that query option keys be symbols - can now be strings.
3
+ ## Ginjo-Rfm 3.0.0
4
+
5
+ * Disabled default port in Connection (was 80), as it was tripping up connections where the port wasn't specified for a :use\_ssl connection on older Rubies.
6
+ * Enabled :ignore\_portals option.
7
+ * Removed runtime dependency on activesupport from gemspec.
8
+ * Added check in Field#coerce to make sure a '?' is in a string before splitting on '?'. This was breaking repeating container fields.
9
+ * Fixed case mismatch in hash key in Factory classes. Added logging of parsing template to logging of parsing backend.
10
+ * Fixed bug in field\_control#value\_list.
11
+ * Added layout\_meta and resultset\_meta objects.
12
+ * Added fmpxmlresult.xml.builder for future use.
13
+ * Added Rfm.logger, Rfm.logger=, Config.logger, Config#logger, and config(:logger=>(...)).
14
+ * Added logging facility.
15
+ * Moved #state method from individual classes to Config class.
16
+ * Fixes to Base#update\_attributes.
17
+ * Refined multiple :use handling in Config.
18
+ * Using rspec 2
19
+ * Removed SubLayout.
20
+ * Added field-mapping awareness to :sort\_field query option.
21
+ * Relaxed requirement that query option keys be symbols - can now be strings.
22
+ * Record.new now automatically creats models based on layout name. Should there be an option to disable this?
23
+ * Removed ActiveSupport requirement (of course, ActiveSupport will load if ActiveModle is used, but that is the users' choice).
24
+ * Removed XmlMini, XmlParser, and related code & specs.
25
+ * Detached resultset from record, so record doesn't drag resultset around with it.
26
+ * Disabled automatic model creation from a table-name in a new Rfm::Record when initializing.
27
+ * Consolidated Base.new, Base#inititalize into Rfm::Record.
28
+ * Fixed validation callbacks issue.
29
+ * Fixed: Resultset will politely return [] when asked for non-existent portal\_names.
30
+ * Mods to rakefile benchmarking/profiling.
31
+ * Refactored Resultset metadata methods.
32
+ * Refactored Layout metadata methods.
33
+ * Fixed bug in Config#get\_config\_file where a single file path might not be recognized.
34
+ * Added connection.rb and moved some methods from Server to Connection.
35
+ * Sax parsing rewrite.
7
36
 
8
37
  ## Ginjo-Rfm 2.1.6
9
38
 
@@ -25,7 +54,7 @@
25
54
 
26
55
  ## Ginjo-Rfm 2.1.2
27
56
 
28
- * Fixed config.rb so that :file_path (to user-defined yml config file) can be specified as a single path string
57
+ * Fixed config.rb so that :file\_path (to user-defined yml config file) can be specified as a single path string
29
58
  or as an array of path strings.
30
59
 
31
60
  ## Ginjo-Rfm 2.1.1
@@ -36,9 +65,9 @@
36
65
 
37
66
  ## Ginjo-Rfm 2.1.0
38
67
 
39
- * Removed `:include_portals` query option in favor of `:ignore_portals`.
68
+ * Removed `:include\_portals` query option in favor of `:ignore\_portals`.
40
69
 
41
- * Added `:max_portal_rows` query option.
70
+ * Added `:max\_portal\_rows` query option.
42
71
 
43
72
  * Added field-remapping framework to allow model fields with different names than Filemaker fields.
44
73
 
@@ -55,9 +84,9 @@
55
84
 
56
85
  ## Ginjo-Rfm 2.0.2
57
86
 
58
- * Added configuration parameter ignore_bad_data to silence data mismatch errors when loading resultset into records.
87
+ * Added configuration parameter ignore\_bad\_data to silence data mismatch errors when loading resultset into records.
59
88
 
60
- * Added method to load a resultset from file or string. Rfm::Resultset.load_data(file_or_string).
89
+ * Added method to load a resultset from file or string. Rfm::Resultset.load\_data(file\_or\_string).
61
90
 
62
91
  * Added more specs for the above features and for the XmlParser module.
63
92
 
@@ -101,9 +130,9 @@
101
130
 
102
131
  * Re-implemented:
103
132
 
104
- Layout#field_controls
133
+ Layout#field\_controls
105
134
 
106
- Layout#value_lists
135
+ Layout#value\_lists
107
136
 
108
137
  * Enhanced:
109
138
 
@@ -149,21 +178,21 @@
149
178
 
150
179
  ## Lardawge-Rfm 1.4.1.1
151
180
 
152
- * [Bug] Inadvertently left out an attr_reader for server from resultset effecting container urls.
181
+ * [Bug] Inadvertently left out an attr\_reader for server from resultset effecting container urls.
153
182
 
154
183
  ## Lardawge-Rfm 1.4.1*
155
184
 
156
- * Changed Server#do_action to Server#connect.
185
+ * Changed Server#do\_action to Server#connect.
157
186
 
158
187
  * XML Parsing is now done via xpath which significantly speeds up parsing.
159
188
 
160
- * Changes to accessor method names for Resultset#portals Resultset#fields to Resultset#portal_meta and Resultset#field_meta to better describe what you get back.
189
+ * Changes to accessor method names for Resultset#portals Resultset#fields to Resultset#portal\_meta and Resultset#field\_meta to better describe what you get back.
161
190
 
162
191
  * Added an option to load portal records which defaults to false. This significantly speeds up load time when portals are present on the layout.
163
192
 
164
193
  Example:
165
194
 
166
- result = fm_server('layout').find({:username => "==#{username}"}, {:include_portals => true})
195
+ result = fm\_server('layout').find({:username => "==#{username}"}, {:include\_portals => true})
167
196
  # => This will fetch all records with portal records attached.
168
197
 
169
198
  result.first.portals
@@ -171,4 +200,4 @@
171
200
 
172
201
  * Internal file restructuring. Some classes have changed but it should be nothing a developer would use API wise. Please let me know if it is.
173
202
 
174
- * Removed Layout#value_lists && Layout#field_controls. Will put back in if the demand is high. Needs a major refactor and different placement if it goes back in. Was broken so it didn't seem to be used by many devs.
203
+ * Removed Layout#value\_lists && Layout#field\_controls. Will put back in if the demand is high. Needs a major refactor and different placement if it goes back in. Was broken so it didn't seem to be used by many devs.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ginjo-rfm
2
2
 
3
- Rfm is a Ruby-Filemaker adapter, a Ruby gem that allows scripts and applications to exchange commands and data with Filemaker Pro using Filemaker's XML interface. Ginjo-rfm picks up from the lardawge-rfm gem and continues to refine code and fix bugs. Version 2.0 adds some major enhancements, while remaining compatible with ginjo-rfm 1.4.x and lardawge-rfm 1.4.x.
3
+ Rfm is a Ruby-Filemaker adapter, a Ruby Gem that provides an interface between Filemaker Server and Ruby. Query your Filemaker database, browse result records as persistent objects, and create/update/delete records with a syntax similar to ActiveRecord. Ginjo-rfm picks up from the lardawge-rfm gem and continues to refine code and fix bugs. Version 3 removes the dependency on ActiveSupport and is now a completely independent Gem, able to run most of its core features without requiring any other supporting Gems. ActiveModel features can be activated by adding activemodel to your Gemfile (or requiring activemodel manually).
4
+
5
+ Ginjo-rfm version 3 has been tested successfully on Ruby 1.8.7, 1.9.3, 2.0.0, and 2.1.2.
4
6
 
5
7
 
6
8
  ## Documentation & Links
@@ -12,274 +14,73 @@ Rfm is a Ruby-Filemaker adapter, a Ruby gem that allows scripts and applications
12
14
  * Original homepage <http://sixfriedrice.com/wp/products/rfm/>
13
15
  * Lardawge at github <https://github.com/lardawge/rfm>
14
16
 
17
+ ## New in version 3.0
15
18
 
16
- ## New in version 2.1
19
+ There are many changes in version 3, but most of them are under the hood. Here are some highlights.
17
20
 
18
- Ginjo-rfm 2.1 has a combination of new features, bug fixes, and a lot of code refactoring.
19
- Most api calls remain the same, but a good deal of underlying code has been transformed
20
- to support and take advantage of the progress of technologies surrounding Ruby.
21
+ * Compatibility with Ruby 2.1.2 (and 2.0.0, 1.9.3, 1.8.7).
21
22
 
22
- * Portals are now included by default.
23
- Removed `:include_portals` query option in favor of `:ignore_portals`.
24
- Added `:max_portal_rows` query option.
25
- * Added field-mapping framework to allow model fields with different names than Filemaker fields.
23
+ * XML parsing rewrite.
24
+ The entire XML parsing engine of Rfm has been rewritten to use only the sax/stream parsing schemes of the supported Ruby XML parsers (libxml-ruby, nokogiri, ox, rexml). There were two main goals in this rewrite: 1, to separate the xml parsing code from the Rfm/Filemaker objects, and 2, to remove the hard dependency on ActiveSupport. See below for parsing configuration options.
26
25
 
27
- class User < Rfm::Base
28
- config :field_mapping => {
29
- #<filemaker-field-name> => <rfm-field-name>
30
- 'userName' => 'login',
31
- 'First Name' => 'first_name',
32
- 'Last Name' => 'last_name',
33
- 'IDperson' => 'person_id'
34
- }
35
- end
26
+ * Better logging capabilities.
27
+ Added Rfm.logger, Rfm.logger=, Config.logger, Config#logger, and config(:logger=>(...)).
36
28
 
37
- User.find(:login=>'bill') # => [{'login' => 'bill', 'first_name' => 'Bill', ...}, ...]
29
+ * Added field-mapping awareness to :sort_field query option.
38
30
 
39
- * Fixed date/time/timestamp translations when writing data to Filemaker.
40
- * Detached new Server objects from Factory.servers hash, so wont reuse or stack-up servers.
41
- * Added grammar translation layer between xml parser and Rfm, allowing all supported xml grammars to be used with Rfm.
42
- This will also streamline changes/additions to Filemaker's xml grammar(s).
43
- * Added ability to manually import fmpresultset and fmpxmlresult data (from file, variable, etc.).
44
-
45
- Rfm::Resultset.load_data(file_or_string).
46
-
47
- * Compatibility fixes for ruby 1.9.
48
- * Configuration `:use` option now works for all Rfm objects that respond to `config`.
31
+ * Relaxed requirement that query option keys be symbols - can now be strings or symbols.
49
32
 
50
- Some issues still to be addressed (some longstanding and some more recent) are repeating field writes, some of the
51
- object management & introspection calls, pull requests, more coverage of Filemaker's query syntax, more error classes, more specs, and more documentation.
33
+ * Detached resultset from record, so record doesn't drag resultset around with it.
52
34
 
35
+ * Bug fixes and refinements in modeling, configuration, metadata access, and Rfm object instantiation.
53
36
 
54
- ## New in version 2.0
37
+ See the changelog or the commit history for more details on changes in ginjo-rfm v3.
55
38
 
56
- Ginjo-rfm 2.0 brings new features to Rfm, making it easier than ever to work with Filemaker data from your Ruby scripts.
57
-
58
- * Rails-like modeling with ActiveModel
59
- * Support for multiple XML Parsers
60
- * Configuration API
61
- * Compound Filemaker queries with omitable requests
62
- * Full metadata support
63
-
64
-
65
- ### Data Modeling with ActiveModel
66
-
67
- If you can load ActiveModel in your project, you can have model callbacks, validations, and other ActiveModel features.
68
- If you can't load ActiveModel (because you're using something incompatible, like Rails 2),
69
- you can still use Rfm models... minus the ActiveModel-specific features like callbacks and validations. Rfm models give you basic
70
- data modeling with easy configuration and CRUD features.
71
-
72
- class User < Rfm::Base
73
- config :layout=>'user_layout'
74
- before_save :encrypt_password
75
- validate :valid_email_address
76
- end
77
-
78
- @user = User.new :username => 'bill', :password => 'pass'
79
- @user.email = 'my@email.com'
80
- @user.save!
39
+ ## Download & Installation
81
40
 
41
+ Find the latest stable release at Rubygems.org.
82
42
 
83
- ### Choice of XML Parsers
43
+ In your Gemfile.
84
44
 
85
- Ginjo-rfm 2.0 uses ActiveSupport's XmlMini parsing interface, which has built-in support for
86
- LibXML, Nokogiri, and REXML. Additionally, ginjo-rfm includes adapters for Ox and Hpricot parsing.
87
- You can specifiy which parser to use or let Rfm decide.
45
+ gem 'ginjo-rfm', :require=>'rfm'
88
46
 
89
- Rfm.config :parser => :libxml
47
+ Or manually.
90
48
 
91
- If you're not able to install one of the faster parsers, ginjo-rfm will fall back to
92
- ruby's built-in REXML. Want to roll your own XML adapter? Just pass it to Rfm as a module.
49
+ gem install 'ginjo-rfm'
93
50
 
94
- Rfm.config :parser => MyHomeGrownAdapter
51
+ You can find the latest development release on github.
95
52
 
96
- Choose your preferred parser globaly, as in the above example, or set a different parser for each model.
97
-
98
- class Order < Rfm::Base
99
- config :parser => :hpricot
100
- end
101
-
102
- The current parsing options are
53
+ gem 'ginjo-rfm', :git=>'https://github.com/ginjo/rfm.git', :branch=>'master'
103
54
 
104
- :jdom -> JDOM (for JRuby)
105
- :oxsax -> Ox SAX
106
- :libxml -> LibXML Tree
107
- :libxmlsax -> LibXML SAX
108
- :nokogirisax -> Nokogiri SAX
109
- :nokogiri -> Nokogiri Tree
110
- :hpricot -> Hpricot Tree
111
- :rexml -> REXML Tree
112
- :rexmlsax -> REXML SAX
113
-
114
- If you're wondering about performance, here are some preliminary benchmark results. Each backend parsed a fmresultset.xml and a FMPXMLLAYOUT.xml 30 times each. Results have differed across environments with different test data, so this data is by no means definitive. Also note that earlier versions of ActiveSupport did not contain all of the parsing backend options mentioned here.
55
+ Ginjo-rfm v3 can be run without any other gems, allowing you to create models to interact with your Filemaker servers, layouts, tables, records, and data. If you want the additional features provided by ActiveModel, just add activemodel to your Gemfile (or require it manually). Ginjo-rfm v3 will use the built-in Ruby XML parser REXML by default. If you want to use one of the other supported parsers (libxml-ruby, nokogiri, ox), just add it to your Gemfile or require it manually. If you have several Ruby XML parsers installed, you can specify which one you want Rfm to use by setting the configuration option :parser with one of the supported options (:libxml, :nokogiri, :ox, :rexml).
115
56
 
116
- user system total real
117
- ActiveSupport::XmlMini_OxSAX
118
- 0.200000 0.010000 0.210000 ( 0.211842)
119
- ActiveSupport::XmlMini_LibXML
120
- 0.400000 0.010000 0.410000 ( 0.411823)
121
- ActiveSupport::XmlMini_LibXMLSAX
122
- 0.400000 0.010000 0.410000 ( 0.411360)
123
- ActiveSupport::XmlMini_NokogiriSAX
124
- 0.670000 0.010000 0.680000 ( 0.682885)
125
- ActiveSupport::XmlMini_Nokogiri
126
- 0.970000 0.030000 1.000000 ( 0.998673)
127
- ActiveSupport::XmlMini_Hpricot
128
- 1.950000 0.060000 2.010000 ( 2.011355)
129
- ActiveSupport::XmlMini_REXML
130
- 8.710000 0.180000 8.890000 ( 9.015836)
131
- ActiveSupport::XmlMini_REXMLSAX
132
- 6.320000 0.040000 6.360000 ( 6.377179)
57
+ Note that while this gem is officially named "ginjo-rfm", you require/load it into your Ruby scripts as simply "rfm". This is in keeping with the original rfm gem from Sixfriedrice and with other forks of the rfm gem.
133
58
 
134
59
 
135
60
 
136
- ### Configuration API
61
+ ## Ginjo-rfm Basic Usage
137
62
 
138
- The ginjo-rfm configuration module lets you store your settings in several different ways. Store some, or all, of your project-specific settings in a rfm.yml file at the root of your project, or in your Rails config/ directory. Settings can also be put in a RFM_CONFIG constant at the top level of your project. Configuration settings can be simple key=>values, or they can be named groups of key=>values. Configuration can also be passed to various Rfm methods during load and runtime, as individual settings or as groups.
63
+ The first step in getting connected to your Filemaker databases with Rfm is to store your configuration settings in a yaml file or in the RFM_CONFIG hash. The second step is creating a Ruby class (often referred to as a "model" in this documentation) that represent a layout in your Filemaker database. Create as many models as you wish, each pointing to a layout/table-occurrence that you want to work with. The third step is using your new models to query, create, update, and delete records in your Filemaker database. Here's an example setup for a simple order-item table.
139
64
 
140
65
  rfm.yml
141
66
 
142
- :ssl: true
143
- :root_cert: false
144
- :timeout: 10
145
- :port: 443
146
- :host: live.mydomain.com
147
- :account_name: admin
148
- :password: pass
149
- :database: MyFmDb
150
-
151
- Set a model's configuration.
67
+ :host: my.host.com
68
+ :account_name: myname
69
+ :password: somepass
70
+ :database: MyFmDb
152
71
 
153
- class MyModel < Rfm::Base
154
- config :layout => 'mylayout'
155
- end
72
+ app/models/order\_item.rb
156
73
 
74
+ class OrderItem < Rfm::Base
75
+ config :layout => 'order_item_layout'
76
+ end
77
+
78
+ app/controllers/order\_item\_controller.rb
157
79
 
158
- ### Compound Filemaker Queries, with Omitable FMP Find Requests
80
+ def show
81
+ @record = OrderItem.find params[:id]
82
+ end
159
83
 
160
- Create a Filemaker 'omit' request by including an :omit key with a value of true.
161
-
162
- my_layout.find :field1 => 'val1', :field2 => 'val2', :omit => true
163
-
164
- Create multiple Filemaker find requests by passing an array of hashes to the #find method.
165
-
166
- my_layout.find [{:field1 => 'bill', :field2 => 'admin'}, {:field2 => 'staff', :field3 => 'inactive', :omit => true}, ...]
167
-
168
- If the value of a field in a find request is an array of strings, the string values will be logically OR'd in the query.
169
-
170
- my_layout.find :fieldOne => ['bill','mike','bob'], :fieldTwo =>'staff'
171
-
172
-
173
- ### Full Metadata Support
174
-
175
- * Server databases
176
- * Database layouts
177
- * Database scripts
178
- * Layout fields
179
- * Layout portals
180
- * Resultset meta
181
- * Field definition meta
182
- * Portal definition meta
183
-
184
- There are also many enhancements to make it easier to get the objects or data you want. Some examples:
185
-
186
- Get a database object using default config
187
-
188
- Rfm.db 'my_db'
189
-
190
- Get a layout object using config grouping :my_group
191
-
192
- Rfm.layout :my_group
193
-
194
- Get the total count of all records in the table
195
-
196
- MyModel.total_count
197
-
198
- Get the portal names (table-occurrence names) on the current layout
199
-
200
- MyModel.portal_names
201
-
202
- Get the names of fields on the current layout
203
-
204
- my_record.field_names
205
-
206
- ### From ginjo-rfm 1.4.x
207
-
208
- From ginjo-rfm 1.4.x, the following features are also included.
209
-
210
- Connection timeout settings
211
-
212
- Rfm.config :timeout => 10
213
-
214
- Value-list alternate display
215
-
216
- i = array_of_value_list_items[3] # => '8765'
217
- i.value # => '8765'
218
- i.display # => '8765 Amy'
219
-
220
-
221
- ### Compatibility
222
-
223
- Ginjo-rfm 2.0 is compatible with previous versions of Rfm - Ginjo, Lardawge, and SFR. However, much has been changed in the low-level workings of the code. If you have scripts that reach deep into the guts of Rfm 1.0 thru 1.4.x, you may find that some things are slightly different in 2.0. Additionally, some long-standing bugs have been fixed that may have been so de rigeur, that the "correct behavior" in Rfm 2.0 may break scripts that relied on the previously buggy functions. These low level changes, and the addition of major new functionality, led the decision to release this version of Rfm as 2.0, instead of 1.5.
224
-
225
-
226
- ## Download & Installation
227
-
228
- There are at least 4 ways to download ginjo-rfm.
229
-
230
- * With Bundler: gem 'ginjo-rfm'
231
- * With the command line: gem install ginjo-rfm
232
- * From https://rubygems.org/gems/ginjo-rfm
233
- * From https://github.com/ginjo/rfm
234
-
235
- Ginjo-rfm requires the ActiveSupport gem for several features, including XML parsing. Rfm has been tested and works with ActiveSupport 2.3.5 thru 3.1.3, on both ruby 1.8.7 and ruby 1.9.2. ActiveModel requires ActiveSupport 3+ and is not compatible with ActiveSupport 2.3.x. So while you CAN use ginjo-rfm with Rails 2.3, you will not have ActiveModel features like callbacks and validations. Basic modeling functionality and Filemaker interaction will continue to work, unaffected by the presence or absence of ActiveModel.
236
-
237
- For the best performance, it is recommended that you use the Ox, Libxml-ruby, Nokogiri, or Hpricot parser. Ginjo-rfm does not require these gems by dependency, so you will have to make sure they are installed on your machine and/or specified in your Gemfile, if you wish to use them. If you don't want to install any of these parsers, Rfm will use the REXML parser included with the Ruby standard library. Similarly, ginjo-rfm does not require ActiveModel by dependency, so also make sure that is installed and/or specified in your Gemfile if you wish to use ActiveModel features.
238
-
239
- Note that the installation of Ox, Libxml-ruby, Nokogiri, or Hpricot gems will require further dependencies. Please see the install instructions for each parser to get them installed and running on your system.
240
-
241
-
242
- ### Using Bundler and/or Rails >= 3.0
243
-
244
- In your Gemfile:
245
-
246
- gem 'ginjo-rfm'
247
- gem 'ox' # optional
248
- gem 'libxml-ruby' # optional
249
- gem 'nokogiri' # optional
250
- gem 'hpricot' # optional
251
- gem 'activemodel' # optional
252
-
253
- In your shell:
254
-
255
- bundle install
256
-
257
- In your project, you may or may not have to require 'rfm', depending on Bundler's configuration:
258
-
259
- require 'rfm'
260
-
261
- ### Without Bundler
262
-
263
- If you are not using Bundler, Rfm will pick up the XML parsers and ActiveModel as long as they are available in your current rubygems installation.
264
-
265
- In your shell:
266
-
267
- gem install ginjo-rfm
268
- gem install ox # optional
269
- gem install nokogiri # optional
270
- gem install libxml-ruby # optional
271
- gem install hpricot # optional
272
- gem install activemodel # optional
273
-
274
- Once the gem is installed, you can use rfm in your ruby scripts by requiring it:
275
-
276
- require 'rubygems'
277
- require 'rfm'
278
-
279
-
280
- ## Ginjo-rfm Basic Usage
281
-
282
- The first step in getting connected to your Filemaker databases with Rfm is to store your configuration settings in a yaml file or in the RFM_CONFIG hash. The second step is creating a model that represents a layout from one of your Filemaker databases.
283
84
 
284
85
  ### Configuration
285
86
 
@@ -288,7 +89,6 @@ In previous versions of Rfm, you may have stored your configuration settings in
288
89
  rfm.yml
289
90
 
290
91
  :ssl: true
291
- :root_cert: false
292
92
  :timeout: 10
293
93
  :port: 443
294
94
  :host: my.host.com
@@ -304,12 +104,11 @@ Or put your configuration settings in a hash called RFM_CONFIG. Rfm will pick th
304
104
  :account_name => 'myname',
305
105
  :password => 'somepass',
306
106
  :ssl => true,
307
- :root_cert => false,
308
107
  :port => 443,
309
108
  :timeout => 10
310
109
  }
311
110
 
312
- You can use configuration subgroups to seperate global settings from environment-specific settings.
111
+ You can use configuration subgroups to separate global settings from environment-specific settings.
313
112
 
314
113
  :ssl: true
315
114
  :root_cert: false
@@ -326,7 +125,7 @@ You can use configuration subgroups to seperate global settings from environment
326
125
  :password: pass
327
126
  :database: LiveFmDb
328
127
 
329
- Then in your environment files (or wherever you put environment-specific configuration in your ruby project),
128
+ Then in your environment files (or wherever you put environment-specific configuration in your Ruby project),
330
129
  specifiy which subgroup to use.
331
130
 
332
131
  RFM_CONFIG = {:use => :development}
@@ -348,13 +147,13 @@ You can use configuration subgroups to contain any arbitrary groups of settings.
348
147
  :password: pass
349
148
  :database: custTwoFmDb
350
149
 
351
- Use the configuration setting method `config` to set configuration for specific objects, like Rfm models. When you pass a `:use => :subgroup` to the `config` method, you're saying use that subgroup of settings.
150
+ Use the configuration setting method `config` to set configuration for specific objects, like Rfm models. When you pass a `:use => :subgroup` to the `config` method, you're saying use that subgroup of settings (on top of any existing upstream configuration).
352
151
 
353
152
  class MyModel < Rfm::Base
354
153
  config :use => :customer1, :layout => 'some_layout'
355
154
  end
356
155
 
357
- The current heirarchy of configurable objects in Rfm, starting at the top, is:
156
+ The current hierarchy of configurable objects in Rfm, starting at the top, is:
358
157
 
359
158
  * rfm.yml # file of settings in yaml format
360
159
  * RFM_CONFIG # user-defined hash
@@ -385,12 +184,13 @@ Use `get_config` to view the compiled configuration settings for any object. Con
385
184
  :account_name => 'name', :password => 'pass'
386
185
  }
387
186
 
388
- **Possible Configuration Options**
187
+ #### Configuration Options
389
188
 
390
189
  Following are all of the recognized configuration options, including defaults if applicable.
190
+ See `Rfm::Config::CONFIG_KEYS` for a list of currently allowed configuration options.
391
191
 
392
192
  :host => 'localhost'
393
- :port => 80
193
+ :port
394
194
  :ssl => true
395
195
  :root_cert => true
396
196
  :root_cert_name => ''
@@ -409,13 +209,13 @@ Following are all of the recognized configuration options, including defaults if
409
209
  :parent => 'Rfm::Config' # the parent configuration object of the current configuration object, as string
410
210
  :file_name => 'rfm.yml # name of configuration file to load yaml from
411
211
  :file_path => ['', 'config/'] # array of additional file paths to look for configuration file
412
- :parser => ActiveSupport::XmlMini_REXML # XmlParser to use if no other is specified or can be found
212
+ :parser # Prefferred XML parser (you must also require the parsing gem or specify it in your gemfile, if not using the built-in Ruby XML parser REXML). Can be :libxml, :nokogiri, :ox, :rexml.
413
213
  :ignore_bad_data => nil # Instruct Rfm to ignore data mismatch errors when loading a resultset
414
214
 
415
215
 
416
216
  ### Using Models
417
217
 
418
- Rfm models provide easy access, modeling, and persistence of your Filemaker data.h
218
+ Rfm models provide easy access, modeling, and persistence of your Filemaker data.
419
219
 
420
220
  class User < Rfm::Base
421
221
  config :layout => 'my_user_layout'
@@ -439,24 +239,13 @@ Rfm models provide easy access, modeling, and persistence of your Filemaker data
439
239
  @user.update_attributes(:login => 'william', :email => 'myother@email.com')
440
240
  @user.save!
441
241
 
442
- Put your model code anywhere at the top level of your script/application. In Rails, this could be your initialization file(s), your environment file(s), or in a file in your Models directory called something like `rfm_models.rb`. Then require 'rfm_models' in your initialization or environment.
242
+ If using Rails, put your model code in files within your models/ directory.
443
243
 
444
- rfm_models.rb
244
+ app/models/user.rb
445
245
 
446
- require 'rfm'
447
-
448
246
  class User < Rfm::Base
449
247
  config :layout => 'user_layout'
450
248
  end
451
-
452
- class Order < Rfm::Base
453
- config :layout => 'order_layout'
454
- end
455
-
456
- main_initializer.rb
457
-
458
- require 'rfm_models'
459
-
460
249
 
461
250
  If you prefer, you can create models on-the-fly from any layout.
462
251
 
@@ -470,9 +259,9 @@ Or create models for an entire database, all at once.
470
259
 
471
260
  # => [MyLayoutXml, AnotherLayoutXml, ThirdLayoutXml, AndSoOnXml, ...]
472
261
  # The regex in the first parameter is optional and filters the layout names in the specified database.
473
- # Omit the regex parameter to modelize all possible layouts in the specified database.
262
+ # Omit the regex parameter to modelize all possible layouts in the specified database (careful with this one!).
474
263
 
475
- With ActiveModel loaded, you get callbacks, validations, errors, serialization, and a handful of other features extracted from Rails ActiveRecord.
264
+ With ActiveModel loaded, you get callbacks, validations, errors, serialization, and a handful of other features extracted from Rails ActiveRecord. Not all ActiveModel features are supported (yet) in ginjo-rfm, but adapters can be hand-rolled in the meantime.
476
265
 
477
266
  In your Gemfile
478
267
 
@@ -503,9 +292,9 @@ To learn more about ActiveModel, see the ActiveModel or RubyOnRails documentatio
503
292
 
504
293
  Once you have an Rfm model or layout, you can use any of the standard Rfm commands to create, search, edit, and delete records. To learn more about these commands, see below for Databases, Layouts, Resultsets, and Records. Or checkout the API documentation for Rfm::Server, Rfm::Database, Rfm::Layout, Rfm::Record, and Rfm::Base.
505
294
 
506
- **Two Small Changes in Rfm Return Values**
295
+ #### Two Small Changes in Rfm Return Values
507
296
 
508
- When using Models to retrieve records using the `any` method or the `find(record_id)` method, the return values will be single Rfm::Record objects. This differs from the traditional Rfm behavior of these methods when accessed directly from the the Rfm::Layout instance, where the return value is always a Rfm::Resultset.
297
+ (From Rfm v2 onward) When using Models to retrieve records using the `any` method or the `find(record_id)` method, the return values will be single Rfm::Record objects. This differs from the original Rfm behavior of these methods when accessed directly from the the Rfm::Layout instance, where the return value is always a Rfm::Resultset.
509
298
 
510
299
  MyModel.find(record_id) == my_layout.find(record_id)[0]
511
300
  MyModel.any == my_layout.any[0]
@@ -513,7 +302,7 @@ When using Models to retrieve records using the `any` method or the `find(record
513
302
 
514
303
  ### Getting Rfm Server, Database, and Layout Objects Manually
515
304
 
516
- Well... not entirely manually. To get server, db, and layout objects as in previous versions of Rfm, see the section "Working with classic Rfm features". Ginjo-rfm 2.0 has some new methods to create/locate Filemaker objects and meta data. Many of these new methods are configuration-aware.
305
+ Well... not entirely manually. To get server, db, and layout objects as in previous versions of Rfm, see the section "Working with classic Rfm features". Newer versions of ginjo-rfm can use the configuration options to build these objects.
517
306
 
518
307
  Create a layout object using default configuration settings.
519
308
 
@@ -591,9 +380,9 @@ There are a number of methods within Rfm that have been made accessible from the
591
380
  # Any of these methods can be accessed via Rfm.<method_name>
592
381
 
593
382
  Rfm::Factory :servers, :server, :db, :database, :layout, :models, :modelize
594
- Rfm::XmlParser :backend, :backend=
595
383
  Rfm::Config :config, :get_config, :config_clear
596
384
  Rfm::Resultset :ignore_bad_data
385
+ Rfm::SaxParser :backend
597
386
 
598
387
  If you are working with a Filemaker database that returns codes like '?' for a missing value in a date field, Rfm will throw an error. Set your main configuration, your server, or your layout to `ignore_bad_data true`, if you want Rfm to silently ignore data mismatch errors when loading resultset data. If ActiveRecord is loaded, and your resultset is loaded into a Rfm model, your model records will log these errors in the @errors attribute.
599
388
 
@@ -711,7 +500,7 @@ All of these methods return an Rfm::Resultset object (see below), and every one
711
500
 
712
501
  For a complete list of the available options, see the "expand_options" method in the Rfm::Server object in the file named server.rb.
713
502
 
714
- Finally, if filemaker returns an error when executing any of these methods, an error will be raised in your ruby script. There is one exception to this, though. If a find results in no records being found (FileMaker error # 401) I just ignore it and return you a Resultset with zero records in it. If you prefer an error in this case, add :raise_on_401 => true to the options you pass the Rfm::Server when you create it.
503
+ Finally, if filemaker returns an error when executing any of these methods, an error will be raised in your Ruby script. There is one exception to this, though. If a find results in no records being found (FileMaker error # 401) I just ignore it and return you a Resultset with zero records in it. If you prefer an error in this case, add :raise_on_401 => true to the options you pass the Rfm::Server when you create it.
715
504
 
716
505
 
717
506
  ### Resultset and Record Objects
@@ -722,7 +511,7 @@ Any method on the Layout object that returns data will return a Resultset object
722
511
  my_result.size # returns '1'
723
512
  my_result[0] # returns the first record (an Rfm::Record object)
724
513
 
725
- The Resultset object also tells you information about the fields and portals in the result. Resultset#field\_meta and Resultset#portal\_meta are both standard ruby hashes, with strings for keys. The fields hash has Rfm::Metadata::Field objects for values. The portals hash has another hash for its values. This nested hash is the fields on the portal. This would print out all the field names:
514
+ The Resultset object also tells you information about the fields and portals in the result. Resultset#field\_meta and Resultset#portal\_meta are both standard Ruby hashes, with strings for keys. The fields hash has Rfm::Metadata::Field objects for values. The portals hash has another hash for its values. This nested hash is the fields on the portal. This would print out all the field names:
726
515
 
727
516
  my_result.field_meta.each { |name, field| puts name }
728
517
 
@@ -746,7 +535,7 @@ But most importantly, the Resultset contains record objects. Rfm::Record is a su
746
535
  my_record = my_result[0]
747
536
  puts my_record["first_name"]
748
537
 
749
- As a convenience, if your field names are valid ruby method names (ie, they don't have spaces or odd punctuation in them), you can do this instead:
538
+ As a convenience, if your field names are valid Ruby method names (ie, they don't have spaces or odd punctuation in them), you can do this instead:
750
539
 
751
540
  puts my_record.first_name
752
541
 
@@ -805,9 +594,9 @@ FileMaker's field types are coerced to Ruby types thusly:
805
594
  TimeStamp Field -> DateTime object
806
595
  Container Field -> URI object
807
596
 
808
- FileMaker's number field is insanely robust. The only data type in ruby that can handle the same magnitude and precision of a FileMaker number is Ruby's BigDecimal. (This is an extension class, so you have to require 'bigdecimal' to use it yourself). Unfortuantely, BigDecimal is not a "normal" ruby numeric class, so it might be really annoying that your tiny filemaker numbers have to go this route. This is a great topic for debate.
597
+ FileMaker's number field is insanely robust. The only data type in Ruby that can handle the same magnitude and precision of a FileMaker number is Ruby's BigDecimal. (This is an extension class, so you have to require 'bigdecimal' to use it yourself). Unfortuantely, BigDecimal is not a "normal" Ruby numeric class, so it might be really annoying that your tiny filemaker numbers have to go this route. This is a great topic for debate.
809
598
 
810
- Also, Ruby doesn't have a Time type that stores just a normal time (with no date attached). The Time class in ruby is a lot like DateTime, or a Timestamp in FileMaker. When I get a Time field from FileMaker, I turn it into a DateTime object, and set its date to the oldest date Ruby supports. You can still compare these in all the normal ways, so this should be fine, but it will look weird if you, ie, to_s one and see an odd date attached to your time.
599
+ Also, Ruby doesn't have a Time type that stores just a normal time (with no date attached). The Time class in Ruby is a lot like DateTime, or a Timestamp in FileMaker. When I get a Time field from FileMaker, I turn it into a DateTime object, and set its date to the oldest date Ruby supports. You can still compare these in all the normal ways, so this should be fine, but it will look weird if you, ie, to_s one and see an odd date attached to your time.
811
600
 
812
601
  Finally, container fields will come back as URI objects. You can:
813
602
 
@@ -841,6 +630,193 @@ So, for an annoying, but detailed load of output, make a connection like this:
841
630
 
842
631
  If you were tracking ginjo-rfm on github before the switch to version 2.0.0, please accept my humblest apologies for making a mess of the branching. The pre 2.0.0 edge branch has become master, and the pre 2.0.0 master branch has become ginjo-1-4-stable. I don't intend to make that kind of hard reset again, at least not on public branches. Master will be the branch to find the latest-greatest public source, and 'stable' branches will emerge as necessary to preserve historical releases.
843
632
 
633
+ ### Still To Do
634
+
635
+ Repeating field compatibility, more coverage of Filemaker's query syntax, more error classes, more specs, and more documentation.
636
+
637
+
638
+
639
+
640
+ ## Previous Version Highlights
641
+
642
+ ### Version 2.1
643
+
644
+ * Portals are now included by default.
645
+ Removed `:include_portals` query option in favor of `:ignore_portals`.
646
+ Added `:max_portal_rows` query option.
647
+ * Added field-remapping framework to allow model fields with different names than Filemaker fields.
648
+
649
+ class User < Rfm::Base
650
+ config :field_mapping => {
651
+ #<filemaker-field-name> => <rfm-field-name>
652
+ 'userName' => 'login',
653
+ 'First Name' => 'first_name',
654
+ 'Last Name' => 'last_name',
655
+ 'IDperson' => 'person_id'
656
+ }
657
+ end
658
+
659
+ User.find(:login=>'bill') # => [{'login' => 'bill', 'first_name' => 'Bill', ...}, ...]
660
+
661
+ * Fixed date/time/timestamp translations when writing data to Filemaker.
662
+ * Detached new Server objects from Factory.servers hash, so wont reuse or stack-up servers.
663
+ * Added grammar translation layer between xml parser and Rfm, allowing all supported xml grammars to be used with Rfm.
664
+ This will also streamline changes/additions to Filemaker's xml grammar(s).
665
+ * Added ability to manually import fmpresultset and fmpxmlresult data (from file, variable, etc.).
666
+
667
+ Rfm::Resultset.load_data(file_or_string).
668
+
669
+ * Compatibility fixes for Ruby 1.9.
670
+ * Configuration `:use` option now works for all Rfm objects that respond to `config`.
671
+
672
+
673
+ ### Version 2.0
674
+
675
+ * Rails-like modeling with ActiveModel
676
+ * Support for multiple XML Parsers
677
+ * Configuration API
678
+ * Compound Filemaker queries with omitable requests
679
+ * Full metadata support
680
+
681
+
682
+ #### Data Modeling with ActiveModel
683
+
684
+ If you can load ActiveModel in your project, you can have model callbacks, validations, and other ActiveModel features.
685
+ If you can't load ActiveModel (because you're using something incompatible, like Rails 2),
686
+ you can still use Rfm models... minus the ActiveModel-specific features like callbacks and validations. Rfm models give you basic
687
+ data modeling with easy configuration and CRUD features.
688
+
689
+ class User < Rfm::Base
690
+ config :layout=>'user_layout'
691
+ before_save :encrypt_password
692
+ validate :valid_email_address
693
+ end
694
+
695
+ @user = User.new :username => 'bill', :password => 'pass'
696
+ @user.email = 'my@email.com'
697
+ @user.save!
698
+
699
+
700
+ #### Choice of XML Parsers
701
+
702
+ Note that this section only applies to ginjo-rfm v2. See notes for ginjo-rfm v3 for v3 parsing options.
703
+
704
+ Ginjo-rfm 2.0 uses ActiveSupport's XmlMini parsing interface, which has built-in support for
705
+ LibXML, Nokogiri, and REXML. Additionally, ginjo-rfm includes adapters for Ox and Hpricot parsing.
706
+ You can specifiy which parser to use or let Rfm decide.
707
+
708
+ Rfm.config :parser => :libxml
709
+
710
+ If you're not able to install one of the faster parsers, ginjo-rfm will fall back to
711
+ Ruby's built-in REXML. Want to roll your own XML adapter? Just pass it to Rfm as a module.
712
+
713
+ Rfm.config :parser => MyHomeGrownAdapter
714
+
715
+ Choose your preferred parser globaly, as in the above example, or set a different parser for each model.
716
+
717
+ class Order < Rfm::Base
718
+ config :parser => :hpricot
719
+ end
720
+
721
+ The current parsing options are
722
+
723
+ :jdom -> JDOM (for JRuby)
724
+ :oxsax -> Ox SAX
725
+ :libxml -> LibXML Tree
726
+ :libxmlsax -> LibXML SAX
727
+ :nokogirisax -> Nokogiri SAX
728
+ :nokogiri -> Nokogiri Tree
729
+ :hpricot -> Hpricot Tree
730
+ :rexml -> REXML Tree
731
+ :rexmlsax -> REXML SAX
732
+
733
+
734
+ #### Configuration API
735
+
736
+ The ginjo-rfm configuration module lets you store your settings in several different ways. Store some, or all, of your project-specific settings in a rfm.yml file at the root of your project, or in your Rails config/ directory. Settings can also be put in a RFM_CONFIG constant at the top level of your project. Configuration settings can be simple key=>values, or they can be named groups of key=>values. Configuration can also be passed to various Rfm methods during load and runtime, as individual settings or as groups.
737
+
738
+ rfm.yml
739
+
740
+ :ssl: true
741
+ :root_cert: false
742
+ :timeout: 10
743
+ :port: 443
744
+ :host: live.mydomain.com
745
+ :account_name: admin
746
+ :password: pass
747
+ :database: MyFmDb
748
+
749
+ Set a model's configuration.
750
+
751
+ class MyModel < Rfm::Base
752
+ config :layout => 'mylayout'
753
+ end
754
+
755
+
756
+ #### Compound Filemaker Queries, with Omitable FMP Find Requests
757
+
758
+ Create a Filemaker 'omit' request by including an :omit key with a value of true.
759
+
760
+ my_layout.find :field1 => 'val1', :field2 => 'val2', :omit => true
761
+
762
+ Create multiple Filemaker find requests by passing an array of hashes to the #find method.
763
+
764
+ my_layout.find [{:field1 => 'bill', :field2 => 'admin'}, {:field2 => 'staff', :field3 => 'inactive', :omit => true}, ...]
765
+
766
+ If the value of a field in a find request is an array of strings, the string values will be logically OR'd in the query.
767
+
768
+ my_layout.find :fieldOne => ['bill','mike','bob'], :fieldTwo =>'staff'
769
+
770
+
771
+ #### Full Metadata Support
772
+
773
+ * Server databases
774
+ * Database layouts
775
+ * Database scripts
776
+ * Layout fields
777
+ * Layout portals
778
+ * Resultset meta
779
+ * Field definition meta
780
+ * Portal definition meta
781
+
782
+ There are also many enhancements to make it easier to get the objects or data you want. Some examples:
783
+
784
+ Get a database object using default config
785
+
786
+ Rfm.db 'my_db'
787
+
788
+ Get a layout object using config grouping :my_group
789
+
790
+ Rfm.layout :my_group
791
+
792
+ Get the total count of all records in the table
793
+
794
+ MyModel.total_count
795
+
796
+ Get the portal names (table-occurrence names) on the current layout
797
+
798
+ MyModel.portal_names
799
+
800
+ Get the names of fields on the current layout
801
+
802
+ my_record.field_names
803
+
804
+
805
+ ### From Version 1.4.x
806
+
807
+ From ginjo-rfm 1.4.x, the following features are also included.
808
+
809
+ Connection timeout settings
810
+
811
+ Rfm.config :timeout => 10
812
+
813
+ Value-list alternate display
814
+
815
+ i = array_of_value_list_items[3] # => '8765'
816
+ i.value # => '8765'
817
+ i.display # => '8765 Amy'
818
+
819
+
844
820
 
845
821
  ## Credits
846
822
 
@@ -848,9 +824,10 @@ Rfm was primarily designed by Six Fried Rice co-founder Geoff Coffey.
848
824
 
849
825
  Other lead contributors:
850
826
 
851
- * Mufaddal Khumri helped architect Rfm in the most ruby-like way possible. He also contributed the outstanding error handling code and a comprehensive hierarchy of error classes.
827
+ * Mufaddal Khumri helped architect Rfm in the most Ruby-like way possible. He also contributed the outstanding error handling code and a comprehensive hierarchy of error classes.
852
828
  * Atsushi Matsuo was an early Rfm tester, and provided outstanding feedback, critical code fixes, and a lot of web exposure.
853
829
  * Jesse Antunes helped ensure that Rfm is stable and functional.
854
830
  * Larry Sprock added ssl support, switched the xml parser to a much faster Nokogiri, added the rspec testing framework, and refined code architecture.
831
+ * William Richardson is the current maintainer of the ginjo-rfm fork and added support for multiple xml parsers, ActiveModel integration, field mapping, compound queries, logging, and a configuration framework.
855
832
 
856
833