filemaker 0.0.13 → 0.0.14

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/filemaker.rb +4 -4
  3. data/lib/filemaker/core_ext/hash.rb +2 -2
  4. data/lib/filemaker/database.rb +2 -2
  5. data/lib/filemaker/elasticsearch/filemaker_adapter.rb +1 -1
  6. data/lib/filemaker/layout.rb +6 -2
  7. data/lib/filemaker/model.rb +2 -2
  8. data/lib/filemaker/model/components.rb +1 -1
  9. data/lib/filemaker/model/criteria.rb +2 -2
  10. data/lib/filemaker/model/field.rb +1 -0
  11. data/lib/filemaker/model/fields.rb +1 -1
  12. data/lib/filemaker/model/optional.rb +2 -2
  13. data/lib/filemaker/model/persistable.rb +1 -0
  14. data/lib/filemaker/model/relations/has_many.rb +4 -2
  15. data/lib/filemaker/model/selectable.rb +13 -13
  16. data/lib/filemaker/railtie.rb +1 -1
  17. data/lib/filemaker/record.rb +2 -2
  18. data/lib/filemaker/resultset.rb +1 -1
  19. data/lib/filemaker/server.rb +13 -12
  20. data/lib/filemaker/version.rb +1 -1
  21. data/spec/filemaker/api/query_commands/compound_find_spec.rb +0 -3
  22. data/spec/filemaker/configuration_spec.rb +0 -2
  23. data/spec/filemaker/error_spec.rb +0 -2
  24. data/spec/filemaker/layout_spec.rb +1 -4
  25. data/spec/filemaker/metadata/field_spec.rb +0 -1
  26. data/spec/filemaker/model/builder_spec.rb +8 -11
  27. data/spec/filemaker/model/criteria_spec.rb +1 -3
  28. data/spec/filemaker/model/relations_spec.rb +0 -1
  29. data/spec/filemaker/model_spec.rb +13 -5
  30. data/spec/filemaker/record_spec.rb +2 -2
  31. data/spec/filemaker/resultset_spec.rb +0 -1
  32. data/spec/filemaker/server_spec.rb +10 -12
  33. data/spec/filemaker/store/database_store_spec.rb +1 -3
  34. data/spec/filemaker/store/layout_store_spec.rb +1 -3
  35. data/spec/filemaker/store/script_store_spec.rb +1 -3
  36. data/spec/spec_helper.rb +0 -1
  37. data/spec/support/models.rb +6 -7
  38. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 009458a403f79f4b0f6b04d6735d935ce88861a0
4
- data.tar.gz: 7f9401ccf4fc4439e0395ebed371df36701c7bce
3
+ metadata.gz: c0b5ad4c9868171da5694e25de70b5600debedbe
4
+ data.tar.gz: 54c42d1c9e3a4664b6fbceaa0252c1460b356629
5
5
  SHA512:
6
- metadata.gz: c8d2c4c02b1ee56c848eb7c236c797c3d5445bef754961ee0b6aa79563f14c58496b0109faf59161888776da559949014fa0b9c8bd8e91f80536d64842dfa090
7
- data.tar.gz: 9a224562aa951a8a0979e7d705a5f16eed60c55ac599401ad5b58ab5268b8c5e84d5231a5c764f255920834ba0f713a8d987327685ed2b4e9b719ce94c04999b
6
+ metadata.gz: f9d5ac6b04b0205d53b69de121bbb9bde10d57f08746ce7b3f66f4cc0702c7e3475cbf92300d768fe245a3a7b73139fdf4e2b48a358c4b6b90e55c8e501cd42b
7
+ data.tar.gz: a8578655262153e2f22735280df49a67acb380f5a10c1c6bf9b0003680ee1a1b4ad98f50debe2e628fb638ab85475d184a47ec5f2d6b93b980a5251fabbdcf21
@@ -29,20 +29,20 @@ module Filemaker
29
29
  # defined at the `filemaker.yml` config file.
30
30
  def load!(path, environment = nil)
31
31
  sessions = YAML.load(ERB.new(File.new(path).read).result)[environment.to_s]
32
- fail Errors::ConfigurationError, 'Environment wrong?' if sessions.nil?
32
+ raise Errors::ConfigurationError, 'Environment wrong?' if sessions.nil?
33
33
 
34
34
  sessions.each_pair do |key, value|
35
35
  registry[key] = Filemaker::Server.new do |config|
36
36
  config.host = value.fetch('host') do
37
- fail Errors::ConfigurationError, 'Missing config.host'
37
+ raise Errors::ConfigurationError, 'Missing config.host'
38
38
  end
39
39
 
40
40
  config.account_name = value.fetch('account_name') do
41
- fail Errors::ConfigurationError, 'Missing config.account_name'
41
+ raise Errors::ConfigurationError, 'Missing config.account_name'
42
42
  end
43
43
 
44
44
  config.password = value.fetch('password') do
45
- fail Errors::ConfigurationError, 'Missing config.password'
45
+ raise Errors::ConfigurationError, 'Missing config.password'
46
46
  end
47
47
 
48
48
  config.ssl = value['ssl'] if value['ssl']
@@ -12,8 +12,8 @@ module Filemaker
12
12
  super(convert_key(key))
13
13
  end
14
14
 
15
- alias_method :include?, :key?
16
- alias_method :member?, :key?
15
+ alias include? key?
16
+ alias member? key?
17
17
 
18
18
  def fetch(key, *extras)
19
19
  super(convert_key(key), *extras)
@@ -8,8 +8,8 @@ module Filemaker
8
8
 
9
9
  # @return [Filemaker::Store::LayoutStore] the layout store
10
10
  attr_reader :layouts
11
- alias_method :layout, :layouts
12
- alias_method :lay, :layouts
11
+ alias layout layouts
12
+ alias lay layouts
13
13
 
14
14
  # @return [Filemaker::Store::ScriptStore] the script store
15
15
  attr_reader :scripts
@@ -7,7 +7,7 @@ module Filemaker
7
7
 
8
8
  criteria.instance_exec(response.response['hits']['hits']) do |hits|
9
9
  define_singleton_method :to_a do
10
- self.entries.sort_by do |e|
10
+ entries.sort_by do |e|
11
11
  hits.index { |hit| hit['_id'].to_s == e.id.to_s }
12
12
  end
13
13
  end
@@ -23,8 +23,12 @@ module Filemaker
23
23
 
24
24
  # @return [Filemaker::Resultset]
25
25
  def perform_request(action, args, options)
26
- response, params = server
27
- .perform_request(:post, action, default_params.merge(args), options)
26
+ response, params = server.perform_request(
27
+ :post,
28
+ action,
29
+ default_params.merge(args),
30
+ options
31
+ )
28
32
 
29
33
  Filemaker::Resultset.new(server, response.body, params)
30
34
  end
@@ -34,7 +34,7 @@ module Filemaker
34
34
  end
35
35
 
36
36
  def model_key
37
- @model_cache_key ||= "#{self.class.model_name.cache_key}"
37
+ @model_cache_key ||= self.class.model_name.cache_key
38
38
  end
39
39
 
40
40
  def cache_key
@@ -108,7 +108,7 @@ module Filemaker
108
108
  end
109
109
 
110
110
  def default_per_page
111
- self.per_page
111
+ per_page
112
112
  end
113
113
 
114
114
  # Make use of -view to return an array of [name, data_type] for this
@@ -16,7 +16,7 @@ module Filemaker
16
16
  include ActiveModel::Model
17
17
  include ActiveModel::Dirty
18
18
  include ActiveModel::Serializers::JSON
19
- include ActiveModel::Serializers::Xml
19
+ # include ActiveModel::Serializers::Xml
20
20
  include ActiveModel::Validations::Callbacks
21
21
  include Fields
22
22
  include Relations
@@ -90,8 +90,8 @@ module Filemaker
90
90
 
91
91
  if defined?(Kaminari) && paginated
92
92
  Kaminari.paginate_array(models, total_count: resultset.count)
93
- .page(@_page)
94
- .per(options[:max])
93
+ .page(@_page)
94
+ .per(options[:max])
95
95
  else
96
96
  models
97
97
  end
@@ -20,6 +20,7 @@ module Filemaker
20
20
  def coerce(value)
21
21
  return nil if value.nil?
22
22
  return value if value == '==' || value == '=*'
23
+ return value if value =~ /(\.\.\.)/
23
24
 
24
25
  if @type == String
25
26
  value.to_s
@@ -25,7 +25,7 @@ module Filemaker
25
25
  money: BigDecimal,
26
26
  number: BigDecimal,
