leap_salesforce 0.2.3 → 0.2.4

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: c881f656d66f33e7114b3c35d66171657310ed97696c7b0fd66ed81ba3f6462c
4
- data.tar.gz: 590ff727c864eae8c3cedfdd819e442fd86a3b4e988b371c86bce92c2de484c6
3
+ metadata.gz: 05c69a9a17c1add0dad1ef3ba178ef096818a8379dd6488f3bd96fdcd78a32c1
4
+ data.tar.gz: c05c1ad0beddeac93a2d5af4c880712c8b235a0e18d76e3db71a098bbc714dcd
5
5
  SHA512:
6
- metadata.gz: 804633946e5efadfea7657a7725f57d8f3b08fa1e4dfeb4ce826e30bd8435bc058e0ac07d6fde6ce62e8417309c2f6effd30c028bccbaef31a4a9244c5cc1844
7
- data.tar.gz: 52d08e6d6dc453e1bc934c2ff2f5ef310e01593a5ebf3eed4f51f84fd8e4e92bf649e83c6ee0329c02f0baaf6b1bb18209765d67fe261eb2788b3001cad5d566
6
+ metadata.gz: 23541a09f8e1495f33f776eecdbca0a94d92f1a4b0049ece899a6d32331ccfe014741b35f115c0e0d14e8f3b4354d5a40d1049c1acff3d63690da7c056762f01
7
+ data.tar.gz: 53a7cdbec9530f8400c6a7f9a20a8a12ce0738293640640cd64c9ba1560d3bf734ddab15b1d90652a5cd011baad3a2001f88fd557f61405c3b84ab424500ef97
data/.gitignore CHANGED
@@ -9,7 +9,6 @@
9
9
  Gemfile.lock
10
10
  logs/
11
11
  stub/
12
- */server.csr
13
12
  .idea/workspace.xml
14
13
  .idea/.rakeTasks
15
14
  stub_log
@@ -26,4 +25,5 @@ config/credentials/
26
25
  # sfdx
27
26
  /JWT/
28
27
  /scripts/setup_env.sh
29
- sf_log.log
28
+ sf_log.log
29
+ */server.*
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.2.4
2
+ * Bug Fix
3
+ * Fixed 'delete_as_admin' method which was referring to methods that don't exist
4
+
1
5
  Version 0.2.3
2
6
  * Enhancement
3
7
  * Get sfdx init working with `leap_salesforce init sfdx=true`
@@ -64,6 +64,7 @@ module LeapSalesforce
64
64
  else
65
65
  'get_prod_auth'
66
66
  end
67
+ puts "Using JWT folder '#{ENV['JWT_FOLDER']}'"
67
68
  self.sfdx_display_output = `sh #{__dir__}/#{script_name}.sh`
68
69
  self.access_token = from_output 'Access Token'
69
70
  url_obtained = from_output 'Instance Url'
@@ -5,6 +5,7 @@ require 'rubykeyword'
5
5
  require 'humanize'
6
6
  require 'active_support/core_ext/string'
7
7
  require 'date'
8
+ require 'json'
8
9
 
9
10
  # Override string object to provide convenience methods for Strings
10
11
  class String
@@ -91,4 +92,16 @@ class String
91
92
  else
92
93
  true
93
94
  end
95
+
96
+ # Convert Ruby String representation of Array to SoqlArray
97
+ # @return [String] String representation for use in Soql IN query
98
+ def to_soql_array
99
+ arr = JSON.parse(self)
100
+ unless arr.is_a? Array
101
+ raise ArgumentError, "Cannot convert #{self} into Array" \
102
+ "Called at #{caller_locations[0]}"
103
+ end
104
+ joined = arr.join("', '")
105
+ "('#{joined}')"
106
+ end
94
107
  end
@@ -4,7 +4,7 @@
4
4
  namespace :sfdx do
5
5
  desc 'Login with credentials'
6
6
  task :login do
7
- puts `sfdx force:auth:jwt:grant --clientid $SF_CONSUMER_KEY --jwtkeyfile JWT/server.key --username $SF_USERNAME --setdefaultdevhubusername --setalias HubOrg`
7
+ puts `sfdx force:auth:jwt:grant --clientid $SF_CONSUMER_KEY --jwtkeyfile "$JWT_FOLDER"/server.key --username $SF_USERNAME --setdefaultdevhubusername --setalias HubOrg`
8
8
  end
9
9
 
10
10
  task :display do
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  import File.join(__dir__, 'rake', 'setup.rake')
4
+ import File.join(__dir__, 'rake', 'sfdx.rake')
4
5
 
5
6
  # Dir.glob('rake/*.rake').each(&method(:import))
@@ -127,7 +127,11 @@ class SoqlData < Exchange
127
127
  # @param [Boolean] must_pass Whether to raise exception if call is not successful
128
128
  # @return [Exchange] Exchange object making delete
129
129
  def delete_as_admin(must_pass: true)
130
- LeapSalesforce.api_username = Test.email_for('System Admin')
130
+ LeapSalesforce.api_user = LeapSalesforce::Users.where key: :admin
131
+ rescue LeapSalesforce::UserError
132
+ raise LeapSalesforce::SetupError, 'Please set up a user with a key of :admin' \
133
+ 'to use "delete_as_admin"'
134
+ else
131
135
  delete must_pass: must_pass
132
136
  end
133
137
 
@@ -259,7 +259,7 @@ module SoqlGlobalObjectData
259
259
  def condition_for(value)
260
260
  value = value.to_s
261
261
  operator, value = case value[0]
262
- when '>', '<' then extract_comparator(value)
262
+ when '>', '<', '!', 'I' then extract_comparator(value)
263
263
  when '~' then ['LIKE', value[1..-1]]
264
264
  else
265
265
  return "= '#{value}'" unless value.type_of_time?
@@ -268,14 +268,22 @@ module SoqlGlobalObjectData
268
268
  end
269
269
  return "#{operator} #{value.to_zulu_date_string}" if value.type_of_time?
270
270
 
271
+ return "#{operator} #{value}" if operator.end_with? 'IN'
272
+
271
273
  "#{operator} '#{value}'"
272
274
  end
273
275
 
274
276
  # @param [String] value Value to extract comparator for
275
- # @return [Array] Extract of >, >, >= from string and rest of string
277
+ # @return [Array] Extract of operator, value, taking >, >, >= from string and rest of string
276
278
  def extract_comparator(value)
277
279
  if value[1] == '='
278
280
  [value[0..1], value[2..-1]]
281
+ elsif value[0..2] == '!IN'
282
+ ['NOT IN', value[3..-1].to_soql_array]
283
+ elsif value[0..1] == 'IN'
284
+ ['IN', value[2..-1].to_soql_array]
285
+ elsif value[0] == '!'
286
+ ['!=', value[1..-1]]
279
287
  else
280
288
  [value[0], value[1..-1]]
281
289
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module LeapSalesforce
4
4
  # @return [String] Version of leap salesforce
5
- VERSION = '0.2.3'
5
+ VERSION = '0.2.4'
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.3
4
+ version: 0.2.4
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-12 00:00:00.000000000 Z
12
+ date: 2019-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler