leap_salesforce 0.2.5 → 0.2.6

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
  SHA256:
3
- metadata.gz: 28fc085d9fc3d6e75a57629427bcb554e97b8a3c9eaa3f5ea2fc7449788b6f4a
4
- data.tar.gz: c032cfe147674dff6c4db3fa65d0f3b0876d0a7ebc6058cdae8a73c989b71390
3
+ metadata.gz: 6b318944cb5c337f9eb2f43edb361d5e0ca3fdbe79ffbc493f4b98b6b2fcb81b
4
+ data.tar.gz: 9f05c958a4c5a359097dfd39eb853fb547350701c3161aa4b1c21ba1e6093fc7
5
5
  SHA512:
6
- metadata.gz: d9a10df4ba88385bf192289f9c19bfeff7b9d4b654d8a2f7dd58e96b7727a61fba34f1a84855d5ca10e74cd16b97fcbbcd5c5262fe3540c60ea0529d51f38112
7
- data.tar.gz: 8d8cdecb6bdd62df2c1dc4e1082f39ba42b58b5e12ab89e7edc856b8b0b35eaeb531f935f87c4b07da3593f3afc0dce8d151d96c31a7979b09746b32b7ff43d7
6
+ metadata.gz: 386927d34b1f47d6e3fe6295ecc72c62f4644e093431c667e7656b9175224aabdb947338df9bef91edf4d0d22015364e1bd90898be823d4a82c598b3f9fc3fdf
7
+ data.tar.gz: 88f5a464645b4d0e5b3cabb23f903bbeb6d4a2c12afa77af9dc7312397f1eb1863af5f39d30cb82b23a24ebccf6ed101f0d0a63bbf57b7d9236f0100e2174b89
@@ -67,7 +67,7 @@
67
67
  <orderEntry type="library" scope="PROVIDED" name="sinatra (v2.0.4, RVM: ruby-2.6.0) [gem]" level="application" />
68
68
  <orderEntry type="library" scope="PROVIDED" name="sinatra-basic-auth (v0.1.0, RVM: ruby-2.6.0) [gem]" level="application" />
69
69
  <orderEntry type="library" scope="PROVIDED" name="sinatra-docdsl (v0.8.6, RVM: ruby-2.6.0) [gem]" level="application" />
70
- <orderEntry type="library" scope="PROVIDED" name="soaspec (v0.2.33, RVM: ruby-2.6.0) [gem]" level="application" />
70
+ <orderEntry type="library" scope="PROVIDED" name="soaspec (v0.3.1, RVM: ruby-2.6.0) [gem]" level="application" />
71
71
  <orderEntry type="library" scope="PROVIDED" name="socksify (v1.7.1, RVM: ruby-2.6.0) [gem]" level="application" />
72
72
  <orderEntry type="library" scope="PROVIDED" name="thor (v0.20.3, RVM: ruby-2.6.0) [gem]" level="application" />
73
73
  <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-2.6.0) [gem]" level="application" />
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.2.6
2
+ * Enhancement
3
+ * Update on data of an object made automatically if an update is done so
4
+ that 'find' does not need to be made explicitly
5
+
1
6
  Version 0.2.5
2
7
  * Bug Fix
3
8
  * Fixed query where value starts with I which was not performing properly
@@ -40,6 +40,6 @@ It reads the Metadata from Salesforce and creates the foundation for API tests.'
40
40
  spec.add_dependency 'require_all'
41
41
  spec.add_dependency 'rubocop'
42
42
  spec.add_dependency 'rubykeyword'
43
- spec.add_dependency 'soaspec', '>= 0.2.30'
43
+ spec.add_dependency 'soaspec', '>= 0.3.0'
44
44
  spec.add_dependency 'thor'
45
45
  end
@@ -51,7 +51,7 @@ class SoqlData < Exchange
51
51
  self.test_name = "Factory for '#{self.class}'#{optional_name}" unless name
52
52
  return unless name.is_a? Hash
53
53
 
54
- name.each do |field_name, field_value|
54
+ name.dup.each do |field_name, field_value|
55
55
  send("#{field_name}=", field_value)
56
56
  end
57
57
  end
@@ -81,7 +81,7 @@ class SoqlData < Exchange
81
81
  # Extract the id or return the cached version of it
