Sha256: c8c7088cf3d7623d9cd758a1e6e6234e8a395ecff9bdeb5c8f6b7f42fc55af90

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require_relative '../abstract_result'

module CircleCI
  module CoverageReporter
    module SimpleCov
      class CurrentResult < AbstractResult
        # @param path [String] path to coverage directory
        def initialize(path)
          @path = path
        end

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

        # @note Implement {AbstractResult#url}
        # @return [String]
        def url
          [
            'https://circle-artifacts.com/gh',
            configuration.project,
            configuration.current_build_number,
            'artifacts',
            "0#{configuration.artifacts_dir}",
            path,
            'index.html'
          ].join('/')
        end

        private

        attr_reader :path

        # @return
        def join(name)
          File.join(configuration.artifacts_dir, path, name)
        end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
circleci-coverage_reporter-0.2.0 lib/circleci/coverage_reporter/simplecov/current_result.rb
circleci-coverage_reporter-0.1.3 lib/circleci/coverage_reporter/simplecov/current_result.rb
circleci-coverage_reporter-0.1.2 lib/circleci/coverage_reporter/simplecov/current_result.rb
circleci-coverage_reporter-0.1.1 lib/circleci/coverage_reporter/simplecov/current_result.rb
circleci-coverage_reporter-0.1.0 lib/circleci/coverage_reporter/simplecov/current_result.rb