filemaker 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c7d9adebe5082b877308f9f9288ac84e10c264c
4
- data.tar.gz: ea39999151fd8c509658a39c84428ef436a3c870
3
+ metadata.gz: 5ee29da2611c5857916b7f97e6785080495caafb
4
+ data.tar.gz: 85142a5af79b15ca89df2c2df05c272ece4c1b96
5
5
  SHA512:
6
- metadata.gz: 5afdcecee22c8fcae980cb5044bbef9d3a7b17856c8b8583a3d8c2f4b4e393539d73da5a43b9461eef6910f501b448c03e2a9a093653ce1ef31ffa4e08c861c0
7
- data.tar.gz: d6c55a51482c889e3931f281c13a9a7edb67202e5a46c6e8da596c6d11c69eee42fb1c8608d27f84efa42b44b4e3153f429690c31b7c640f9529d687127daff4
6
+ metadata.gz: bdf8376dfd66c133f426264a67e5c2aaf0277d90561436f9a3944bcb91100c4a55dcb65457181b8a88d349369348b970e46d5fe086bec2753eb64539292213ef
7
+ data.tar.gz: 378d3ba7d1f34637dce2913fb5961c89c8717e28923df5089668e6e56ae8b44b788b5007d4248cce4540a65de71b81517bc56582573f4d87545f76cd1be8fb32
@@ -22,3 +22,21 @@ SpecialGlobalVars:
22
22
 
23
23
  PredicateName:
24
24
  Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Max: 50
28
+
29
+ Metrics/ClassLength:
30
+ Max: 200
31
+
32
+ Metrics/BlockLength:
33
+ Max: 100
34
+
35
+ Metrics/CyclomaticComplexity:
36
+ Enabled: false
37
+
38
+ Metrics/PerceivedComplexity:
39
+ Enabled: false
40
+
41
+ Style/DoubleNegation:
42
+ Enabled: false
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
+ - 2.4.0
4
5
  script: "bundle exec rake"
@@ -1,22 +1,21 @@
1
- Copyright (c) 2014 mech
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2017 mech
4
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:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
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.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -197,8 +197,8 @@ Note: It is vitally important that you get the order right for mixing in the use
197
197
  - [x] Please test the comparison operators with keyword as well as applied to value.
198
198
  - [x] Test serialization of BigDecimal and other types.
199
199
  - [x] Caching of relation models.
200
+ - [x] Dirty checking API for model.
200
201
  - [ ] Test the order for `in` and `not_in` found set accuracy.
201
- - [ ] Dirty checking API for model.
202
202
 
203
203
  ## Pagination
204
204
 
@@ -222,6 +222,10 @@ end
222
222
  Job.per_page # => 50