82
82
  # @return [String] Id of Salesforce Object
83
83
  def id
84
- @id ||= self['$..id,$..Id']
84
+ @id ||= value_from_path '$..id,$..Id'
85
85
  end
86
86
 
87
87
  # @param [Boolean] set Whether to not retry for successful response (Used when you expect an error)
@@ -113,6 +113,7 @@ class SoqlData < Exchange
113
113
  # Update current record with data provided
114
114
  # @param [Hash] data Data to update exchange with
115
115
  def update(data)
116
+ @updated = true
116
117
  self.class.update(id, data)
117
118
  end
118
119
 
@@ -168,12 +169,26 @@ class SoqlData < Exchange
168
169
  # @param [String, Symbol] key Name of request element to set
169
170
  # @param [String] value Value to set request element to
170
171
  def []=(key, value)
171
- @override_parameters[:body] ||= {}
172
172
  value = value.salesforce_format if value.is_a? Time
173
+ @override_parameters[:body] ||= {}
173
174
  @override_parameters[:body][key] = value
174
175
  end
175
176
 
176
- # @return [String] Error message if present
177
+ # @return [String] Value at backend name
178
+ def [](backend_name)
179
+ if @updated
180
+ @updated = false
181
+ find # Retrieve data freshly after an update
182
+ end
183
+ value_from_path backend_name
184
+ rescue NoElementAtPath
185
+ raise diagnose_error if error_message?
186
+
187
+ find
188
+ value_from_path backend_name
189
+ end
190
+
191
+ # @return [String, RestClient::Response] Error message if present
177
192
  def diagnose_error
178
193
  return error_message if error_message?
179
194
 
@@ -201,37 +201,22 @@ module SoqlGlobalObjectData
201
201
  delete
202
202
  end
203
203
 
204
- # rubocop:disable Metrics/MethodLength
205
- # rubocop:disable Metrics/AbcSize
206
204
  def soql_element(name, backend_name)
207
205
  # Either set the element (if creating a new record) or update the object
208
- # @todo: ensure next time an element is retrieved it's not from a cached value
209
206
  # @param [String] new_value Value to update record to
210
207
  define_method("#{name}=") do |new_value|
211
- if @response
208
+ if @response # Performing an update
212
209
  @response = update(backend_name => new_value).response
213
- else
210
+ else # Setting value on creating new object
214
211
  self[backend_name] = new_value.class < SoqlData ? new_value.id : new_value
215
212
  end
216
213
  end
217
214
 
218
215
  # @return [String] Value of backend name
219
- define_method name.to_s do
220
- begin
221
- self[backend_name]
222
- rescue NoElementAtPath
223
- raise diagnose_error if error_message?
224
-
225
- # TODO: Response here should not be necessary. Only find is
226
- @response = find.response
227
- self[backend_name]
228
- end
229
- end
216
+ define_method(name.to_s) { self[backend_name] }
230
217
  # @return [String] Name of backend name for element
231
218
  define_method("#{name}_element") { backend_name }
232
219
  end
233
- # rubocop:enable Metrics/MethodLength
234
- # rubocop:enable Metrics/AbcSize
235
220
 
236
221
  # Map key to a field name if used directly or field defined through 'soql_element'
237
222
  # @param [Symbol, String] key Key to map to Table field name
@@ -2,5 +2,5 @@
2
2
 
3
3
  module LeapSalesforce
4
4
  # @return [String] Version of leap salesforce
5
- VERSION = '0.2.5'
5
+ VERSION = '0.2.6'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leap_salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - IQA
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-09-17 00:00:00.000000000 Z
12
+ date: 2019-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -213,14 +213,14 @@ dependencies:
213
213
  requirements:
214
214
  - - ">="
215
215
  - !ruby/object:Gem::Version
216
- version: 0.2.30
216
+ version: 0.3.0
217
217
  type: :runtime
218
218
  prerelease: false
219
219
  version_requirements: !ruby/object:Gem::Requirement
220
220
  requirements:
221
221
  - - ">="
222
222
  - !ruby/object:Gem::Version
223
- version: 0.2.30
223
+ version: 0.3.0
224
224
  - !ruby/object:Gem::Dependency
225
225
  name: thor
226
226
  requirement: !ruby/object:Gem::Requirement