27
27
  integer: Integer
28
- }
28
+ }.freeze
29
29
 
30
30
  included do
31
31
  class_attribute :fields, :identity
@@ -48,8 +48,8 @@ module Filemaker
48
48
 
49
49
  next unless field
50
50
 
51
- direction = 'ascend' if direction.downcase == 'asc'
52
- direction = 'descend' if direction.downcase == 'desc'
51
+ direction = 'ascend' if direction.casecmp('ASC').zero?
52
+ direction = 'descend' if direction.casecmp('DESC').zero?
53
53
 
54
54
  sortfield << field.fm_name
55
55
  sortorder << direction
@@ -66,6 +66,7 @@ module Filemaker
66
66
  end
67
67
  freeze
68
68
  end
69
+
69
70
  alias_method :delete, :destroy
70
71
 
71
72
  # If value is nil, we convert to empty string so it will get pick up by
@@ -50,8 +50,10 @@ module Filemaker
50
50
  #
51
51
  # @return [Filemaker::Model] the actual model
52
52
  def build(attrs = {})
53
- attrs.merge!(owner.identity.name => owner.identity_id) if \
54
- owner.identity_id
53
+ # attrs.merge!(owner.identity.name => owner.identity_id) if \
54
+ # owner.identity_id
55
+ #
56
+ attrs[owner.identity.name] = owner.identity_id if owner.identity_id
55
57
  target_class.new(attrs)
56
58
  end
57
59
 
@@ -7,8 +7,8 @@ module Filemaker
7
7
  #
8
8
  # @return [Filemaker::Model::Criteria]
9
9
  def where(criterion)
10
- fail Filemaker::Errors::MixedClauseError,
11
- "Can't mix 'where' with 'in'." if chains.include?(:in)
10
+ raise Filemaker::Errors::MixedClauseError,
11
+ "Can't mix 'where' with 'in'." if chains.include?(:in)
12
12
  chains.push(:where)
13
13
 
14
14
  @selector ||= {}
@@ -54,17 +54,17 @@ module Filemaker
54
54
 
55
55
  %w(eq cn bw ew gt gte lt lte neq).each do |operator|
56
56
  define_method(operator) do |criterion, &block|
57
- fail Filemaker::Errors::MixedClauseError,
58
- "Can't mix 'where' with 'in'." if chains.include?(:in)
57
+ raise Filemaker::Errors::MixedClauseError,
58
+ "Can't mix 'where' with 'in'." if chains.include?(:in)
59
59
  chains.push(operator.to_sym)
60
60
  chains.push(:where) unless chains.include?(:where) # Just one time
61
61
  @selector ||= {}
62
62
 
63
- if operator == 'bw'
64
- criterion = klass.with_model_fields(criterion, false)
65
- else
66
- criterion = klass.with_model_fields(criterion)
67
- end
63
+ criterion = if operator == 'bw'
64
+ klass.with_model_fields(criterion, false)
65
+ else
66
+ klass.with_model_fields(criterion)
67
+ end
68
68
 
69
69
  criterion.each_key do |key|
70
70
  selector["#{key}.op"] = operator
@@ -97,8 +97,8 @@ module Filemaker
97
97
  #
98
98
  # @return [Filemaker::Model::Criteria]
99
99
  def in(criterion, negating = false)
100
- fail Filemaker::Errors::MixedClauseError,
101
- "Can't mix 'in' with 'where'." if chains.include?(:where)
100
+ raise Filemaker::Errors::MixedClauseError,
101
+ "Can't mix 'in' with 'where'." if chains.include?(:where)
102
102
  chains.push(:in)
103
103
  @selector ||= []
104
104
 
@@ -127,8 +127,8 @@ module Filemaker
127
127
  #
128
128
  # @return [Filemaker::Model::Criteria]
129
129
  def or(criterion)
130
- fail Filemaker::Errors::MixedClauseError,
131
- "Can't mix 'or' with 'in'." if chains.include?(:in)
130
+ raise Filemaker::Errors::MixedClauseError,
131
+ "Can't mix 'or' with 'in'." if chains.include?(:in)
132
132
  @selector ||= {}
133
133
  selector.merge!(klass.with_model_fields(criterion))
134
134
  options[:lop] = 'or'
@@ -9,7 +9,7 @@ module Rails
9
9
  if config_file.file?