223
223
  ```
224
224
 
225
+ ## Overview
226
+
227
+ `Model` include `Findable` which create `Criteria` and `execute()` to return `Resultset` to be built by `Builder`.
228
+
225
229
  ## Credits
226
230
 
227
231
  This project is heavily inspired by the following Filemaker Ruby effort and several other ORM gems.
@@ -20,13 +20,13 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency 'faraday'
22
22
  spec.add_runtime_dependency 'typhoeus'
23
- spec.add_runtime_dependency 'nokogiri'
23
+ spec.add_runtime_dependency 'nokogiri', '~> 1.7'
24
24
  spec.add_runtime_dependency 'activemodel'
25
25
  spec.add_runtime_dependency 'globalid'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 1.11'
28
- spec.add_development_dependency 'rake', '~> 11.0'
29
- spec.add_development_dependency 'rspec', '~> 3.1'
27
+ spec.add_development_dependency 'bundler', '~> 1.13'
28
+ spec.add_development_dependency 'rake', '~> 12.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.5'
30
30
  spec.add_development_dependency 'rubocop'
31
31
  spec.add_development_dependency 'pry-byebug'
32
32
  end
@@ -80,7 +80,8 @@ module Filemaker
80
80
  omit = q_tag_array.delete('-omit')
81
81
  len = q_tag_array.length
82
82
  result = q_tag_array.flatten.combination(len).select do |c|
83
- q_tag_array.all? { |a| (a & c).size > 0 }
83
+ # q_tag_array.all? { |a| (a & c).size > 0 }
84
+ q_tag_array.all? { |a| !(a & c).empty? }
84
85
  end
85
86
  result = result.each { |c| c.unshift('-omit') if omit }
86
87
  @key_maps.concat result
@@ -21,8 +21,12 @@ module Filemaker
21
21
  ssl.is_a?(Hash) ? { ssl: ssl } : {}
22
22
  end
23
23
 
24
+ def is_ssl?
25
+ ssl.is_a?(Hash) || ssl == true
26
+ end
27
+
24
28
  def url
25
- (ssl.is_a?(Hash) || ssl == true) ? "https://#{host}" : "http://#{host}"
29
+ is_ssl? ? "https://#{host}" : "http://#{host}"
26
30
  end
27
31
  end
28
32
  end
@@ -33,13 +33,17 @@ module Filemaker
33
33
  @resultset = resultset
34
34
  end
35
35
 
36
+ def remove_decimal_mark(value)
37
+ value.delete('$,')
38
+ end
39
+
36
40
  def coerce(value)
37
41
  value = value.to_s.strip
38
42
  return nil if value.empty?
39
43
 
40
44
  case data_type
41
45
  when 'number'
42
- BigDecimal.new(value)
46
+ BigDecimal.new(remove_decimal_mark(value))
43
47
  when 'date'
44
48
  # date_format likely will be '%m/%d/%Y', but if we got '19/8/2014',
45
49
  # then `strptime` will raise invalid date error
@@ -42,7 +42,7 @@ module Filemaker
42
42
  else
43
43
  value
44
44
  end
45
- rescue Exception => e
45
+ rescue StandardError => e
46
46
  warn "[#{e.message}] Could not coerce #{name}: #{value}"
47
47
  value
48
48
  end
@@ -67,7 +67,7 @@ module Filemaker
67
67
  freeze
68
68
  end
69
69
 
70
- alias_method :delete, :destroy
70
+ alias delete destroy
71
71
 
72
72
  # If value is nil, we convert to empty string so it will get pick up by
73
73
  # `fm_attributes`
@@ -25,8 +25,8 @@ module Filemaker
25
25
  # all must be findable using `to find_field_by_name`
26
26
  def final_reference_key
27
27
  target_class.find_field_by_name(source_key).try(:name) ||
28
- target_class.find_field_by_name(reference_key).try(:name) ||
29
- target_class.identity.try(:name)
28
+ target_class.find_field_by_name(reference_key).try(:name) ||
29
+ target_class.identity.try(:name)
30
30
  end
31
31
 
32
32
  protected
@@ -25,8 +25,8 @@ module Filemaker
25
25
 
26
26
  def final_reference_key
27
27
  target_class.find_field_by_name(source_key).try(:name) ||
28
- target_class.find_field_by_name(reference_key).try(:name) ||
29
- target_class.identity.try(:name)
28
+ target_class.find_field_by_name(reference_key).try(:name) ||
29
+ target_class.identity.try(:name)
30
30
  end
31
31
 
32
32
  # Append a model or array of models to the relation. Will set the owner
@@ -47,7 +47,7 @@ module Filemaker
47
47
  end
48
48
  self
49
49
  end
50
- alias_method :push, :<<
50
+ alias push <<
51
51
 
52
52
  # def concat(docs)
53
53
  # # TODO: Find out how to do batch insert in FileMaker
@@ -27,7 +27,11 @@ module Filemaker
27
27
  end
28
28
 
29
29
  def method_missing(name, *args, &block)
30
- target.send(name, *args, &block)
30
+ target.send(name, *args, &block) || super
31
+ end
32
+
33
+ def respond_to_missing?(method_name, include_private = false)
34
+ super
31
35
  end
32
36
  end
33
37
  end
@@ -7,8 +7,11 @@ module Filemaker
7
7
  #
8
8
  # @return [Filemaker::Model::Criteria]
9
9
  def where(criterion)
10
- raise Filemaker::Errors::MixedClauseError,
11
- "Can't mix 'where' with 'in'." if chains.include?(:in)
10
+ if chains.include?(:in)
11
+ raise Filemaker::Errors::MixedClauseError,
12
+ "Can't mix 'where' with 'in'."
13
+ end
14
+
12
15
  chains.push(:where)
13
16
  chains.delete(:in)
14
17
 
@@ -55,8 +58,11 @@ module Filemaker
55
58
 
56
59
  %w(eq cn bw ew gt gte lt lte neq).each do |operator|
57
60
  define_method(operator) do |criterion, &block|
58
- raise Filemaker::Errors::MixedClauseError,
59
- "Can't mix 'where' with 'in'." if chains.include?(:in)
61
+ if chains.include?(:in)
62
+ raise Filemaker::Errors::MixedClauseError,
63
+ "Can't mix 'where' with 'in'."
64
+ end
65
+
60
66
  chains.push(operator.to_sym)
61
67
  chains.push(:where) unless chains.include?(:where) # Just one time
62
68
  chains.delete(:in)
@@ -81,11 +87,11 @@ module Filemaker
81
87
  end
82
88
  end
83
89
 
84
- alias_method :equals, :eq
85
- alias_method :contains, :cn
86
- alias_method :begins_with, :bw
87
- alias_method :ends_with, :ew
88
- alias_method :not, :neq
90
+ alias equals eq
91
+ alias contains cn
92
+ alias begins_with bw
93
+ alias ends_with ew
94
+ alias not neq
89
95
 
90
96
  # Find records based on FileMaker's compound find syntax.
91
97
  #
@@ -99,15 +105,18 @@ module Filemaker
99
105
  #
100
106
  # @return [Filemaker::Model::Criteria]
101
107
  def in(criterion, negating = false)
102
- raise Filemaker::Errors::MixedClauseError,
103
- "Can't mix 'in' with 'where'." if chains.include?(:where)
108
+ if chains.include?(:where)
109
+ raise Filemaker::Errors::MixedClauseError,
110
+ "Can't mix 'in' with 'where'."
111
+ end
112
+
104
113
  chains.push(:in)
105
114
  chains.delete(:where)
106
115
  @selector ||= []
107
116
 
108
117
  become_array(criterion).each do |hash|
109
118
  accepted_hash = klass.with_model_fields(hash)
110
- accepted_hash.merge!('-omit' => true) if negating
119
+ accepted_hash['-omit'] = true if negating
111
120
  @selector << accepted_hash
112
121
  end
113
122
 
@@ -138,8 +147,11 @@ module Filemaker
138
147
  #
139
148
  # @return [Filemaker::Model::Criteria]
140
149
  def or(criterion)
141
- raise Filemaker::Errors::MixedClauseError,
142
- "Can't mix 'or' with 'in'." if chains.include?(:in)
150
+ if chains.include?(:in)
151
+ raise Filemaker::Errors::MixedClauseError,
152
+ "Can't mix 'or' with 'in'."
153
+ end
154
+
143
155
  @selector ||= {}
144
156
  selector.merge!(klass.with_model_fields(criterion))
145
157
  options[:lop] = 'or'
@@ -6,11 +6,11 @@ module Rails
6
6
  initializer 'filemaker-load-config-yml' do
7
7
  config_file = Rails.root.join('config', 'filemaker.yml')
8
8
 
9
- if config_file.file?
10
- ::Filemaker.load!(config_file, Rails.env)
11
- else
9
+ unless config_file.file?
12
10
  raise ::Filemaker::Errors::ConfigurationError, 'No config file'
13
11
  end
12
+
13
+ ::Filemaker.load!(config_file, Rails.env)
14
14
  end
15
15
  end
16
16
  end
@@ -77,7 +77,7 @@ module Filemaker
77
77
 
78
78
  def normalize_data(datum)
79
79
  return nil if datum.empty?
80
- (datum.size == 1) ? datum.first : datum
80
+ datum.size == 1 ? datum.first : datum
81
81
  end
82
82
 
83
83
  def method_missing(symbol, *args, &block)
@@ -86,5 +86,9 @@ module Filemaker
86
86
  return @dirty[$`] = args.first if method =~ /(=)$/ && key?($`)
87
87
  super
88
88
  end
89
+
90
+ def respond_to_missing?
91
+ super
92
+ end
89
93
  end
90
94
  end
@@ -79,7 +79,7 @@ module Filemaker
79
79
  def size
80
80
  list.size
81
81
  end
82
- alias_method :length, :size
82
+ alias length size
83
83
 
84
84
  private
85
85
 
@@ -11,8 +11,8 @@ module Filemaker
11
11
 
12
12
  # @return [Filemaker::Store::DatabaseStore] the database store
13
13
  attr_reader :databases
14
- alias_method :database, :databases
15
- alias_method :db, :databases
14
+ alias database databases
15
+ alias db databases
16
16
 
17
17
  def_delegators :@config, :host, :url, :ssl, :endpoint, :log
18
18
  def_delegators :@config, :account_name, :password
@@ -168,8 +168,6 @@ module Filemaker
168
168
  when :simple then log_simple(params)
169
169
  when :curl then log_curl(params)
170
170
  when :curl_auth then log_curl(params, true)
171
- else
172
- return
173
171
  end
174
172
  end
175
173
 
@@ -188,7 +186,7 @@ module Filemaker
188
186
  end
189
187
 
190
188
  def log_simple(params)
191
- warn "#{endpoint}?#{log_params(params)}"
189
+ warn colorize('48;2;255;0;0', "#{endpoint}?#{log_params(params)}")
192
190
  end
193
191
 
194
192
  def log_params(params)
@@ -196,5 +194,9 @@ module Filemaker
196
194
  "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
197
195
  end.join('&')
198
196
  end
197
+
198
+ def colorize(color, message)
199
+ "\e[#{color}m#{message}\e[0m"
200
+ end
199
201
  end
200
202
  end
@@ -1,3 +1,3 @@
1
1
  module Filemaker
2
- VERSION = '0.0.17'.freeze
2
+ VERSION = '0.0.18'.freeze
3
3
  end
@@ -36,6 +36,18 @@ describe Filemaker::Metadata::Field do
36
36
  expect(field.coerce('100')).to be_a BigDecimal
37
37
  end
38
38
 
39
+ it 'removes decimal mark in number' do
40
+ allow(field).to receive(:data_type).and_return 'number'
41
+ expect(field.coerce('49,028.39')).to be_a BigDecimal
42
+ expect(field.coerce('49,028.39')).to eq 49_028.39
43
+ end
44
+
45
+ it 'removes dollar sign in number' do
46
+ allow(field).to receive(:data_type).and_return 'number'
47
+ expect(field.coerce('$49,028.39')).to be_a BigDecimal
48
+ expect(field.coerce('$49,028.39')).to eq 49_028.39
49
+ end
50
+
39
51
  it 'converts date to Date' do
40
52
  allow(field).to receive(:data_type).and_return 'date'
41
53
  expect(field.coerce('10/31/2014')).to be_a Date
@@ -57,7 +57,10 @@ class MyModel
57
57
  belongs_to :applicant, class_name: User, reference_key: :name
58
58
  belongs_to :member
59
59
  belongs_to :manager, source_key: :mg_id
60
- belongs_to :another_manager, class_name: Manager, source_key: :mg_id, reference_key: :candidate_id
60
+ belongs_to :another_manager,
61
+ class_name: Manager,
62
+ source_key: :mg_id,
63
+ reference_key: :candidate_id
61
64
  has_many :posts
62
65
  has_many :posters, class_name: User, reference_key: :email
63
66
 
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.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - mech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.7'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activemodel
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.11'
89
+ version: '1.13'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.11'
96
+ version: '1.13'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '11.0'
103
+ version: '12.0'
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: '11.0'
110
+ version: '12.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.1'
117
+ version: '3.5'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.1'
124
+ version: '3.5'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  version: '0'
258
258
  requirements: []
259
259
  rubyforge_project:
260
- rubygems_version: 2.6.2
260
+ rubygems_version: 2.6.8
261
261
  signing_key:
262
262
  specification_version: 4
263
263
  summary: A Ruby wrapper to FileMaker XML API.
@@ -287,4 +287,3 @@ test_files:
287
287
  - spec/support/responses/portal.xml
288
288
  - spec/support/responses/scriptnames.xml
289
289
  - spec/support/xml_loader.rb
290
- has_rdoc: