Module: XCJobs::Distribute
Defined Under Namespace
Classes: Crashlytics, Crittercism, DeployGate, HockeyApp, ITC, TestFlight
Instance Method Summary
collapse
Instance Method Details
#after_action(&block) ⇒ Object
33
34
35
|
# File 'lib/xcjobs/distribute.rb', line 33
def after_action(&block)
@after_action = block
end
|
#before_action(&block) ⇒ Object
29
30
31
|
# File 'lib/xcjobs/distribute.rb', line 29
def before_action(&block)
@before_action = block
end
|
#upload(url, form_data = {}, header = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/xcjobs/distribute.rb', line 6
def upload(url, form_data = {}, = {})
@before_action.call if @before_action
curl_options = ['curl', '-sSf', "#{url}"]
form_fields = form_data.flat_map { |k, v| ['-F', "#{k}=#{v}"] }
= .flat_map { |k, v| ['-H', "#{k}:#{v}"] }
puts (curl_options + form_fields + ).join(' ')
Open3.popen2e({ "NSUnbufferedIO" => "YES" }, *(curl_options + form_fields + )) do |stdin, stdout_err, wait_thr|
output = ''
while line = stdout_err.gets
puts line
output << line
end
status = wait_thr.value
if status.success?
@after_action.call(output, status) if @after_action
else
fail "upload failed (exited with status: #{status.exitstatus})"
end
end
end
|