10
10
  ::Filemaker.load!(config_file, Rails.env)
11
11
  else
12
- fail ::Filemaker::Errors::ConfigurationError, 'No config file'
12
+ raise ::Filemaker::Errors::ConfigurationError, 'No config file'
13
13
  end
14
14
  end
15
15
  end
@@ -45,14 +45,14 @@ module Filemaker
45
45
  end
46
46
 
47
47
  def [](key)
48
- fail(Filemaker::Errors::InvalidFieldError, "Invalid field: #{key}") \
48
+ raise(Filemaker::Errors::InvalidFieldError, "Invalid field: #{key}") \
49
49
  unless key?(key)
50
50
  super
51
51
  end
52
52
 
53
53
  def []=(key, value)
54
54
  return super unless @ready
55
- fail(Filemaker::Errors::InvalidFieldError, "Invalid field: #{key}") \
55
+ raise(Filemaker::Errors::InvalidFieldError, "Invalid field: #{key}") \
56
56
  unless key?(key)
57
57
  @dirty[key] = value
58
58
  end
@@ -99,7 +99,7 @@ module Filemaker
99
99
 
100
100
  metadata.xpath('relatedset-definition').each do |relatedset|
101
101
  table_name = relatedset.attribute('table').value
102
- p_fields = {}
102
+ p_fields = {}
103
103
 
104
104
  @portal_fields[table_name] ||= p_fields
105
105
 
@@ -20,7 +20,7 @@ module Filemaker
20
20
  def initialize(options = {})
21
21
  @config = Configuration.new
22
22
  yield @config if block_given?
23
- fail ArgumentError, 'Missing config block' if @config.not_configurable?
23
+ raise ArgumentError, 'Missing config block' if @config.not_configurable?
24
24
 
25
25
  @databases = Store::DatabaseStore.new(self)
26
26
  @connection = get_connection(options)
@@ -36,8 +36,8 @@ module Filemaker
36
36
  # @return [Array] Faraday::Response and request params Hash
37
37
  def perform_request(method, action, args, options = {})
38
38
  params = serialize_args(args)
39
- .merge(expand_options(options))
40
- .merge({ action => '' })
39
+ .merge(expand_options(options))
40
+ .merge({ action => '' })
41
41
 
42
42
  # Serialize the params for submission??
43
43
  params.stringify_keys!
@@ -49,13 +49,13 @@ module Filemaker
49
49
 
50
50
  case response.status
51
51
  when 200 then [response, params]
52
- when 401 then fail Errors::AuthenticationError, 'Auth failed.'
53
- when 0 then fail Errors::CommunicationError, 'Empty response.'
54
- when 404 then fail Errors::CommunicationError, 'HTTP 404 Not Found'
55
- when 302 then fail Errors::CommunicationError, 'Redirect not supported'
52
+ when 401 then raise Errors::AuthenticationError, 'Auth failed.'
53
+ when 0 then raise Errors::CommunicationError, 'Empty response.'
54
+ when 404 then raise Errors::CommunicationError, 'HTTP 404 Not Found'
55
+ when 302 then raise Errors::CommunicationError, 'Redirect not supported'
56
56
  else
57
57
  msg = "Unknown response status = #{response.status}"
58
- fail Errors::CommunicationError, msg
58
+ raise Errors::CommunicationError, msg
59
59
  end
60
60
  end
61
61
 
@@ -105,7 +105,7 @@ module Filemaker
105
105
  when :sortfield
106
106
  if value.is_a? Array
107
107
  msg = 'Too many sortfield, limit=9'
108
- fail(Filemaker::Errors::ParameterError, msg) if value.size > 9
108
+ raise(Filemaker::Errors::ParameterError, msg) if value.size > 9
109
109
  value.each_index do |index|
110
110
  expanded["-sortfield.#{index + 1}"] = value[index]
111
111
  end
@@ -116,7 +116,7 @@ module Filemaker
116
116
  if value.is_a? Array
117
117
  # Use :sortfield as single source of truth for array size
118
118
  msg = 'Too many sortorder, limit=9'
119
- fail(Filemaker::Errors::ParameterError, msg) if value.size > 9
119
+ raise(Filemaker::Errors::ParameterError, msg) if value.size > 9
120
120
  options[:sortfield].each_index do |index|
121
121
  expanded["-sortorder.#{index + 1}"] = value[index] || 'ascend'
