Sha256: df3e320596ad4efa8974c3aa3f984110b7d70ed7a1fa3813f5bf45ff66b38bdb

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

require_relative '../abstract_result'

module CircleCI
  module CoverageReporter
    module SimpleCov
      class BuildResult < AbstractResult
        # @param build [Build]
        def initialize(build)
          @build = build
        end

        # @note Implement {AbstractResult#coverage}
        # @return [Float]
        def coverage
          JSON.parse(find_artifact('.last_run.json').body)['result']['covered_percent']
        end

        # @note Implement {AbstractResult#url}
        # @return [String]
        def url
          find_artifact('index.html').url
        end

        private

        attr_reader :build

        # @param end_with [String]
        # @return [Artifact]
        def find_artifact(end_with)
          build.artifacts.find { |a| a.end_with?(end_with) }
        end
      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/simplecov/build_result.rb
circleci-coverage_reporter-0.1.1 lib/circleci/coverage_reporter/simplecov/build_result.rb
circleci-coverage_reporter-0.1.0 lib/circleci/coverage_reporter/simplecov/build_result.rb