class Covered::Coveralls
def call(wrapper, output = $stderr)
def call(wrapper, output = $stderr) if body = detect_service output.puts "Submitting data using #{body.inspect}..." source_files = [] wrapper.each do |coverage| path = wrapper.relative_path(coverage.path) source_files << { name: path, source_digest: Digest::MD5.hexdigest(coverage.read), coverage: coverage.to_a, } end body[:source_files] = source_files Async do representation = Async::REST::Representation.new( Async::REST::Resource.for(URL), wrapper: Wrapper.new ) begin response = representation.post(body) output.puts "Got response: #{response.read}" ensure representation.close end end end end
def detect_service
def detect_service if token = ENV.fetch('COVERALLS_REPO_TOKEN', @token) return {"repo_token" => token} elsif @service && @job_id return {"service_name" => @service, "service_job_id" => @job_id} elsif job_id = ENV['TRAVIS_JOB_ID'] return {"service_name" => "travis-ci", "service_job_id" => job_id} else warn "#{self.class} can't detect service! Please specify COVERALLS_REPO_TOKEN." end return nil end
def initialize(token: nil, service: nil, job_id: nil)
def initialize(token: nil, service: nil, job_id: nil) @token = token @service = service @job_id = job_id end