122
122
  end
@@ -174,8 +174,9 @@ module Filemaker
174
174
  end
175
175
 
176
176
  def log_curl(params, has_auth = false)
177
- full_url = "#{url}#{endpoint}?#{log_params(params)}"
178
- curl_ssl_option, auth = '', ''
177
+ full_url = "#{url}#{endpoint}?#{log_params(params)}"
178
+ curl_ssl_option = ''
179
+ auth = ''
179
180
 
180
181
  curl_ssl_option = ' -k' if ssl.is_a?(Hash) && !ssl.fetch(:verify) { true }
181
182
 
@@ -1,3 +1,3 @@
1
1
  module Filemaker
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'.freeze
3
3
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Api::QueryCommands::CompoundFind do
2
-
3
2
  context 'with hash' do
4
3
  it '{a: [1, 2]} to (q0);(q1)' do
5
4
  expect(Filemaker::Api::QueryCommands::CompoundFind.new(
@@ -59,7 +58,6 @@ describe Filemaker::Api::QueryCommands::CompoundFind do
59
58
 
60
59
  it '[{a: [1, 2, 3], b: 1}, {c: 4, "-omit" => true}] to
61
60
  (q0,q3);(q1,q3);(q2,q3);!(q4)' do
62
-
63
61
  expect(Filemaker::Api::QueryCommands::CompoundFind.new(
64
62
  [{ a: [1, 2, 3], b: 1 }, { c: 4, '-omit' => true }]
65
63
  ).key_maps_string).to eq '(q0,q3);(q1,q3);(q2,q3);!(q4)'
@@ -77,5 +75,4 @@ describe Filemaker::Api::QueryCommands::CompoundFind do
77
75
  ).key_maps_string).to eq '(q0);(q1);(q2);(q3)'
78
76
  end
79
77
  end
80
-
81
78
  end
@@ -1,5 +1,4 @@
1
1
  describe 'Configuration' do
2
-
3
2
  context 'with yaml file' do
4
3
  it 'load settings based on environment' do
5
4
  path = File.expand_path('../../support/filemaker.yml', __FILE__)
@@ -19,5 +18,4 @@ describe 'Configuration' do
19
18
  end.to raise_error Filemaker::Errors::ConfigurationError
20
19
  end
21
20
  end
22
-
23
21
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Errors do
2
-
3
2
  context '-1 to 100 errors' do
4
3
  it 'raises UnknownError for -1' do
5
4
  expect do
@@ -253,5 +252,4 @@ describe Filemaker::Errors do
253
252
  end.to raise_error Filemaker::Errors::UnableToOpenFileError
254
253
  end
255
254
  end
256
-
257
255
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Layout do
2
-
3
2
  it 'presets -db and -lay' do
4
3
  database = Filemaker::Database.new('candidates', double)
5
4
  layout = Filemaker::Layout.new('profile', double, database)
@@ -8,10 +7,9 @@ describe Filemaker::Layout do
8
7
  end
9
8
 
10
9
  context 'api' do
11
-
12
10
  before do
13
11
  @server = Filemaker::Server.new do |config|
14
- config.host = 'example'
12
+ config.host = 'example.com'
15
13
  config.account_name = 'account_name'
16
14
  config.password = 'password'
17
15
  end
@@ -182,7 +180,6 @@ describe Filemaker::Layout do
182
180
 
183
181
  it 'transforms [{a:1, b:2}, {c:3}, {d:4}, {e:5, "-omit": true}] to \
184
182
  (q0,q1);(q2);(q3);!(q4)' do
185
-
186
183
  resultset = @layout.query(
187
184
  [{ a: 1, b: 2 }, { c: 3 }, { d: 4 }, { e: 5, '-omit' => true }]
188
185
  )
@@ -58,5 +58,4 @@ describe Filemaker::Metadata::Field do
58
58
  'https://host/fmi/xml/cnt/1234jpg'
59
59
  end
60
60
  end
61
-
62
61
  end
@@ -1,38 +1,35 @@
1
1
  describe Filemaker::Model::Builder do
2
-
3
2
  let(:model) { Job }
4
3
  let(:server) { Object.new }
5
4
  let(:xml) { import_xml_as_string('jobs.xml') }
6
5
  let(:resultset) { Filemaker::Resultset.new(server, xml) }
