Sha256: bc2ad0a0e8ef202c5603b950074a9e2800619f3f76562f802d4bada34efe34b5

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 Bytes

Contents

require_relative 'abstract_vcs_client'

module CircleCI
  module CoverageReporter
    class GitHubClient < AbstractVCSClient
      # @note Implement {AbstractVCSClient#create_comment}
      # @param reports [Array<Report>]
      # @return [void]
      def create_comment(reports)
        Faraday.new(url: 'https://api.github.com').post do |req|
          req.url ['/repos', configuration.project, 'commits', configuration.current_revision, 'comments'].join('/')
          req.headers['Authorization'] = "token #{token}"
          req.headers['Content-Type'] = 'application/json'
          req.body = JSON.generate(body: reports.join("\n"))
        end
      end

      private

      # @return [Client]
      def configuration
        CoverageReporter.client.configuration
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
circleci-coverage_reporter-0.1.2 lib/circleci/coverage_reporter/github_client.rb
circleci-coverage_reporter-0.1.1 lib/circleci/coverage_reporter/github_client.rb
circleci-coverage_reporter-0.1.0 lib/circleci/coverage_reporter/github_client.rb