apexgen 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ When /^I get help for "([^"]*)"$/ do |app_name|
2
+ @app_name = app_name
3
+ step %(I run `#{app_name} help`)
4
+ end
5
+
6
+ # Add more step definitions here
@@ -0,0 +1,19 @@
1
+ Given /^the file "([^"]*)" doesn't exist$/ do |file|
2
+ FileUtils.rm(file) if File.exists? file
3
+ end
4
+
5
+ Given /^the file "([^"]*)" doesn't exist in my current directory$/ do |filename|
6
+ step %(the file "#{ENV['PWD']}/#{filename}" doesn't exist)
7
+ end
8
+
9
+ Then /^a file named "([^"]*)" should exist in my current directory$/ do |filename|
10
+ step %(a file named "#{ENV['PWD']}/#{filename}" should exist)
11
+ end
12
+
13
+ Then /^the file "([^"]*)" in my current directory should contain "(.*?)"$/ do |filename, matcher|
14
+ step %(the file "#{ENV['PWD']}/#{filename}" should contain "#{matcher}")
15
+ end
16
+
17
+ # Then /^the file "([^"]*)" in my current directory should contain:$/ do |filename, partial_content|
18
+ # check_file_content("#{ENV['PWD']}/#{filename}", partial_content, true)
19
+ # end
@@ -0,0 +1,21 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
5
+
6
+ Before do
7
+ # Using "announce" causes massive warnings on 1.9.2
8
+ @puts = true
9
+ @original_rubylib = ENV['RUBYLIB']
10
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
11
+ @real_pwd = ENV['PWD']
12
+ fake_pwd = File.join('/tmp', 'fake_pwd')
13
+ FileUtils.rm_rf fake_pwd, secure: true
14
+ Dir.mkdir fake_pwd
15
+ ENV['PWD'] = fake_pwd
16
+ end
17
+
18
+ After do
19
+ ENV['RUBYLIB'] = @original_rubylib
20
+ ENV['PWD'] = @real_pwd
21
+ end
@@ -0,0 +1,24 @@
1
+ require 'apexgen/version.rb'
2
+
3
+ # Add requires for other files you add to your project here, so
4
+ # you just need to require this one file in your bin file
5
+
6
+ # CustomObject Classes
7
+ require 'apexgen/custom_object.rb'
8
+ # CustomObject Field Formatters
9
+ require 'apexgen/field/auto_number.rb'
10
+ require 'apexgen/field/checkbox.rb'
11
+ require 'apexgen/field/currency.rb'
12
+ require 'apexgen/field/date.rb'
13
+ require 'apexgen/field/date_time.rb'
14
+ require 'apexgen/field/encrypted_text.rb'
15
+ require 'apexgen/field/email.rb'
16
+ require 'apexgen/field/geolocation.rb'
17
+ require 'apexgen/field/long_text_area.rb'
18
+ require 'apexgen/field/number.rb'
19
+ require 'apexgen/field/percent.rb'
20
+ require 'apexgen/field/phone.rb'
21
+ require 'apexgen/field/rich_text_area.rb'
22
+ require 'apexgen/field/text.rb'
23
+ require 'apexgen/field/text_area.rb'
24
+ require 'apexgen/field/url.rb'
@@ -0,0 +1,85 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ class CustomObject
5
+ def initialize(name, fields=[])
6
+ # Set up vars
7
+ @name = name
8
+ @fields = fields
9
+ @name_plural = name.pluralize
10
+ @object_name = "#{@name}__c"
11
+ formats = {
12
+ 'text' => Apexgen::Field::Text.new,
13
+ 'encryptedtext' => Apexgen::Field::EncryptedText.new,
14
+ 'textarea' => Apexgen::Field::TextArea.new,
15
+ 'longtextarea' => Apexgen::Field::LongTextArea.new,
16
+ 'richtextarea' => Apexgen::Field::RichTextArea.new,
17
+ 'url' => Apexgen::Field::Url.new,
18
+ 'autonumber' => Apexgen::Field::AutoNumber.new,
19
+ 'checkbox' => Apexgen::Field::Checkbox.new,
20
+ 'currency' => Apexgen::Field::Currency.new,
21
+ 'datetime' => Apexgen::Field::DateTime.new,
22
+ 'date' => Apexgen::Field::Date.new,
23
+ 'email' => Apexgen::Field::Email.new,
24
+ 'geolocation' => Apexgen::Field::Geolocation.new,
25
+ 'number' => Apexgen::Field::Number.new,
26
+ 'percent' => Apexgen::Field::Percent.new,
27
+ 'phone' => Apexgen::Field::Phone.new,
28
+ }
29
+
30
+ # Filename and path setup
31
+ @file_name = "#{@object_name}.object"
32
+ @dir_name = File.join(ENV['PWD'], 'objects')
33
+
34
+ # Make the directory if it doesn't exist yet
35
+ Dir.mkdir @dir_name unless File.directory? @dir_name
36
+
37
+ # Make the file
38
+ File.open(File.join(@dir_name, @file_name), "w") do |f|
39
+ xml = String.new
40
+ xml << header
41
+
42
+ @fields.each do |field|
43
+ name, type = field.split(':')
44
+ type = 'text' if type == nil
45
+ formatter = formats[type.downcase]
46
+ xml << formatter.format(name)
47
+ end
48
+
49
+ xml << footer
50
+ f.write xml
51
+ end
52
+ end
53
+
54
+ # Private Classes
55
+ private
56
+
57
+ def header
58
+ """
59
+ <?xml version=\"1.0\" encoding=\"UTF-8\"?>
60
+ <CustomObject xmlns=\"http://soap.sforce.com/2006/04/metadata\">
61
+ <deploymentStatus>Deployed</deploymentStatus>
62
+ <description>A custom object named #{@name}</description>
63
+ <enableActivities>true</enableActivities>
64
+ <enableFeeds>false</enableFeeds>
65
+ <enableHistory>true</enableHistory>
66
+ <enableReports>true</enableReports>
67
+ """
68
+ end
69
+
70
+ def footer
71
+ """
72
+ <label>#{@name.titleize}</label>
73
+ <nameField>
74
+ <label>#{@name.titleize} Name</label>
75
+ <displayFormat>{0000}</displayFormat>
76
+ <type>AutoNumber</type>
77
+ </nameField>
78
+ <pluralLabel>#{@name_plural.titleize}</pluralLabel>
79
+ <searchLayouts/>
80
+ <sharingModel>ReadWrite</sharingModel>
81
+ </CustomObject>
82
+ """
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,29 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class AutoNumber
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:displayFormat] = o[:displayFormat] || '{0000}'
13
+ o[:inlineHelpText] = o[:inlineHelpText] || "#{name_title} Help Text"
14
+ """
15
+ <fields>
16
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
17
+ <description>#{name_title} Description</description>
18
+ <displayFormat>#{o[:displayFormat]}</displayFormat>
19
+ <externalId>#{o[:externalId]}</externalId>
20
+ <inlineHelpText>#{o[:inlineHelpText]}</inlineHelpText>
21
+ <label>#{name_title}</label>
22
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
23
+ <type>Url</type>
24
+ </fields>
25
+ """
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class Checkbox
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:defaultValue] = o[:defaultValue] || 'false'
13
+ """
14
+ <fields>
15
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
16
+ <description>#{name_title} Description</description>
17
+ <externalId>#{o[:externalId]}</externalId>
18
+ <defaultValue>#{o[:defaultValue]}</defaultValue>
19
+ <label>#{name_title}</label>
20
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
21
+ <type>Checkbox</type>
22
+ </fields>
23
+ """
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class Currency
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:required] = o[:required] || 'false'
13
+ o[:precision] = o[:precision] || '14'
14
+ o[:scale] = o[:scale] || '2'
15
+ """
16
+ <fields>
17
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
18
+ <description>#{name_title} Description</description>
19
+ <externalId>#{o[:externalId]}</externalId>
20
+ <label>#{name_title}</label>
21
+ <required>#{o[:required]}}</required>
22
+ <precision>#{o[:precision]}</precision>
23
+ <scale>#{o[:scale]}</scale>
24
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
25
+ <type>Currency</type>
26
+ </fields>
27
+ """
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class Date
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:required] = o[:required] || 'false'
13
+ """
14
+ <fields>
15
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
16
+ <description>#{name_title} Description</description>
17
+ <externalId>#{o[:externalId]}</externalId>
18
+ <label>#{name_title}</label>
19
+ <required>#{o[:required]}}</required>
20
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
21
+ <type>Date</type>
22
+ </fields>
23
+ """
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class DateTime
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:required] = o[:required] || 'false'
13
+ """
14
+ <fields>
15
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
16
+ <description>#{name_title} Description</description>
17
+ <externalId>#{o[:externalId]}</externalId>
18
+ <label>#{name_title}</label>
19
+ <required>#{o[:required]}}</required>
20
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
21
+ <type>DateTime</type>
22
+ </fields>
23
+ """
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class Email
6
+ def format(name, o={})
7
+ # Set up default opts
8
+ o[:externalId] = o[:externalId] || 'false'
9
+ o[:length] = o[:length] || '128'
10
+ o[:required] = o[:required] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:unique] = o[:unique] || 'false'
13
+ # Titleize the name so we don't need to repeat the method several times
14
+ name_title = name.titleize
15
+ """
16
+ <fields>
17
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
18
+ <description>#{name_title} Description</description>
19
+ <externalId>#{o[:externalId]}</externalId>
20
+ <label>#{name_title}</label>
21
+ <length>#{o[:length]}</length>
22
+ <required>#{o[:required]}</required>
23
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
24
+ <type>Email</type>
25
+ <unique>#{o[:unique]}</unique>
26
+ </fields>
27
+ """
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class EncryptedText
6
+ def format(name, o={})
7
+ # Set up default opts
8
+ o[:externalId] = o[:externalId] || 'false'
9
+ o[:length] = o[:length] || '128'
10
+ o[:required] = o[:required] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:maskChar] = o[:maskChar] || 'asterisk'
13
+ o[:maskType] = o[:maskType] || 'all'
14
+ # Titleize the name so we don't need to repeat the method several times
15
+ name_title = name.titleize
16
+ """
17
+ <fields>
18
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
19
+ <description>#{name_title} Description</description>
20
+ <externalId>#{o[:externalId]}</externalId>
21
+ <label>#{name_title}</label>
22
+ <length>#{o[:length]}</length>
23
+ <maskChar>#{o[:maskChar]}</maskChar>
24
+ <maskType>#{o[:maskType]}</maskType>
25
+ <required>#{o[:required]}</required>
26
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
27
+ <type>EncryptedText</type>
28
+ </fields>
29
+ """
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class Geolocation
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:required] = o[:required] || 'false'
13
+ o[:displayLocationInDecimal] = o[:displayLocationInDecimal] || 'false'
14
+ o[:scale] = o[:scale] || '2'
15
+ """
16
+ <fields>
17
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
18
+ <description>#{name_title} Description</description>
19
+ <displayLocationInDecimal>#{o[:displayLocationInDecimal]}</displayLocationInDecimal>
20
+ <externalId>#{o[:externalId]}</externalId>
21
+ <label>#{name_title}</label>
22
+ <required>#{o[:required]}</required>
23
+ <scale>#{o[:scale]}</scale>
24
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
25
+ <type>Location</type>
26
+ </fields>
27
+ """
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class LongTextArea
6
+ def format(name, o={})
7
+ # Set up default opts
8
+ o[:externalId] = o[:externalId] || 'false'
9
+ o[:length] = o[:length] || '32768'
10
+ o[:required] = o[:required] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:visibleLines] = o[:visibleLines] || '3'
13
+ # Titleize the name so we don't need to repeat the method several times
14
+ name_title = name.titleize
15
+ """
16
+ <fields>
17
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
18
+ <description>#{name_title} Description</description>
19
+ <externalId>#{o[:externalId]}</externalId>
20
+ <label>#{name_title}</label>
21
+ <length>#{o[:length]}</length>
22
+ <required>#{o[:required]}</required>
23
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
24
+ <type>LongTextArea</type>
25
+ <visibleLines>#{o[:visibleLines]}</visibleLines>
26
+ </fields>
27
+ """
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Apexgen
4
+ module Field
5
+ class Number
6
+ def format(name, o={})
7
+ # Titleize the name so we don't need to repeat the method several times
8
+ name_title = name.titleize
9
+ # Set up default opts
10
+ o[:externalId] = o[:externalId] || 'false'
11
+ o[:trackHistory] = o[:trackHistory] || 'false'
12
+ o[:required] = o[:required] || 'false'
13
+ o[:precision] = o[:precision] || '18'
14
+ o[:scale] = o[:scale] || '2'
15
+ o[:unique] = o[:unique] || 'false'
16
+ """
17
+ <fields>
18
+ <fullName>#{name_title.gsub(/\s/, '_')}__c</fullName>
19
+ <description>#{name_title} Description</description>
20
+ <externalId>#{o[:externalId]}</externalId>
21
+ <label>#{name_title}</label>
22
+ <required>#{o[:required]}</required>
23
+ <precision>#{o[:precision]}</precision>
24
+ <scale>#{o[:scale]}</scale>
25
+ <trackHistory>#{o[:trackHistory]}</trackHistory>
26
+ <unique>#{o[:unique]}</unique>
27
+ <type>Number</type>
28
+ </fields>
29
+ """
30
+ end
31
+ end
32
+ end
33
+ end