7
6
 
8
7
  context '.build' do
9
-
10
- let(:subject) {
8
+ let(:subject) do
11
9
  Filemaker::Model::Builder.build(resultset.first, model.new)
12
- }
10
+ end
13
11
 
14
12
  it 'has portals' do
15
13
  expect(subject.portals.keys).to eq([])
16
14
  end
17
15
 
18
16
  it 'has a status' do
19
- expect(subject.status).to eq("open")
17
+ expect(subject.status).to eq('open')
20
18
  end
21
-
19
+
22
20
  it 'has an jdid' do
23
- expect(subject.jdid).to eq("JID1122")
21
+ expect(subject.jdid).to eq('JID1122')
24
22
  end
25
-
23
+
26
24
  it 'has a modify_date' do
27
25
  expect(subject.modify_date).to eq(Date.parse('2014-08-12'))
28
26
  end
29
27
  end
30
28
 
31
29
  context '.collection' do
32
-
33
- let(:subject) {
30
+ let(:subject) do
34
31
  Filemaker::Model::Builder.collection(resultset, model)
35
- }
32
+ end
36
33
 
37
34
  it 'is an array of Jobs' do
38
35
  subject.each do |job|
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Model::Criteria do
2
-
3
2
  let(:criteria) { Filemaker::Model::Criteria.new(MyModel) }
4
3
  let(:cf) { Filemaker::Api::QueryCommands::CompoundFind }
5
4
 
@@ -130,7 +129,7 @@ describe Filemaker::Model::Criteria do
130
129
  expect(compound_find.key_maps_string).to eq \
131
130
  '(q0,q2);(q0,q3);(q1,q2);(q1,q3)'
132
131
  expect(criteria.selector).to eq \
133
- [{ 'name' => %w(Bob Lee), 'passage of time' => [20, 30] }]
132
+ [{ 'name' => %w(Bob Lee), 'passage of time' => [20, 30] }]
134
133
  end
135
134
 
136
135
  it '{a: [1, 2], b: 3} to (q0,q2);(q1,q2)' do
@@ -315,5 +314,4 @@ describe Filemaker::Model::Criteria do
315
314
  expect(criteria.per(50).options[:skip]).to be_nil
316
315
  end
317
316
  end
318
-
319
317
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Model::Relations do
2
-
3
2
  it 'every model has a relations hash' do
4
3
  expect(MyModel.new.relations).to eq({})
5
4
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Model do
2
-
3
2
  let(:model) { MyModel.new }
4
3
 
5
4
  it 'sets up -db and -lay' do
@@ -12,10 +11,10 @@ describe Filemaker::Model do
12
11
  it 'sets up server and api' do
13
12
  expect(MyModel.api.default_params).to eq \
14
13
  ({ '-db' => :candidates, '-lay' => :profile })
15
- expect(MyModel.server.host).to eq 'example'
14
+ expect(MyModel.server.host).to eq 'example.com'
16
15
  expect(model.api.default_params).to eq \
17
16
  ({ '-db' => :candidates, '-lay' => :profile })
18
- expect(model.server.host).to eq 'example'
17
+ expect(model.server.host).to eq 'example.com'
19
18
  end
20
19
 
21
20
  it 'is a new record' do
@@ -55,6 +54,16 @@ describe Filemaker::Model do
55
54
  expect(model.created_at).to be_a Date
56
55
  end
57
56
 
57
+ it 'accepts date range as string' do
58
+ model.created_at = '1/1/2016...1/31/2016'
59
+ expect(model.created_at).to be_a String
60
+ end
61
+
62
+ it 'accepts number range as string' do
63
+ model.salary = '1000...2000'
64
+ expect(model.salary).to be_a String
65
+ end
66
+
58
67
  it 'check for presence of name and salary' do
59
68
  expect(model.name?).to be true
60
69
  expect(model.salary?).to be false
@@ -98,8 +107,7 @@ describe Filemaker::Model do
98
107
  model.name = 'Bob'
99
108
  expect(model.changed?).to be true
100
109
  expect(model.changed).to eq ['name']
101
- expect(model.dirty_attributes).to eq({'name' => 'Bob'})
110
+ expect(model.dirty_attributes).to eq({ 'name' => 'Bob' })
102
111
  end
103
112
  end
104
-
105
113
  end
@@ -8,7 +8,8 @@ describe Filemaker::Record do
8
8
 
