leap_salesforce 0.1.5 → 0.1.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: 34e05db673469ab9a0bc71da3a58abf22522fb797776e7ed144504177ec43923
4
- data.tar.gz: c36487d9759e438fff829f742f8edbe1a7cef970cf272c5eaac3b0b824a3460e
3
+ metadata.gz: 1bc5400e3a22260ee15346243caca18a4e839d5a32237a236cedb4488e8a073d
4
+ data.tar.gz: be7c25e87d9dfd868ae7e7347b64ef61bb520a9f017c031e4ec5c0e5b8b27832
5
5
  SHA512:
6
- metadata.gz: caa01bf5c5268ca4781999f8a997f08ecc23ae3c4be923fb9a76d3a4d430c6dd6e7130df4ff9687077745e9ba61109e327c0af2ba8d2dda1e1e1b06f425d97e1
7
- data.tar.gz: 6c4f242aa17da03f03069b541b34f3dd199c4883e48c53fb1d6a02a37cfffc69826426721be9fa12a8e19e0e2c9ed3ebcaca74c5ce8cd0cf82b21c1202d07af4
6
+ metadata.gz: 48685d0acfa0a8b0b9ae08b94bdf64d41636df9982d45636a3d9e526ff9bef3d32cea0389767a4a2b31b6f6b5b45273c16bb221fc50d0121b96ddaa799b1769d
7
+ data.tar.gz: e62daf28879015af67c9eda73b495cd106450c962562c72556a4af97492511b238db493f3c21094d81fa2eba362dc05babae9f554b8b873584a1aa7002f59732
data/.gitignore CHANGED
@@ -9,6 +9,7 @@
9
9
  Gemfile.lock
10
10
  logs/
11
11
  stub/
12
+ .idea/workspace.xml
12
13
 
13
14
  # Generated files for now
14
15
  spec/support/
data/.leap_salesforce.yml CHANGED
@@ -6,5 +6,6 @@ soql_objects:
6
6
  - Document: ContentDocument
7
7
  - User:
8
8
  create_enum: false
9
+ - Group
9
10
  - Broker: Broker__c
10
- - Account
11
+ - Account
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Version 0.1.6
2
+ * Bug Fix
3
+ * Fix 'create_all' rake task
4
+ * Update string matcher so it excludes ALL non ruby characters
5
+ * Add example of setting an associated field through a lookup
6
+
1
7
  Version 0.1.5
2
8
  * Bug Fix
3
9
  * Handle name starting with 0, currency. This time adding string unit tests
data/README.md CHANGED
@@ -24,8 +24,11 @@ Or install it yourself as:
24
24
  $ gem install leap_salesforce
25
25
 
26
26
  ## Usage
27
-
27
+ ### Getting started
28
28
  After installing the gem, to get started in creating a fresh repository, the `leap_salesforce` executable can be used.
29
+ It will ask for credentials and setup files that will locally store them.
30
+ This assumes that a Salesforce OAuth app be set up to be used for the API which can be done by
31
+ following [this wiki]('https://gitlab.com/leap-dojo/leap_salesforce/wikis/SetUpOAuthApp').
29
32
 
30
33
  E.g
31
34
 
@@ -33,6 +36,22 @@ E.g
33
36
  leap_salesforce init
