Sha256: 33e9abcf5fc2da2ddec8802b7844993378c2b970372e346b7a7961a631587071

Contents?: true

Size: 1.77 KB

Versions: 7

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

module Coverband
  module Reporters
    class SimpleCovReport < Base
      def self.report(store, options = {})
        begin
          require 'simplecov'
        rescue StandardError
          Coverband.configuration.logger.error 'coverband requires simplecov in order to generate a report, when configured for the scov report style.'
          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
        }
        S3ReportWriter.new(Coverband.configuration.s3_bucket, s3_writer_options).persist! if Coverband.configuration.s3_bucket
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coverband-2.0.3 lib/coverband/reporters/simple_cov_report.rb
coverband-2.0.3.alpha lib/coverband/reporters/simple_cov_report.rb
coverband-2.0.2 lib/coverband/reporters/simple_cov_report.rb
coverband-2.0.2.alpha2 lib/coverband/reporters/simple_cov_report.rb
coverband-2.0.2.alpha lib/coverband/reporters/simple_cov_report.rb
coverband-2.0.1 lib/coverband/reporters/simple_cov_report.rb
coverband-2.0.1.alpha lib/coverband/reporters/simple_cov_report.rb