leap_salesforce 0.2.24 → 0.2.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.leap_salesforce.yml +9 -3
- data/.rubocop.yml +12 -2
- data/ChangeLog +8 -0
- data/lib/leap_salesforce/generator/soql_enums.rb +11 -2
- data/lib/leap_salesforce/generator/templates/soql_object.rb.erb +0 -1
- data/lib/leap_salesforce/soql_data/soql_settings.rb +4 -13
- data/lib/leap_salesforce/soql_object.rb +26 -2
- data/lib/leap_salesforce/users/users.rb +22 -9
- data/lib/leap_salesforce/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46ddc1666b0bfa490615de0e71ebfc2c38a038d1979ba11ca316473b9149ee5d
|
4
|
+
data.tar.gz: fd02406910add5f0476180668503aa8cd84a2b17a8d2d177c7bea04cc92a24ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce2360e07c182e3c2e9c74cd1ba2ab97f383a18d6797ecc84989c67a96f011df0debd4b4ca1f687ee1f757547fb2afc17b54df43dd07bfa92908ee8fa4efe37
|
7
|
+
data.tar.gz: e19d83a1ec699f4e71239e73b27f293d10d0e62c4d3cf1051aec99590bfb795ade0c94bb318ff7f9598c2ec2e42f421f2d2f5ca8c7c071d0023b5d90c5b79636
|
data/.leap_salesforce.yml
CHANGED
@@ -6,9 +6,15 @@ soql_objects:
|
|
6
6
|
- Contact
|
7
7
|
- Document: ContentDocument
|
8
8
|
- User:
|
9
|
-
create_enum:
|
10
|
-
|
9
|
+
create_enum:
|
10
|
+
exclude:
|
11
|
+
- Time
|
12
|
+
- Group:
|
13
|
+
create_enum: false # Set this to false to not track enums for object
|
11
14
|
- Broker: Broker__c
|
12
|
-
- Account
|
15
|
+
- Account:
|
16
|
+
create_enum:
|
17
|
+
exclude:
|
18
|
+
- Rating
|
13
19
|
- Attachment
|
14
20
|
- EventLogFile
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,13 @@
|
|
1
1
|
# Modifies RuboCop (Static analysis tool)
|
2
|
-
|
3
|
-
Max: 160
|
2
|
+
Layout/LineLength:
|
3
|
+
Max: 160
|
4
|
+
Lint/RaiseException:
|
5
|
+
Enabled: true
|
6
|
+
Lint/StructNewOverride:
|
7
|
+
Enabled: true
|
8
|
+
Style/HashEachMethods:
|
9
|
+
Enabled: true
|
10
|
+
Style/HashTransformKeys:
|
11
|
+
Enabled: true
|
12
|
+
Style/HashTransformValues:
|
13
|
+
Enabled: true
|
data/ChangeLog
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
Version 0.2.26
|
2
|
+
* Enhancement
|
3
|
+
* Create method to exclude picklists being created based on regexp in .leap_salesforce.yml
|
4
|
+
|
5
|
+
Version 0.2.25
|
6
|
+
* Enhancement
|
7
|
+
* `execute_as` user method that raises error if user not present
|
8
|
+
|
1
9
|
Version 0.2.24
|
2
10
|
* Bug fix
|
3
11
|
* Handle metadata label name that is the same name as a method on SoqlData (which one would not want overwriting)
|
@@ -28,7 +28,10 @@ module LeapSalesforce
|
|
28
28
|
# @param [LeapSalesforce::SoqlData] entity An object representing an object in Salesforce
|
29
29
|
# Object inheriting from SoqlData that has picklists underneath it
|
30
30
|
def create_picklists_for(entity)
|
31
|
-
|
31
|
+
soql_object = LeapSalesforce.soql_objects.find { |so| so.class_name == entity.to_s }
|
32
|
+
raise "Could not find soql object for '#{entity.to_s}'" unless soql_object
|
33
|
+
|
34
|
+
unless soql_object.create_enum != false
|
32
35
|
puts "Skipping picklists for #{entity}"
|
33
36
|
return
|
34
37
|
end
|
@@ -36,7 +39,13 @@ module LeapSalesforce
|
|
36
39
|
@entity_name = entity
|
37
40
|
picklists = entity.picklists
|
38
41
|
puts "#{picklists.count} picklists found"
|
39
|
-
picklists.each
|
42
|
+
picklists.each do |picklist|
|
43
|
+
if soql_object.excludes?(picklist)
|
44
|
+
puts "Exluding picklist '#{picklist}'"
|
45
|
+
else
|
46
|
+
generate_picklist_file picklist
|
47
|
+
end
|
48
|
+
end
|
40
49
|
end
|
41
50
|
|
42
51
|
# Generate file for a picklist from it's metadata
|
@@ -3,5 +3,4 @@ require_relative '<%= @field_name_file %>'
|
|
3
3
|
class <%= @soql_object.class_name %> < SoqlData
|
4
4
|
include <%= @soql_object.class_name %>::Fields
|
5
5
|
<%= "soql_object '#{@soql_object.backend_name}'" unless @soql_object.backend_name == @soql_object.class_name %>
|
6
|
-
<%= "create_enum false" if @soql_object.create_enum == false %>
|
7
6
|
end
|
@@ -14,18 +14,9 @@ module SoqlSettings
|
|
14
14
|
@soql_object_name || to_s
|
15
15
|
end
|
16
16
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Boolean] Whether to create enum for object
|
24
|
-
def create_enum?
|
25
|
-
if @create_enum.nil?
|
26
|
-
true # True by default
|
27
|
-
else
|
28
|
-
@create_enum
|
29
|
-
end
|
17
|
+
# @deprecated Not used, setting in '.leap_salesforce.yml' controls this now
|
18
|
+
def create_enum
|
19
|
+
LeapSalesforce.logger.warn "Method 'create_enum' called when it is deprecated" \
|
20
|
+
" from #{caller_locations[0]}"
|
30
21
|
end
|
31
22
|
end
|
@@ -11,17 +11,41 @@ module LeapSalesforce
|
|
11
11
|
attr_accessor :reference
|
12
12
|
# @return [String] Description of Soql object from '.leap_salesforce' YAML
|
13
13
|
attr_accessor :description
|
14
|
-
# @return [Boolean] Whether to create enumerations for object
|
14
|
+
# @return [Boolean, Hash] Whether to create enumerations for object
|
15
15
|
attr_accessor :create_enum
|
16
16
|
|
17
17
|
# Create a representation of a Soql object from a description (usually in .leap_salesforce.yml)
|
18
|
-
# @
|
18
|
+
# @example Specific Salesforce object 'Case' to be represented
|
19
|
+
# 'Case'
|
20
|
+
# @example Represent Broker object by class with different name
|
21
|
+
# { 'Broker' => Broker__c }
|
22
|
+
# @example Represent Group object, specifying to ignore enums
|
23
|
+
# {"Group"=>nil, "create_enum"=>true} }
|
24
|
+
# @example Represent User object, specifying to ignore enum with name of Timezone
|
25
|
+
# {"User"=>nil, "create_enum"=>{"exclude"=>["Timezone"]}}
|
26
|
+
# @param [Hash, String] description
|
19
27
|
def initialize(description)
|
20
28
|
self.description = description
|
21
29
|
interpret_description
|
22
30
|
self.reference = @class_name.snakecase
|
23
31
|
end
|
24
32
|
|
33
|
+
# @param [String] picklist
|
34
|
+
# @return [Boolean] Whether picklist should be excluded from being generated
|
35
|
+
def excludes?(picklist)
|
36
|
+
if create_enum.is_a? Hash
|
37
|
+
if create_enum['exclude']
|
38
|
+
create_enum['exclude'].any? do |exclusion_list|
|
39
|
+
!picklist.to_s[Regexp.new(exclusion_list)].nil?
|
40
|
+
end
|
41
|
+
else
|
42
|
+
false
|
43
|
+
end
|
44
|
+
else
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
25
49
|
private
|
26
50
|
|
27
51
|
# Set attributes based on description
|
@@ -27,9 +27,16 @@ module LeapSalesforce
|
|
27
27
|
@list << User.new(*user)
|
28
28
|
end
|
29
29
|
|
30
|
+
# @example Filter user by key of :admin
|
31
|
+
# where(key: :admin)
|
32
|
+
# @example Filter user by description containing Payroll
|
33
|
+
# where(description: /Payroll/)
|
34
|
+
# @example Filter user by username
|
35
|
+
# where(username: 'username@domain.com')
|
30
36
|
# @param [Symbol, Hash, String, Regexp, LeapSalesforce::User] filter Filter to find users by
|
31
37
|
# @param [Boolean] all Whether to return all users matching criteria, not just first
|
32
|
-
# @return [LeapSalesforce::User, Array] A user that meets the criteria
|
38
|
+
# @return [LeapSalesforce::User, Array] A user that meets the criteria.
|
39
|
+
# If all is true this returns array of users
|
33
40
|
def where(filter, all: false)
|
34
41
|
@all = all
|
35
42
|
case filter
|
@@ -66,20 +73,26 @@ module LeapSalesforce
|
|
66
73
|
@all ? users : users.first
|
67
74
|
end
|
68
75
|
|
76
|
+
# @param [Symbol, Hash, String, Regexp, LeapSalesforce::User] filter Filter to find user by
|
77
|
+
# @return [Object] Result of block
|
78
|
+
def execute_as(filter)
|
79
|
+
current_user = LeapSalesforce.api_user
|
80
|
+
LeapSalesforce.api_user = LeapSalesforce::Users.where filter
|
81
|
+
result = yield
|
82
|
+
LeapSalesforce.api_user = current_user
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
69
86
|
# Execute block as user matching filter if that user is present
|
70
87
|
# If user is not present the current user will be used
|
71
88
|
# @return [Object] Result of block
|
72
|
-
def execute_as_if_present(
|
89
|
+
def execute_as_if_present(user_filter)
|
73
90
|
raise ArgumentError, 'Pass block to :execute_as_if_present method' unless block_given?
|
74
91
|
|
75
|
-
|
76
|
-
|
77
|
-
LeapSalesforce.api_user = LeapSalesforce::Users.where filter
|
78
|
-
result = yield
|
79
|
-
LeapSalesforce.api_user = current_user
|
80
|
-
result
|
92
|
+
if any? user_filter
|
93
|
+
execute_as(user_filter) { yield }
|
81
94
|
else
|
82
|
-
LeapSalesforce.logger.warn "No user found user filter #{
|
95
|
+
LeapSalesforce.logger.warn "No user found user filter #{user_filter}, using '#{LeapSalesforce.api_user}'"
|
83
96
|
yield
|
84
97
|
end
|
85
98
|
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.
|
4
|
+
version: 0.2.26
|
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: 2020-
|
12
|
+
date: 2020-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|