metaforce 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/lib/metaforce/config.rb +8 -4
- data/lib/metaforce/metadata/transaction.rb +4 -4
- data/lib/metaforce/services/client.rb +3 -0
- data/lib/metaforce/tasks/README.md +57 -0
- data/lib/metaforce/tasks/metaforce.rake +18 -9
- data/lib/metaforce/version.rb +1 -1
- data/spec/fixtures/sample/metaforce.yml +13 -0
- data/spec/lib/services/services_spec.rb +8 -0
- metadata +19 -16
data/README.md
CHANGED
@@ -62,6 +62,8 @@ end
|
|
62
62
|
This gem is far from being feature complete. Here's a list of things that still
|
63
63
|
need to be done.
|
64
64
|
|
65
|
+
* Implement command line utility that can watch the directory and deploy when a
|
66
|
+
file changes.
|
65
67
|
* Implement CRUD based calls <http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_crud_based_calls_intro.htm>.
|
66
68
|
* Implement some helper methods for diffing metadata.
|
67
69
|
* Ability to deploy directly from a git repository.
|
@@ -75,6 +77,10 @@ feature on a new branch, then send me a pull request with a detailed
|
|
75
77
|
description. Please provide applicable rspec specs.
|
76
78
|
|
77
79
|
## Version History
|
80
|
+
**0.3.5** (February 11, 2012)
|
81
|
+
|
82
|
+
* Allow rake tasks to get credentials from a metaforce.yml file.
|
83
|
+
|
78
84
|
**0.3.4** (February 9, 2012)
|
79
85
|
|
80
86
|
* Add rake tasks.
|
data/lib/metaforce/config.rb
CHANGED
@@ -42,12 +42,16 @@ module Metaforce
|
|
42
42
|
# Set this to true if you're authenticating with a Sandbox instance.
|
43
43
|
# Defaults to false.
|
44
44
|
attr_accessor :test
|
45
|
+
# Causes Metaforce::Transaction.result to loop until the transaction is
|
46
|
+
# complete. Defaults to false.
|
47
|
+
attr_accessor :wait_until_done
|
45
48
|
|
46
49
|
def initialize
|
47
|
-
Savon.log
|
48
|
-
HTTPI.log
|
49
|
-
@api_version
|
50
|
-
@test
|
50
|
+
Savon.log = false
|
51
|
+
HTTPI.log = false
|
52
|
+
@api_version = "23.0"
|
53
|
+
@test = false
|
54
|
+
@wait_until_done = false
|
51
55
|
end
|
52
56
|
|
53
57
|
def logger
|
@@ -40,14 +40,14 @@ module Metaforce
|
|
40
40
|
|
41
41
|
# Returns the decoded content of the returned zip file.
|
42
42
|
def zip_file
|
43
|
-
raise
|
43
|
+
raise 'Request was not a retrieve.' unless @type == :retrieve
|
44
44
|
Base64.decode64(@result[:zip_file])
|
45
45
|
end
|
46
46
|
|
47
47
|
# Unzips the returned zip file to +destination+.
|
48
48
|
def unzip(destination)
|
49
49
|
zip = zip_file
|
50
|
-
file = Tempfile.new(
|
50
|
+
file = Tempfile.new('retrieve')
|
51
51
|
file.write(zip)
|
52
52
|
path = file.path
|
53
53
|
file.close
|
@@ -63,8 +63,8 @@ module Metaforce
|
|
63
63
|
|
64
64
|
# Returns the deploy or retrieve result
|
65
65
|
def result(options={})
|
66
|
-
self.wait_until_done if options[:wait_until_done]
|
67
|
-
raise
|
66
|
+
self.wait_until_done if (options[:wait_until_done] || Metaforce.configuration.wait_until_done)
|
67
|
+
raise 'Request has not completed.' unless @done
|
68
68
|
@result = @client.status(@id, @type) if @result.nil?
|
69
69
|
@result
|
70
70
|
end
|
@@ -11,6 +11,9 @@ module Metaforce
|
|
11
11
|
# is nil, it will get the username, password and security token from the
|
12
12
|
# configuration.
|
13
13
|
def initialize(options=nil)
|
14
|
+
# Convert string keys to hashes
|
15
|
+
options.dup.each { |key, value| options[key.to_sym] = value } if options.is_a?(Hash)
|
16
|
+
|
14
17
|
options = {
|
15
18
|
:username => Metaforce.configuration.username,
|
16
19
|
:password => Metaforce.configuration.password,
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Metaforce Rake Tasks
|
2
|
+
These are a set of default rake tasks that can be used for deploying/retrieving
|
3
|
+
metadata using Rake and Metaforce. The following rake tasks are provided:
|
4
|
+
|
5
|
+
* metaforce:deploy
|
6
|
+
* metaforce:retrieve
|
7
|
+
|
8
|
+
You can include the rake tasks by adding the following to your Rakefile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
begin
|
12
|
+
require 'metaforce'
|
13
|
+
load 'metaforce/tasks/metaforce.rake'
|
14
|
+
rescue LoadError
|
15
|
+
task :metaforce do
|
16
|
+
puts "Couldn't load metaforce tasks"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
## metaforce.yml
|
22
|
+
Include a metaforce.yml file in the root if you'd rather not type in your
|
23
|
+
username, password and security token everytime you deploy or retrieve.
|
24
|
+
|
25
|
+
With one environment:
|
26
|
+
|
27
|
+
```yaml
|
28
|
+
---
|
29
|
+
username: user
|
30
|
+
password: password
|
31
|
+
security_token: securitytoken
|
32
|
+
test: true # defaults to false
|
33
|
+
```
|
34
|
+
|
35
|
+
With multiple environments:
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
---
|
39
|
+
production:
|
40
|
+
username: user
|
41
|
+
password: password
|
42
|
+
security_token: securitytoken
|
43
|
+
sandbox:
|
44
|
+
username: user
|
45
|
+
password: password
|
46
|
+
security_token: securitytoken
|
47
|
+
test: true
|
48
|
+
```
|
49
|
+
|
50
|
+
This would deploy using the `sandbox` environment:
|
51
|
+
|
52
|
+
`rake metaforce:deploy env="sandbox"`
|
53
|
+
|
54
|
+
This would retrieve code using the `production` environment and would unzip the
|
55
|
+
contents to "production\_code" rather than the default of "src".
|
56
|
+
|
57
|
+
`rake metaforce:retrieve env="production" dir="production_code"`
|
@@ -1,14 +1,22 @@
|
|
1
1
|
namespace :metaforce do
|
2
2
|
Metaforce.log = true
|
3
3
|
|
4
|
-
task :require do
|
5
|
-
require 'metaforce'
|
6
|
-
end
|
7
|
-
|
8
4
|
task :login do
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
if File.exists?('metaforce.yml')
|
6
|
+
require 'yaml'
|
7
|
+
config = YAML.load_file('metaforce.yml')
|
8
|
+
env = ENV['env'] || 'default'
|
9
|
+
root = config.has_key?(env) ? config[env] : config
|
10
|
+
username = root["username"]
|
11
|
+
password = root["password"]
|
12
|
+
security_token = root["security_token"] || ''
|
13
|
+
test = root["test"] || false
|
14
|
+
Metaforce.configuration.test = test
|
15
|
+
else
|
16
|
+
print "username: "; username = STDIN.gets.chomp
|
17
|
+
print "password: "; password = STDIN.gets.chomp
|
18
|
+
print "security token: "; security_token = STDIN.gets.chomp
|
19
|
+
end
|
12
20
|
@client = Metaforce::Metadata::Client.new :username => username,
|
13
21
|
:password => password,
|
14
22
|
:security_token => security_token
|
@@ -27,10 +35,11 @@ namespace :metaforce do
|
|
27
35
|
|
28
36
|
desc "Retrieve metadata from the organization to src directory"
|
29
37
|
task :retrieve => :login do
|
38
|
+
dir = ENV['dir'] || 'src'
|
30
39
|
retrieval = @client.retrieve_unpackaged(File.expand_path('src/package.xml'))
|
31
40
|
result = retrieval.result(:wait_until_done => true)
|
32
|
-
retrieval.unzip(File.expand_path(
|
33
|
-
puts "Successfully retrieved metadata."
|
41
|
+
retrieval.unzip(File.expand_path(dir))
|
42
|
+
puts "Successfully retrieved metadata to '#{dir}'."
|
34
43
|
end
|
35
44
|
|
36
45
|
end
|
data/lib/metaforce/version.rb
CHANGED
@@ -20,5 +20,13 @@ describe Metaforce::Services::Client do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
23
|
+
context "when given a hash with strings" do
|
24
|
+
it "works just like symbols" do
|
25
|
+
savon.expects(:login).with(:username => 'valid', :password => 'password').returns(:success)
|
26
|
+
session = Metaforce::Services::Client.new("username" => 'valid', "password" => 'password').session
|
27
|
+
session.should eq({ :session_id => "00DU0000000Ilbh!AQoAQHVcube9Z6CRlbR9Eg8ZxpJlrJ6X8QDbnokfyVZItFKzJsLHIRGiqhzJkYsNYRkd3UVA9.s82sbjEbZGUqP3mG6TP_P8",
|
28
|
+
:metadata_server_url => "https://na12-api.salesforce.com/services/Soap/m/23.0/00DU0000000Albh" })
|
29
|
+
end
|
30
|
+
end
|
23
31
|
end
|
24
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metaforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &9127740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.5.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9127740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: savon
|
27
|
-
requirement: &
|
27
|
+
requirement: &9127260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9127260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rubyzip
|
38
|
-
requirement: &
|
38
|
+
requirement: &9126870 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.9.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9126870
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &9126570 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *9126570
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &9126200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *9126200
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &9125950 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *9125950
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: savon_spec
|
82
|
-
requirement: &
|
82
|
+
requirement: &9125560 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 0.1.6
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *9125560
|
91
91
|
description: A Ruby gem for interacting with the Salesforce Metadata API
|
92
92
|
email:
|
93
93
|
- eric@ejholmes.net
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/metaforce/metadata/transaction.rb
|
111
111
|
- lib/metaforce/services.rb
|
112
112
|
- lib/metaforce/services/client.rb
|
113
|
+
- lib/metaforce/tasks/README.md
|
113
114
|
- lib/metaforce/tasks/metaforce.rake
|
114
115
|
- lib/metaforce/types.rb
|
115
116
|
- lib/metaforce/version.rb
|
@@ -128,6 +129,7 @@ files:
|
|
128
129
|
- spec/fixtures/requests/login/success.xml
|
129
130
|
- spec/fixtures/requests/retrieve/in_progress.xml
|
130
131
|
- spec/fixtures/sample/Rakefile
|
132
|
+
- spec/fixtures/sample/metaforce.yml
|
131
133
|
- spec/fixtures/sample/src/classes/TestClass.cls
|
132
134
|
- spec/fixtures/sample/src/classes/TestClass.cls-meta.xml
|
133
135
|
- spec/fixtures/sample/src/package.xml
|
@@ -178,6 +180,7 @@ test_files:
|
|
178
180
|
- spec/fixtures/requests/login/success.xml
|
179
181
|
- spec/fixtures/requests/retrieve/in_progress.xml
|
180
182
|
- spec/fixtures/sample/Rakefile
|
183
|
+
- spec/fixtures/sample/metaforce.yml
|
181
184
|
- spec/fixtures/sample/src/classes/TestClass.cls
|
182
185
|
- spec/fixtures/sample/src/classes/TestClass.cls-meta.xml
|
183
186
|
- spec/fixtures/sample/src/package.xml
|