metaforce 0.5.3 → 1.0.0a

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.
Files changed (72) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +1 -11
  4. data/LICENSE +22 -0
  5. data/README.md +91 -96
  6. data/Rakefile +6 -14
  7. data/examples/example.rb +51 -0
  8. data/lib/metaforce/abstract_client.rb +76 -0
  9. data/lib/metaforce/client.rb +27 -0
  10. data/lib/metaforce/config.rb +41 -19
  11. data/lib/metaforce/job/crud.rb +13 -0
  12. data/lib/metaforce/job/deploy.rb +87 -0
  13. data/lib/metaforce/job/retrieve.rb +92 -0
  14. data/lib/metaforce/job.rb +183 -0
  15. data/lib/metaforce/login.rb +39 -0
  16. data/lib/metaforce/manifest.rb +18 -93
  17. data/lib/metaforce/metadata/client/crud.rb +86 -0
  18. data/lib/metaforce/metadata/client/file.rb +113 -0
  19. data/lib/metaforce/metadata/client.rb +7 -225
  20. data/lib/metaforce/services/client.rb +45 -86
  21. data/lib/metaforce/version.rb +1 -1
  22. data/lib/metaforce.rb +27 -7
  23. data/metaforce.gemspec +19 -16
  24. data/spec/fixtures/package.xml +1 -1
  25. data/spec/fixtures/payload.zip +0 -0
  26. data/spec/fixtures/requests/{describe_layout → foo}/invalid_session.xml +0 -0
  27. data/spec/fixtures/requests/send_email/success.xml +1 -0
  28. data/spec/lib/client_spec.rb +34 -0
  29. data/spec/lib/config_spec.rb +8 -50
  30. data/spec/lib/job/deploy_spec.rb +53 -0
  31. data/spec/lib/job/retrieve_spec.rb +28 -0
  32. data/spec/lib/job_spec.rb +95 -0
  33. data/spec/lib/login_spec.rb +18 -0
  34. data/spec/lib/manifest_spec.rb +22 -168
  35. data/spec/lib/metadata/client_spec.rb +84 -179
  36. data/spec/lib/metaforce_spec.rb +20 -0
  37. data/spec/lib/services/client_spec.rb +22 -35
  38. data/spec/spec_helper.rb +24 -3
  39. data/spec/support/client.rb +38 -0
  40. data/wsdl/26.0/metadata.xml +4750 -0
  41. data/wsdl/26.0/partner.xml +3340 -0
  42. metadata +114 -77
  43. data/Guardfile +0 -9
  44. data/bin/metaforce +0 -6
  45. data/lib/metaforce/core_extensions/string.rb +0 -31
  46. data/lib/metaforce/core_extensions.rb +0 -1
  47. data/lib/metaforce/custom_actions.rb +0 -29
  48. data/lib/metaforce/error.rb +0 -3
  49. data/lib/metaforce/login_details.rb +0 -28
  50. data/lib/metaforce/metadata/crud.rb +0 -103
  51. data/lib/metaforce/metadata/file.rb +0 -74
  52. data/lib/metaforce/metadata/transaction.rb +0 -100
  53. data/lib/metaforce/metadata.rb +0 -4
  54. data/lib/metaforce/rake/deploy.rb +0 -35
  55. data/lib/metaforce/rake/retrieve.rb +0 -39
  56. data/lib/metaforce/rake/tests.rb +0 -62
  57. data/lib/metaforce/rake.rb +0 -43
  58. data/lib/metaforce/services.rb +0 -1
  59. data/lib/metaforce/tasks/README.md +0 -62
  60. data/lib/metaforce/tasks/metaforce.rake +0 -5
  61. data/lib/metaforce/thor/metaforce.rb +0 -117
  62. data/lib/metaforce/types.rb +0 -249
  63. data/spec/.gitignore +0 -1
  64. data/spec/fixtures/sample/Rakefile +0 -2
  65. data/spec/fixtures/sample/metaforce.yml +0 -13
  66. data/spec/fixtures/sample/src/classes/TestClass.cls +0 -2
  67. data/spec/fixtures/sample/src/classes/TestClass.cls-meta.xml +0 -5
  68. data/spec/fixtures/sample/src/package.xml +0 -8
  69. data/spec/lib/core_extensions/string_spec.rb +0 -23
  70. data/spec/lib/metadata/crud_spec.rb +0 -66
  71. data/spec/lib/metadata/file_spec.rb +0 -17
  72. data/spec/lib/metadata/transaction_spec.rb +0 -68
