module XCJobs::Distribute
Public Instance Methods
after_action(&block)
click to toggle source
# File lib/xcjobs/distribute.rb, line 33 def after_action(&block) @after_action = block end
before_action(&block)
click to toggle source
# File lib/xcjobs/distribute.rb, line 29 def before_action(&block) @before_action = block end
upload(url, form_data = {}, header = {})
click to toggle source
# File lib/xcjobs/distribute.rb, line 6 def upload(url, form_data = {}, header = {}) @before_action.call if @before_action curl_options = ['curl', '-sSf', "#{url}"] form_fields = form_data.flat_map { |k, v| ['-F', "#{k}=#{v}"] } header_fields = header.flat_map { |k, v| ['-H', "#{k}:#{v}"] } puts (curl_options + form_fields + header_fields).join(' ') Open3.popen2e({ "NSUnbufferedIO" => "YES" }, *(curl_options + form_fields + header_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