34
37
  ```
35
38
 
39
+ Credentials are not stored in stored in source control. They can be setting through the following environment variables:
40
+
41
+ * 'client_id'
42
+ * 'client_secret'
43
+ * 'password'
44
+
45
+ Tests can be run using the default `Rake` task.
46
+
47
+ E.g.,
48
+
49
+ `rake` # Run all tests
50
+
51
+ API Traffic logs can be seen in the `logs` folder.
52
+
53
+ TODO: Finish this. A lot more needed
54
+
36
55
  ## Docs
37
56
 
38
57
  Technical docs [here](https://www.rubydoc.info/gems/leap_salesforce)
data/exe/leap_salesforce CHANGED
@@ -33,7 +33,7 @@ module LeapSalesforce
33
33
  end
34
34
 
35
35
  query_for_parameters
36
- generate_files binding, ['Gemfile', 'Rakefile', '.leap_salesforce.yml', '.rspec',
36
+ generate_files binding, ['Gemfile', 'Rakefile', '.leap_salesforce.yml', '.rspec', '.gitignore',
37
37
  { config: ['general.rb', { credentials: 'salesforce_oauth2.yml' }] },
38
38
  { spec: %w[spec_helper.rb limit_spec.rb crud_eg_spec.rb picklists_spec.rb] }]
39
39
 
@@ -7,12 +7,15 @@ require 'active_support/core_ext/string'
7
7
 
8
8
  # Override string object to provide convenience methods for Strings
9
9
  class String
10
+ # @note This removes '?' which is allowed in a method but is not desired for automatic creation of their names
11
+ # in the way that is being used here
10
12
  # @return [String] Convert string to something that would be friendly to use as in Ruby
11
13
  def to_ruby_friendly
12
- tr(":'/()$€£¥#+, ", '').tr('-*"', '').tr('&|=', '_')
13
- .gsub('<', '_lt_').gsub('>', '_gt_')
14
- .remove_macrons.tr("\n", '')
15
- .humanize_numbered_string
14
+ tr('&|=', '_').gsub('<', '_lt_').gsub('>', '_gt_')
15
+ .remove_macrons
16
+ .humanize_numbered_string
17
+ .gsub(/[\s]+/, '_')
18
+ .gsub(/[\W]/, '') # Remove any other special characters
16
19
  end
17
20
 
18
21
  # @return [String] Convert String to form a class could use
@@ -21,13 +21,15 @@ module LeapSalesforce
21
21
  when 'string' then set("Faker::Lorem.paragraph_by_chars(#{field['length']})")
22
22
  when 'id' then set('Best to not hard code this', use_quotes: true)
23
23
  when 'boolean' then set('true')
24
- when 'picklist' then set("#{class_name}::#{field['name']}.sample")
24
+ when 'picklist' then set("#{class_name}::#{field['name'].to_class_name}.sample")
25
25
  when 'reference'
26
+ return set('User.find(CreatedDate: "<#{0.days.ago}").id') if field['name'] == 'OwnerId'
27
+
26
28
  soql_obj = LeapSalesforce.soql_objects.find { |so| so.backend_name == field['relationshipName'] }&.reference
27
29
  if soql_obj
28
30
  "association :#{@field['label'].unused_ruby_name}, factory: :#{soql_obj}"
29
31
  else
30
- "# Please add #{field['relationshipName']} to .leap_salesforce.yml to create association for #{field}"
32
+ "# Please add #{field['relationshipName']} to .leap_salesforce.yml (if it's a table) to create association for #{field['relationshipName']}"
31
33
  end
32
34
  else
33
35
  set("Content depending on #{field['type']}", use_quotes: true)
@@ -43,6 +45,7 @@ module LeapSalesforce
43
45
  %w[FirstName LastName]
44
46
  end
45
47
 
48
+ # @return [Array] List of backend field names to be populated by default for account
46
49
  def account
47
50
  ['Name']
48
51
  end
@@ -19,10 +19,15 @@ module LeapSalesforce
19
19
  # @param [String] content Content to put within file
20
20
  def generate_file(filename, content, overwrite: true)
21
21
  FileUtils.mkdir_p File.dirname filename unless File.directory? File.dirname(filename)
22
- return puts "File '#{filename}' already exists, skipping...".colorize :red if File.exist?(filename) && !overwrite
22
+ action = if File.exist?(filename)
23
+ return puts "File '#{filename}' already exists, skipping...".colorize :red unless overwrite
23
24
 
25
+ 'Updated'
26
+ else
27
+ 'Created'
28
+ end
24
29
  File.write filename, content
25
- puts "\u2713 Created file at #{filename}".colorize :green
30
+ puts "\u2713 #{action} #{filename}".colorize :green
26
31
  end
27
32
 
28
33
  # @example Create a spec_helper file and test file in spec folder
@@ -33,7 +33,7 @@ module LeapSalesforce
33
33
  @picklist = picklist
34
34
  @enum_name = picklist.to_class_name
35
35
  picklist_name = picklist.to_key_name
36
- values = entity.picklist_for picklist
36
+ values = entity.picklist_for(picklist)
37
37
  @enum_values = {}
38
38
  values.each { |value| @enum_values[value.to_key_name] = value }
39
39
  content = read_template 'picklist.rb.erb', binding
@@ -32,7 +32,7 @@ module LeapSalesforce
32
32
  end
33
33
  content = read_template 'soql_object.rb.erb', binding
34
34
  file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.reference}.rb")
35
- generate_file file, content
35
+ generate_file file, content, overwrite: false
36
36
  end
37
37
 
38
38
  # Generate module with fields for Soql Object
@@ -47,7 +47,7 @@ module LeapSalesforce
47
47
  @default_fields, @other_fields = filter_fields
48
48
  content = read_template 'factory.rb.erb', binding
49
49
  file = File.join(FACTORY_FOLDER, "#{@soql_object.reference}.rb")
50
- generate_file file, content
50
+ generate_file file, content, overwrite: false
51
51
  end
52
52
 
53
53
  # Generate soql_object and it's related modules, factories
@@ -0,0 +1,2 @@
1
+ logs/
2
+ config/credentials/ # Confidential files stored here
@@ -6,4 +6,5 @@ soql_objects:
6
6
  - Document: ContentDocument
7
7
  - User:
8
8
  create_enum: false # Example of indicating that enumerations are not required to be generated for
9
- - Account
9
+ - Account
10
+ - Group
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # This file is generated and updated automatically so best not to edit manually
3
4
  # Helps handle picklist values for <%= "#{@entity_name}, #{@enum_name}" %>
4
5
  class <%= @entity_name %> < SoqlData
5
6
  # Enumeration for <%= @enum_name %>
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is generated and updated automatically so best not to edit manually
1
4
  # Fields for <%= @soql_object.class_name %> mapped from SOQL <%= @soql_object.backend_name %>
2
5
  class <%= @soql_object.class_name %> < SoqlData
3
6
  module Fields
@@ -13,11 +13,11 @@ namespace :leaps do
13
13
  LeapSalesforce::Generator::SoqlObjects.new.create_all
14
14
  end
15
15
 
16
- # TODO: This does not work
17
16
  desc 'Create objects, fields, enums'
18
17
  task create_all: :create_soql_objects do
19
- # require_all LeapSalesforce.lib_folder
20
- LeapSalesforce.objects_to_verify = SoqlData.descendants
21
- Rake::Task['leaps:create_enums'].invoke
18
+ # TODO: This is not ideal. But only way I could get it to work
19
+ puts `bundle exec rake leaps:create_soql_objects`
20
+ puts 'Creating enums. Please wait until finished for output'
21
+ puts `bundle exec rake leaps:create_enums`
22
22
  end
23
23
  end
@@ -52,7 +52,7 @@ module SoqlObjectDescribe
52
52
  def picklist_for(field_name)
53
53
  properties = properties_for field_name
54
54
 
55
- properties['picklistValues'].collect { |list| list['label'] }
55
+ properties['picklistValues'].collect { |list| list['label'] }.compact
56
56
  end
57
57
 
58
58
  # @param [String, Symbol] field_name Salesforce backend field name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LeapSalesforce
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.6'
5
5
  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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - IQA
@@ -242,7 +242,6 @@ files:
242
242
  - ".idea/misc.xml"
243
243
  - ".idea/modules.xml"
244
244
  - ".idea/vcs.xml"
245
- - ".idea/workspace.xml"
246
245
  - ".leap_salesforce.yml"
247
246
  - ".rspec"
248
247
  - ".rubocop.yml"
@@ -267,6 +266,7 @@ files:
267
266
  - lib/leap_salesforce/generator/generator.rb
268
267
  - lib/leap_salesforce/generator/soql_enums.rb
269
268
  - lib/leap_salesforce/generator/soql_objects.rb
269
+ - lib/leap_salesforce/generator/templates/.gitignore.erb
270
270
  - lib/leap_salesforce/generator/templates/.leap_salesforce.yml.erb
271
271
  - lib/leap_salesforce/generator/templates/.rspec.erb
272
272
  - lib/leap_salesforce/generator/templates/Gemfile.erb