9
9
  xml = import_xml_as_string('portal.xml')
10
10
  resultset = Filemaker::Resultset.new(server, xml)
11
- records = Nokogiri::XML(xml).remove_namespaces!.xpath('/fmresultset/resultset/record')
11
+ path = '/fmresultset/resultset/record'
12
+ records = Nokogiri::XML(xml).remove_namespaces!.xpath(path)
12
13
  @record = Filemaker::Record.new(records.first, resultset)
13
14
  end
14
15
 
@@ -59,5 +60,4 @@ describe Filemaker::Record do
59
60
  expect(@record.dirty).to eq({ 'year' => 2014 })
60
61
  end
61
62
  end
62
-
63
63
  end
@@ -67,5 +67,4 @@ describe Filemaker::Resultset do
67
67
  expect(resultset.list.size).to eq 2
68
68
  end
69
69
  end
70
-
71
70
  end
@@ -1,15 +1,14 @@
1
1
  describe Filemaker::Server do
2
-
3
2
  context 'initializing a server' do
4
3
  it 'provides a host, account_name, and password' do
5
4
  server = Filemaker::Server.new do |config|
6
- config.host = 'example'
5
+ config.host = 'example.com'
7
6
  config.account_name = 'account_name'
8
7
  config.password = 'password'
9
8
  end
10
9
 
11
- expect(server.host).to eq 'example'
12
- expect(server.url).to eq 'http://example'
10
+ expect(server.host).to eq 'example.com'
11
+ expect(server.url).to eq 'http://example.com'
13
12
  expect(server.account_name).to eq 'account_name'
14
13
  expect(server.password).to eq 'password'
15
14
  expect(server.connection).to be_a Faraday::Connection
@@ -21,13 +20,13 @@ describe Filemaker::Server do
21
20
 
22
21
  it 'specifically ask for no SSL' do
23
22
  server = Filemaker::Server.new do |config|
24
- config.host = 'example'
23
+ config.host = 'example.com'
25
24
  config.account_name = 'account_name'
26
25
  config.password = 'password'
27
26
  config.ssl = false
28
27
  end
29
28
 
30
- expect(server.url).to eq 'http://example'
29
+ expect(server.url).to eq 'http://example.com'
31
30
  end
32
31
 
33
32
  it 'did not provide host, account_name, and password' do
@@ -36,7 +35,7 @@ describe Filemaker::Server do
36
35
  end.to raise_error ArgumentError
37
36
 
38
37
  expect do
39
- Filemaker::Server.new { |config| config.host = 'example' }
38
+ Filemaker::Server.new { |config| config.host = 'example.com' }
40
39
  end.to raise_error ArgumentError
41
40
  end
42
41
  end
@@ -44,13 +43,13 @@ describe Filemaker::Server do
44
43
  context 'initializing a server with SSL' do
45
44
  it 'indicates secured connection' do
46
45
  server = Filemaker::Server.new do |config|
47
- config.host = 'example'
46
+ config.host = 'example.com'
48
47
  config.account_name = 'account_name'
49
48
  config.password = 'password'
50
49
  config.ssl = { verify: false }
51
50
  end
52
51
 
53
- expect(server.url).to eq 'https://example'
52
+ expect(server.url).to eq 'https://example.com'
54
53
  expect(server.connection.ssl[:verify]).to be false
55
54
  end
56
55
  end
@@ -58,7 +57,7 @@ describe Filemaker::Server do
58
57
  describe 'databases is a store to track encountered -db' do
59
58
  it 'stores database object and can be accessed with db and database' do
60
59
  server = Filemaker::Server.new do |config|
61
- config.host = 'example'
60
+ config.host = 'example.com'
62
61
  config.account_name = 'account_name'
63
62
  config.password = 'password'
64
63
  end
@@ -72,7 +71,7 @@ describe Filemaker::Server do
72
71
  context 'HTTP errors' do
73
72
  before do
74
73
  @server = Filemaker::Server.new do |config|
75
- config.host = 'example'
74
+ config.host = 'example.com'
76
75
  config.account_name = 'account_name'
77
76
  config.password = 'password'
78
77
  end
@@ -102,5 +101,4 @@ describe Filemaker::Server do
102
101
  end.to raise_error Filemaker::Errors::AuthenticationError
103
102
  end
104
103
  end