@@ -1,249 +0,0 @@
1
- module Metaforce
2
- module Metadata
3
- class Types
4
-
5
- def self.name(key)
6
- METADATA_TYPES[key][:name]
7
- end
8
-
9
- def self.folder(key)
10
- METADATA_TYPES[key][:folder]
11
- end
12
-
13
- def self.key(name)
14
- METADATA_TYPES.each do |key, component|
15
- return key if component[:name] == name
16
- end
17
- end
18
-
19
- def self.all
20
- METADATA_TYPES
21
- end
22
-
23
- def [](key)
24
- METADATA_TYPES[key]
25
- end
26
-
27
- private
28
-
29
- METADATA_TYPES = {
30
- :action_override => {
31
- :name => "ActionOverride",
32
- :folder => "objects",
33
- :plural => :action_overrides
34
- },
35
- :analytic_snapshot => {
36
- :name => "AnalyticsSnapshot",
37
- :folder => "analyticsnapshots",
38
- :plural => :analytic_snapshots
39
- },
40
- :apex_class => {
41
- :name => "ApexClass",
42
- :folder => "classes",
43
- :plural => :apex_classes
44
- },
45
- :article_type => {
46
- :name => "ArticleType",
47
- :folder => "objects",
48
- :plural => :article_types
49
- },
50
- :apex_component => {
51
- :name => "ApexComponent",
52
- :folder => "components",
53
- :plural => :apex_components
54
- },
55
- :apex_page => {
56
- :name => "ApexPage",
57
- :folder => "pages",
58
- :plural => :apex_pages
59
- },
60
- :apex_trigger => {
61
- :name => "ApexTrigger",
62
- :folder => "triggers",
63
- :plural => :apex_triggers
64
- },
65
- :business_process => {
66
- :name => "BusinessProcess",
67
- :folder => "objects",
68
- :plural => :business_processes
69
- },
70
- :custom_application => {
71
- :name => "CustomApplication",
72
- :folder => "applications",
73
- :plural => :custom_applications
74
- },
75
- :custom_field => {
76
- :name => "CustomField",
77
- :folder => "objects",
78
- :plural => :custom_fields
79
- },
80
- :custom_labels => {
81
- :name => "CustomLabels",
82
- :folder => "labels",
83
- :plural => :custom_labels
84
- },
85
- :custom_object => {
86
- :name => "CustomObject",
87
- :folder => "objects",
88
- :plural => :custom_objects
89
- },
90
- :custom_object_translation => {
91
- :name => "CustomObjectTranslation",
92
- :folder => "objectTranslations",
93
- :plural => :custom_object_translations
94
- },
95
- :custom_page_web_link => {
96
- :name => "CustomPageWebLink",
97
- :folder => "weblinks",
98
- :plural => :custom_page_web_links
99
- },
100
- :custom_site => {
101
- :name => "CustomSite",
102
- :folder => "sites",
103
- :plural => :custom_sites
104
- },
105
- :custom_tab => {
106
- :name => "CustomTab",
107
- :folder => "tabs",
108
- :plural => :custom_tabs
109
- },
110
- :dashboard => {
111
- :name => "Dashboard",
112
- :folder => "dashboards",
113
- :plural => :dashboards
114
- },
115
- :data_category_group => {
116
- :name => "DataCategoryGroup",
117
- :folder => "datacategorygroups",
118
- :plural => :data_category_groups
119
- },
120
- :document => {
121
- :name => "Document",
122
- :folder => "document",
123
- :plural => :documents
124
- },
125
- :email_template => {
126
- :name => "EmailTemplate",
127
- :folder => "email",
128
- :plural => :email_templates
129
- },
130
- :entitlement_template => {
131
- :name => "EntitlementTemplate",
132
- :folder => "entitlementTemplates",
133
- :plural => :entitlement_templates
134
- },
135
- :field_set => {
136
- :name => "FieldSet",
137
- :folder => "objects",
138
- :plural => :field_sets
139
- },
140
- :home_page_component => {
141
- :name => "HomePageComponent",
142
- :folder => "homePageComponents",
143
- :plural => :home_page_components
144
- },
145
- :home_page_layout => {
146
- :name => "HomePageLayout",
147
- :folder => "HomePageLayouts",
148
- :plural => :home_page_layouts
149
- },
150
- :layout => {
151
- :name => "Layout",
152
- :folder => "layouts",
153
- :plural => :layouts
154
- },
155
- :letterhead => {
156
- :name => "Letterhead",
157
- :folder => "letterhead",
158
- :plural => :letterheads
159
- },
160
- :list_view => {
161
- :name => "ListView",
162
- :folder => "objects",
163
- :plural => :list_views
164
- },
165
- :named_filter => {
166
- :name => "NamedFilter",
167
- :folder => "objects",
168
- :plural => :named_filters
169
- },
170
- :permission_set => {
171
- :name => "PermissionSet",
172
- :folder => "permissionsets",
173
- :plural => :permission_sets
174
- },
175
- :portal => {
176
- :name => "Portal",
177
- :folder => "portals",
178
- :plural => :portals
179
- },
180
- :profile => {
181
- :name => "Profile",
182
- :folder => "profiles",
183
- :plural => :profiles
184
- },
185
- :record_type => {
186
- :name => "RecordType",
187
- :folder => "objects",
188
- :plural => :record_types
189
- },
190
- :remote_site_setting => {
191
- :name => "RemoteSiteSetting",
192
- :folder => "remoteSiteSettings",
193
- :plural => :remote_site_settings
194
- },
195
- :report => {
196
- :name => "Report",
197
- :folder => "reports",
198
- :plural => :reports
199
- },
200
- :report_type => {
201
- :name => "ReportType",
202
- :folder => "reportTypes",
203
- :plural => :report_types
204
- },
205
- :scontrol => {
206
- :name => "scontrol",
207
- :folder => "scontrols",
208
- :plural => :scontrols
209
- },
210
- :sharing_reason => {
211
- :name => "SharingReason",
212
- :folder => "objects",
213
- :plural => :sharing_reasons
214
- },
215
- :sharing_recalculation => {
216
- :name => "SharingRecalculation",
217
- :folder => "objects",
218
- :plural => :sharing_recalculations
219
- },
220
- :static_resource => {
221
- :name => "StaticResource",
222
- :folder => "staticResources",
223
- :plural => :static_resources
224
- },
225
- :translations => {
226
- :name => "Translations",
227
- :folder => "translations",
228
- :plural => :translations
229
- },
230
- :validation_rule => {
231
- :name => "ValidationRule",
232
- :folder => "objects",
233
- :plural => :validation_rules
234
- },
235
- :weblink => {
236
- :name => "Weblink",
237
- :folder => "objects",
238
- :plural => :weblinks
239
- },
240
- :workflow => {
241
- :name => "Workflow",
242
- :folder => "workflows",
243
- :plural => :workflows
244
- }
245
- }
246
-
247
- end
248
- end
249
- end
data/spec/.gitignore DELETED
@@ -1 +0,0 @@
1
- test_spec.rb
@@ -1,2 +0,0 @@
1
- require 'metaforce/rake'
2
- load 'metaforce/tasks/metaforce.rake'
@@ -1,13 +0,0 @@
1
- ---
2
- production: &production
3
- username: user
4
- password: password
5
- security_token: aaaaaaaa
6
-
7
- sandbox: &sandbox
8
- username: user
9
- password: password
10
- security_token: aaaaaaaa
11
- test: true
12
-
13
- default: *production
@@ -1,2 +0,0 @@
1
- public class TestClass {
2
- }
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3
- <apiVersion>23.0</apiVersion>
4
- <status>Active</status>
5
- </ApexClass>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0"?>
2
- <Package xmlns="http://soap.sforce.com/2006/04/metadata">
3
- <types>
4
- <members>TestClass</members>
5
- <name>ApexClass</name>
6
- </types>
7
- <version>23.0</version>
8
- </Package>
@@ -1,23 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe String do
4
-
5
- describe ".lower_camelcase" do
6
- it "camelCases underscored_words" do
7
- "hello_world".lower_camelcase.should eq("helloWorld")
8
- end
9
- end
10
-
11
- describe ".camelcase" do
12
- it "CamelCases underscored_words" do
13
- "hello_world".camelcase.should eq("HelloWorld")
14
- end
15
- end
16
-
17
- describe ".underscore" do
18
- it "underscores CamelCased words" do
19
- "HelloWorld".underscore.should eq("hello_world")
20
- end
21
- end
22
-
23
- end
@@ -1,66 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Metaforce::Metadata::Client do
4
-
5
- before(:each) do
6
- savon.expects(:login).with(:username => 'valid', :password => 'password').returns(:success)
7
- end
8
-
9
- let(:client) do
10
- Metaforce::Metadata::Client.new(:username => 'valid', :password => 'password')
11
- end
12
-
13
- describe ".create" do
14
- it "returns a transaction" do
15
- savon.expects(:create).with(:metadata => [{:api_version => '23.0', :description => '', :label => 'test', :content => '', :full_name => 'component'}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'wsdl:ApexComponent'}}).returns(:in_progress)
16
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
17
- response = client.create(:apex_component, :full_name => 'component', :label => 'test', :content => '')
18
- response.should be_a(Metaforce::Transaction)
19
- end
20
-
21
- it "base64 encodes any content" do
22
- savon.expects(:create).with(:metadata => [{:api_version => '23.0', :description => '', :full_name => 'component', :label => 'test', :content => "dGVzdA==\n"}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'wsdl:ApexComponent'}}).returns(:in_progress)
23
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
24
- response = client.create(:apex_component, :full_name => 'component', :label => 'test', :content => 'test')
25
- end
26
-
27
- it "responds to method missing" do
28
- savon.expects(:create).with(:metadata => [{:api_version => '23.0', :description => '', :label => 'test', :content => '', :full_name => 'component'}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'wsdl:ApexComponent'}}).returns(:in_progress)
29
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
30
- response = client.create_apex_component(:full_name => 'component', :label => 'test', :content => '')
31
- response.should be_a(Metaforce::Transaction)
32
- end
33
- end
34
-
35
- describe ".delete" do
36
- it "returns a transaction" do
37
- savon.expects(:delete).with(:metadata => [{:full_name => 'component'}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'wsdl:ApexComponent'}}).returns(:in_progress)
38
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
39
- response = client.delete(:apex_component, 'component')
40
- response.should be_a(Metaforce::Transaction)
41
- end
42
-
43
- it "responds to method missing" do
44
- savon.expects(:delete).with(:metadata => [{:full_name => 'component'}], :attributes! => {'ins0:metadata' => {'xsi:type' => 'wsdl:ApexComponent'}}).returns(:in_progress)
45
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
46
- response = client.delete_apex_component('component')
47
- response.should be_a(Metaforce::Transaction)
48
- end
49
- end
50
-
51
- describe ".update" do
52
- it "returns a transaction" do
53
- savon.expects(:update).with(:metadata => {:current_name => 'old_component', :metadata => [{:api_version => '23.0', :description => '', :label => 'test', :content => '', :full_name => 'component'}], :attributes! => {:metadata => {'xsi:type' => 'wsdl:ApexComponent'}}}).returns(:in_progress)
54
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
55
- response = client.update(:apex_component, 'old_component', :full_name => 'component', :label => 'test', :content => '')
56
- response.should be_a(Metaforce::Transaction)
57
- end
58
-
59
- it "responds to method missing" do
60
- savon.expects(:update).with(:metadata => {:current_name => 'old_component', :metadata => [{:api_version => '23.0', :description => '', :label => 'test', :content => '', :full_name => 'component'}], :attributes! => {:metadata => {'xsi:type' => 'wsdl:ApexComponent'}}}).returns(:in_progress)
61
- savon.expects(:check_status).with(:ids => ['04sU0000000WNWoIAO']).returns(:done);
62
- response = client.update_apex_component('old_component', :full_name => 'component', :label => 'test', :content => '')
63
- response.should be_a(Metaforce::Transaction)
64
- end
65
- end
66
- end
@@ -1,17 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Metaforce::Metadata::MetadataFile do
4
- describe "#template" do
5
- it "returns a hash" do
6
- file = Metaforce::Metadata::MetadataFile.template(:apex_page)
7
- file.should be_a(Hash)
8
- end
9
- end
10
-
11
- describe ".to_xml" do
12
- it "returns a string representation of the hash" do
13
- file = Metaforce::Metadata::MetadataFile.template(:apex_page)
14
- file.to_xml.should be_a(String)
15
- end
16
- end
17
- end
@@ -1,68 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Metaforce::Transaction do
4
-
5
- before(:each) do
6
- savon.expects(:login).with(:username => 'valid', :password => 'password').returns(:success)
7
- Metaforce::Metadata::Client.any_instance.stubs(:create_deploy_file).returns('')
8
- end
9
-
10
- let(:client) do
11
- Metaforce::Metadata::Client.new(:username => 'valid', :password => 'password')
12
- end
13
-
14
- describe ".done?" do
15
-
16
- it "allows you to check if the transaction has completed" do
17
- savon.expects(:deploy).with(:zip_file => '', :deploy_options => {}).returns(:in_progress)
18
- savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
19
- deployment = client.deploy(File.expand_path('../../../fixtures/sample', __FILE__))
20
- deployment.done?.should eq(true)
21
- end
22
-
23
- it "doesn't send a request if it has already completed" do
24
- savon.expects(:deploy).with(:zip_file => '', :deploy_options => {}).returns(:in_progress)
25
- savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
26
- deployment = client.deploy(File.expand_path('../../../fixtures/sample', __FILE__))
27
- deployment.done?.should eq(true)
28
- expect { deployment.done?.should eq(true) }.to_not raise_error
29
- end
30
-
31
- end
32
-
33
- describe ".status" do
34
-
35
- it "returns the status" do
36
- savon.expects(:deploy).with(:zip_file => '', :deploy_options => {}).returns(:in_progress)
37
- savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
38
- deployment = client.deploy(File.expand_path('../../../fixtures/sample', __FILE__))
39
- savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
40
- deployment.status.should be_a(Hash)
41
- end
42
-
43
- end
44
-
45
- describe ".result" do
46
-
47
- it "allows you to check the transaction result" do
48
- savon.expects(:deploy).with(:zip_file => '', :deploy_options => {}).returns(:in_progress)
49
- savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
50
- deployment = client.deploy(File.expand_path('../../../fixtures/sample', __FILE__))
51
- deployment.done?.should eq(true)
52
- savon.expects(:check_deploy_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
53
- deployment.result.should be_a(Hash)
54
- end
55
-
56
- it "doesn't send a request if it has already retrieved the result" do
57
- savon.expects(:deploy).with(:zip_file => '', :deploy_options => {}).returns(:in_progress)
58
- savon.expects(:check_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
59
- deployment = client.deploy(File.expand_path('../../../fixtures/sample', __FILE__))
60
- deployment.done?.should eq(true)
61
- savon.expects(:check_deploy_status).with(:ids => [ "04sU0000000WNWoIAO" ]).returns(:done)
62
- deployment.result.should be_a(Hash)
63
- expect { deployment.result }.to_not raise_error
64
- end
65
-
66
- end
67
-
68
- end