hoopla_salesforce 0.0.2 → 0.0.3
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.
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'base64'
|
2
2
|
require 'savon'
|
3
|
-
require '
|
3
|
+
require 'hoopla_salesforce/text_reporter'
|
4
4
|
|
5
5
|
Savon::Request.logger = Logger.new(STDOUT)
|
6
6
|
Savon::Request.logger.level = Logger::WARN
|
@@ -45,7 +45,7 @@ module HooplaSalesforce
|
|
45
45
|
@header = { "wsdl:SessionHeader" => { "wsdl:sessionId" => response[:session_id] } }
|
46
46
|
end
|
47
47
|
|
48
|
-
def deploy(zipfile)
|
48
|
+
def deploy(zipfile, options)
|
49
49
|
login
|
50
50
|
|
51
51
|
data = Base64.encode64(File.read(zipfile))
|
@@ -53,9 +53,7 @@ module HooplaSalesforce
|
|
53
53
|
response = metaclient.deploy do |soap, wsse|
|
54
54
|
soap.header = header
|
55
55
|
soap.body = { "wsdl:ZipFile" => data,
|
56
|
-
"wsdl:DeployOptions" =>
|
57
|
-
"wsdl:runAllTests" => true
|
58
|
-
},
|
56
|
+
"wsdl:DeployOptions" => options,
|
59
57
|
:order! => ['wsdl:ZipFile', 'wsdl:DeployOptions']
|
60
58
|
}
|
61
59
|
end.to_hash[:deploy_response][:result]
|
@@ -73,10 +71,11 @@ module HooplaSalesforce
|
|
73
71
|
soap.body = { "wsdl:asyncProcessId" => response[:id] }
|
74
72
|
end.to_hash[:check_deploy_status_response][:result]
|
75
73
|
|
76
|
-
|
74
|
+
error_out unless TextReporter.new(response).report
|
75
|
+
end
|
77
76
|
|
78
|
-
|
79
|
-
|
77
|
+
def error_out
|
78
|
+
raise "Deployment errors. See report for details."
|
80
79
|
end
|
81
80
|
|
82
81
|
def retrieve(request)
|
@@ -45,7 +45,25 @@ module HooplaSalesforce
|
|
45
45
|
make_resources
|
46
46
|
make_zipfile
|
47
47
|
require 'hoopla_salesforce/deployer'
|
48
|
-
HooplaSalesforce::Deployer.new(username, password, token, enterprise_wsdl, metadata_wsdl).deploy(deploy_file)
|
48
|
+
HooplaSalesforce::Deployer.new(username, password, token, enterprise_wsdl, metadata_wsdl).deploy(deploy_file, deploy_options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def deploy_options
|
53
|
+
testNames = Dir["#{src}/classes/*.cls"].inject([]) do |names, f|
|
54
|
+
body = File.read(f)
|
55
|
+
if body =~ /(testMethod|@isTest)/ && match = body.match(/\bclass\s+(\w+)\s*\{\s*/)
|
56
|
+
names << match[1]
|
57
|
+
else
|
58
|
+
names
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if testNames.empty?
|
63
|
+
{ "wsdl:runAllTests" => true }
|
64
|
+
else
|
65
|
+
testNames.map! { |n| namespace.sub(/__$/, '.') + n } if namespace
|
66
|
+
{ "wsdl:runTests" => testNames }
|
49
67
|
end
|
50
68
|
end
|
51
69
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
module HooplaSalesforce
|
4
|
+
class TextReporter
|
5
|
+
attr_reader :result
|
6
|
+
|
7
|
+
def initialize(result)
|
8
|
+
@result = result
|
9
|
+
end
|
10
|
+
|
11
|
+
def green
|
12
|
+
"\e[32m"
|
13
|
+
end
|
14
|
+
|
15
|
+
def red
|
16
|
+
"\e[31m"
|
17
|
+
end
|
18
|
+
|
19
|
+
def end_color
|
20
|
+
"\e[0m"
|
21
|
+
end
|
22
|
+
|
23
|
+
def sanitize(data)
|
24
|
+
return data if data.is_a? Array
|
25
|
+
return [data] if data
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
|
29
|
+
def report
|
30
|
+
indent = " "
|
31
|
+
updated_files = []
|
32
|
+
problems = []
|
33
|
+
test_failures = []
|
34
|
+
coverage_warnings = []
|
35
|
+
|
36
|
+
result[:messages].each do |message|
|
37
|
+
if message[:success]
|
38
|
+
status = " "
|
39
|
+
status = "U" if message[:changed]
|
40
|
+
status = "D" if message[:deleted]
|
41
|
+
status = "A" if message[:created]
|
42
|
+
|
43
|
+
updated_files << "#{green}#{indent}#{status} #{message[:file_name]}#{end_color}"
|
44
|
+
end
|
45
|
+
|
46
|
+
if message[:problem]
|
47
|
+
problem = "#{red}#{indent}#{message[:file_name]}:#{message[:line_number]} (column #{message[:column_number]})\n"
|
48
|
+
problem += "#{indent*2}#{message[:problem]}#{end_color}"
|
49
|
+
problems << problem
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if ENV['FULL_OUTPUT']
|
54
|
+
pp result
|
55
|
+
else
|
56
|
+
puts "(Run with FULL_OUTPUT=true to show full deploy output)"
|
57
|
+
end
|
58
|
+
|
59
|
+
puts
|
60
|
+
puts "Updated files:"
|
61
|
+
puts updated_files.uniq.join("\n")
|
62
|
+
puts
|
63
|
+
|
64
|
+
puts "Test results:"
|
65
|
+
test_result = result[:run_test_result]
|
66
|
+
failures = test_result[:num_failures].to_i
|
67
|
+
passes = test_result[:num_tests_run].to_i - failures
|
68
|
+
print "#{indent}Passes: #{green}#{passes}#{end_color} "
|
69
|
+
print "Failures: #{red}#{failures}#{end_color} "
|
70
|
+
puts "Duration: #{test_result[:total_time]}"
|
71
|
+
puts
|
72
|
+
|
73
|
+
# :failures is only an array if we have more than 1. Fun...
|
74
|
+
sanitize(test_result[:failures]).each do |failure|
|
75
|
+
message = "#{indent}#{red}#{failure[:name]}.#{failure[:method_name]}: #{failure[:message]}\n"
|
76
|
+
message += failure[:stack_trace].split("\n").map{ |l| indent * 2 + l }.join("\n")
|
77
|
+
message += end_color
|
78
|
+
test_failures << message
|
79
|
+
end
|
80
|
+
|
81
|
+
if !test_failures.empty?
|
82
|
+
puts "Test failures:"
|
83
|
+
puts test_failures.join("\n")
|
84
|
+
puts
|
85
|
+
end
|
86
|
+
|
87
|
+
sanitize(test_result[:code_coverage_warnings]).each do |warning|
|
88
|
+
coverage_warnings << "#{indent}#{warning[:name]}: #{warning[:message]}"
|
89
|
+
end
|
90
|
+
|
91
|
+
if !coverage_warnings.empty?
|
92
|
+
puts "Coverage warnings:"
|
93
|
+
puts coverage_warnings.join("\n")
|
94
|
+
puts
|
95
|
+
end
|
96
|
+
|
97
|
+
if !problems.empty?
|
98
|
+
puts "Problems:"
|
99
|
+
puts problems.join("\n")
|
100
|
+
puts
|
101
|
+
end
|
102
|
+
|
103
|
+
return problems.empty?
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Trotter Cashion
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-11 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/hoopla_salesforce/rake/deploy_task.rb
|
61
61
|
- lib/hoopla_salesforce/rake/retrieve_task.rb
|
62
62
|
- lib/hoopla_salesforce/version.rb
|
63
|
+
- lib/hoopla_salesforce/text_reporter.rb
|
63
64
|
- lib/hoopla_salesforce/deployer.rb
|
64
65
|
- lib/hoopla_salesforce.rb
|
65
66
|
has_rdoc: true
|