105
-
106
104
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Store::DatabaseStore do
2
-
3
2
  it 'is a Hash' do
4
3
  store = Filemaker::Store::DatabaseStore.new(double(:server))
5
4
  expect(store).to be_a Hash
@@ -16,7 +15,7 @@ describe Filemaker::Store::DatabaseStore do
16
15
  describe 'all' do
17
16
  it 'returns all databases' do
18
17
  server = Filemaker::Server.new do |config|
19
- config.host = 'example'
18
+ config.host = 'example.com'
20
19
  config.account_name = 'account_name'
21
20
  config.password = 'password'
22
21
  end
@@ -30,5 +29,4 @@ describe Filemaker::Store::DatabaseStore do
30
29
  expect(server.db.all).to eq expected_result
31
30
  end
32
31
  end
33
-
34
32
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Store::LayoutStore do
2
-
3
2
  it 'is a Hash' do
4
3
  store = Filemaker::Store::LayoutStore.new(double, double)
5
4
  expect(store).to be_a Hash
@@ -16,7 +15,7 @@ describe Filemaker::Store::LayoutStore do
16
15
  describe 'all' do
17
16
  it 'returns all layouts for a database' do
18
17
  server = Filemaker::Server.new do |config|
19
- config.host = 'example'
18
+ config.host = 'example.com'
20
19
  config.account_name = 'account_name'
21
20
  config.password = 'password'
22
21
  end
@@ -27,5 +26,4 @@ describe Filemaker::Store::LayoutStore do
27
26
  ['Dashboard', 'Calender', 'Profile', 'Resume', 'Job Application']
28
27
  end
29
28
  end
30
-
31
29
  end
@@ -1,5 +1,4 @@
1
1
  describe Filemaker::Store::ScriptStore do
2
-
3
2
  it 'is a Hash' do
4
3
  store = Filemaker::Store::ScriptStore.new(double, double)
5
4
  expect(store).to be_a Hash
@@ -16,7 +15,7 @@ describe Filemaker::Store::ScriptStore do
16
15
  describe 'all' do
17
16
  it 'returns all scripts for a database' do
18
17
  server = Filemaker::Server.new do |config|
19
- config.host = 'example'
18
+ config.host = 'example.com'
20
19
  config.account_name = 'account_name'
21
20
  config.password = 'password'
22
21
  end
@@ -27,5 +26,4 @@ describe Filemaker::Store::ScriptStore do
27
26
  ['library', 'open job', 'copy resume']
28
27
  end
29
28
  end
30
-
31
29
  end
@@ -81,5 +81,4 @@ RSpec.configure do |config|
81
81
  # a real object. This is generally recommended.
82
82
  mocks.verify_partial_doubles = true
83
83
  end
84
-
85
84
  end
@@ -1,5 +1,5 @@
1
1
  Filemaker.registry['default'] = Filemaker::Server.new do |config|
2
- config.host = 'example'
2
+ config.host = 'example.com'
3
3
  config.account_name = 'account_name'
4
4
  config.password = 'password'
5
5
  end
@@ -27,7 +27,6 @@ class Job
27
27
  string :status
28
28
  string :jdid, fm_name: 'JDID'
29
29
  date :modify_date, fm_name: 'modify date'
30
-
31
30
  end
32
31
 
33
32
  class MyModel
@@ -36,15 +35,15 @@ class MyModel
36
35
  database :candidates
37
36
  layout :profile
38
37
 
38
+ belongs_to :candidate
39
+ belongs_to :applicant, class_name: User, reference_key: :name
40
+ has_many :posts
41
+ has_many :posters, class_name: User, reference_key: :email
42
+
39
43
  string :name, :email, default: 'UNTITLED'
40
44
  string :candidate_id, fm_name: 'CA ID', identity: true
41
45
  date :created_at
42
46
  datetime :updated_at, fm_name: 'ModifiedDate'
43
47
  money :salary
44
48
  integer :age, fm_name: 'passage of time'
45
-
46
- belongs_to :candidate
47
- belongs_to :applicant, class_name: User, reference_key: :name
48
- has_many :posts
49
- has_many :posters, class_name: User, reference_key: :email
50
49
  end
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.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - mech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project:
246
- rubygems_version: 2.5.1
246
+ rubygems_version: 2.6.2
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: A Ruby wrapper to FileMaker XML API.