Sha256: 3438624748be2c29cb31d93f1663fa63c46c00eb19f2c069364cd974ad493b15

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module Coverband
  module Reporters
    class SimpleCovReport < Base
      def self.report(store, options = {})
        begin
          require 'simplecov'
        rescue StandardError
          msg = 'coverband requires simplecov to generate a report, when config.reporter=scov'
          Coverband.configuration.logger.error msg
          return
        end

        scov_style_report = super(store, options)
        open_report = options.fetch(:open_report) { true }

        # set root to show files if user has simplecov profiles
        # https://github.com/danmayer/coverband/issues/59
        SimpleCov.root(current_root)

        # add in files never hit in coverband
        SimpleCov.track_files "#{current_root}/{app,lib,config}/**/*.{rb,haml,erb,slim}"

        # still apply coverband filters
        report_files = SimpleCov.add_not_loaded_files(scov_style_report)
        filtered_report_files = {}
        report_files.each_pair do |file, data|
          next if Coverband.configuration.ignore.any? { |i| file.match(i) }
          filtered_report_files[file] = data
        end

        SimpleCov::Result.new(filtered_report_files).format!

        if open_report
          `open #{SimpleCov.coverage_dir}/index.html`
        else
          Coverband.configuration.logger.info "report is ready and viewable: open #{SimpleCov.coverage_dir}/index.html"
        end

        s3_writer_options = {
          region: Coverband.configuration.s3_region,
          access_key_id: Coverband.configuration.s3_access_key_id,
          secret_access_key: Coverband.configuration.s3_secret_access_key
        }
        Coverband::Utils::S3ReportWriter.new(Coverband.configuration.s3_bucket,
                                                s3_writer_options).persist! if Coverband.configuration.s3_bucket
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coverband-3.0.0 lib/coverband/reporters/simple_cov_report.rb
coverband-3.0.0.alpha2 lib/coverband/reporters/simple_cov_report.rb
coverband-3.0.0.alpha lib/coverband/reporters/simple_cov_report.rb