Class: HooplaSalesforce::Skeleton

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/hoopla_salesforce/skeleton.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory) ⇒ Skeleton

Returns a new instance of Skeleton.



10
11
12
# File 'lib/hoopla_salesforce/skeleton.rb', line 10

def initialize(directory)
  @directory = directory
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



8
9
10
# File 'lib/hoopla_salesforce/skeleton.rb', line 8

def directory
  @directory
end

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hoopla_salesforce/skeleton.rb', line 18

def create
  puts "Creating a skeleton in #{directory}"
  %w(applications classes objects pages resources tabs triggers).each do |dir|
    mkdir_p "/src/#{dir}"
  end
  mkdir_p '/lib'
  make_package_xml
  make_rakefile
  make_gitignore
  followup_instructions
end

#followup_instructionsObject



108
109
110
111
112
113
114
115
116
117
# File 'lib/hoopla_salesforce/skeleton.rb', line 108

def followup_instructions
  puts
  puts "-" * 80
  puts " All done. Now you need to download your WSDL files into your project:"
  puts
  puts "   Enterprise WSDL: #{directory}/lib/enterprise.xml"
  puts "   Metadata WSDL:   #{directory}/lib/metadata.xml"
  puts
  puts "-" * 80
end

#make_gitignoreObject



99
100
101
102
103
104
105
106
# File 'lib/hoopla_salesforce/skeleton.rb', line 99

def make_gitignore
  File.open("#{directory}/.gitignore", 'w') do |gitignore|
    gitignore.print <<-EOS.margin
      src-processed
      deploy.zip
    EOS
  end
end

#make_package_xmlObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/hoopla_salesforce/skeleton.rb', line 30

def make_package_xml
  File.open("#{directory}/src/package.xml", 'w') do |pkg|
    pkg.print <<-EOS.margin
      <?xml version="1.0" encoding="UTF-8"?>
      <Package xmlns="http://soap.sforce.com/2006/04/metadata">
        <fullName></fullName>
        <apiAccessLevel>Unrestricted</apiAccessLevel>
        <description></description>
        <namespacePrefix>__NAMESPACE__</namespacePrefix>
        <types>
          <members>*</members>
          <name>ApexClass</name>
        </types>
        <types>
          <members>*</members>
          <name>ApexPage</name>
        </types>
        <types>
          <members>*</members>
          <name>ApexTrigger</name>
        </types>
        <types>
          <members>*</members>
          <name>CustomApplication</name>
        </types>
        <types>
          <members>*</members>
          <name>CustomObject</name>
        </types>
        <types>
          <members>*</members>
          <name>CustomField</name>
        </types>
        <types>
          <members>*</members>
          <name>ValidationRule</name>
        </types>
        <types>
          <members>*</members>
          <name>CustomTab</name>
        </types>
        <types>
          <members>*</members>
          <name>StaticResource</name>
        </types>
        <version>18.0</version>
      </Package>
    EOS
  end
end

#make_rakefileObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/hoopla_salesforce/skeleton.rb', line 81

def make_rakefile
  File.open("#{directory}/Rakefile", 'w') do |rakefile|
    rakefile.print <<-EOS.margin
      require 'hoopla_salesforce/rake'
      
      HooplaSalesforce.enterprise_wsdl = "lib/enterprise.xml"
      HooplaSalesforce.metadata_wsdl   = "lib/metadata.xml"
      
      HooplaSalesforce::Rake::DeployTask.new(:development) do |t|
        t.username  = "[email protected]"
        t.password  = "yourpassword"
        t.token     = "your security token"
        t.namespace = "" 
      end
    EOS
  end
end

#mkdir_p(dir = '') ⇒ Object



14
15
16
# File 'lib/hoopla_salesforce/skeleton.rb', line 14

def mkdir_p(dir='')
  super directory + dir
end