Module: Metaforce::Metadata::Client::File

Included in:
Metaforce::Metadata::Client
Defined in:
lib/metaforce/metadata/client/file.rb

Instance Method Summary collapse

Instance Method Details

#_deploy(zip_file, options = {}) ⇒ Object

Public: Deploy code to Salesforce.

zip_file - The base64 encoded contents of the zip file. options - Hash of DeployOptions.

Returns the AsyncResult



63
64
65
66
67
# File 'lib/metaforce/metadata/client/file.rb', line 63

def _deploy(zip_file, options={})
  request :deploy do |soap|
    soap.body = { :zip_file => zip_file, :deploy_options => options }
  end
end

#_retrieve(options = {}) ⇒ Object

Public: Retrieve code from Salesforce.

Returns the AsyncResult



72
73
74
75
76
# File 'lib/metaforce/metadata/client/file.rb', line 72

def _retrieve(options={})
  request :retrieve do |soap|
    soap.body = { :retrieve_request => options }
  end
end

#deploy(path, options = {}) ⇒ Object

Public: Deploy code to Salesforce.

path - A path to a zip file, or a directory to deploy. options - Deploy options.

Examples

client.deploy(File.expand_path('./src'))


86
87
88
# File 'lib/metaforce/metadata/client/file.rb', line 86

def deploy(path, options={})
  Job::Deploy.new(self, path, options)
end

#describe(version = nil) ⇒ Object

Public: Describe the organization’s metadata.

version - API version (default: latest).

Examples

# List the names of all metadata types
client.describe..collect { |t| t.xml_name }
#=> ["CustomLabels", "StaticResource", "Scontrol", "ApexComponent", ... ]


33
34
35
36
37
# File 'lib/metaforce/metadata/client/file.rb', line 33

def describe(version=nil)
  request :describe_metadata do |soap|
    soap.body = { :api_version => version } unless version.nil?
  end
end

#list_metadata(*args) ⇒ Object

Public: Specify an array of component types to list.

Examples

# Get a list of apex classes on the server and output the names of each
client.('ApexClass').collect { |t| t.full_name }
#=> ["al__SObjectPaginatorListenerForTesting", "al__IndexOutOfBoundsException", ... ]

# Get a list of apex components and apex classes
client.('CustomObject', 'ApexComponent')
#=> ["ContractContactRole", "Solution", "Invoice_Statements__c", ... ]


17
18
19
20
21
22
# File 'lib/metaforce/metadata/client/file.rb', line 17

def (*args)
  queries = args.map(&:to_s).map(&:camelize).map { |t| {:type => t} }
  request :list_metadata do |soap|
    soap.body = { :queries => queries }
  end
end

#retrieve(options = {}) ⇒ Object



90
91
92
# File 'lib/metaforce/metadata/client/file.rb', line 90

def retrieve(options={})
  Job::Retrieve.new(self, options)
end

#retrieve_unpackaged(manifest, options = {}) ⇒ Object

Public: Retrieves files specified in the manifest file (A package.xml file).



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/metaforce/metadata/client/file.rb', line 96

def retrieve_unpackaged(manifest, options={})
  package = if manifest.is_a?(Metaforce::Manifest)
    manifest
  elsif manifest.is_a?(String)
    Metaforce::Manifest.new(::File.open(manifest).read)
  end
  options = {
    :api_version    => Metaforce.configuration.api_version,
    :single_package => true,
    :unpackaged     => { :types => package.to_package }
  }.merge(options)
  retrieve(options)
end

#status(ids, type = nil) ⇒ Object

Public: Checks the status of an async result.

ids - A list of ids to check. type - either :deploy or :retrieve

Examples

client.status('04sU0000000Wx6KIAS')
#=> {:done=>true, :id=>"04sU0000000Wx6KIAS", :state=>"Completed", ...}


48
49
50
51
52
53
54
55
# File 'lib/metaforce/metadata/client/file.rb', line 48

def status(ids, type=nil)
  method = :check_status
  method = :"check_#{type}_status" if type
  ids = [ids] unless ids.respond_to?(:each)
  request method do |soap|
    soap.body = { :ids => ids }
  end
end