Sha256: f8ccac22fdb073fe3d95ddc7e614e2f0d5a1eca539a1496d0bd2b974009d9dd3

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

module Coverband
  module Reporters
    class HTMLReport < Base
      attr_accessor :filtered_report_files, :open_report, :static, :notice,
                    :base_path, :filename

      def initialize(store, options = {})
        coverband_reports = Coverband::Reporters::Base.report(store, options)
        self.open_report = options.fetch(:open_report) { true }
        self.static = options.fetch(:static) { true }
        # TODO: refactor notice out to top level of web only
        self.notice = options.fetch(:notice) { nil }
        self.base_path = options.fetch(:base_path) { nil }
        self.filename = options.fetch(:filename) { nil }

        self.filtered_report_files = self.class.fix_reports(coverband_reports)
      end

      def file_details
        Coverband::Utils::HTMLFormatter.new(filtered_report_files,
                                            base_path: base_path,
                                            notice: notice).format_source_file!(filename)
      end

      def report
        if static?
          report_static_site
        else
          report_dynamic_html
        end
      end

      private

      def static?
        static
      end

      def report_static_site
        Coverband::Utils::HTMLFormatter.new(filtered_report_files).format_static_html!
        if open_report
          `open #{Coverband.configuration.root}/coverage/index.html`
        else
          Coverband.configuration.logger.info 'report is ready and viewable: open coverage/index.html'
        end

        Coverband::Utils::S3Report.instance.persist! if Coverband.configuration.s3_bucket
      end

      def report_dynamic_html
        Coverband::Utils::HTMLFormatter.new(filtered_report_files,
                                            base_path: base_path,
                                            notice: notice).format_dynamic_html!
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
coverband-4.2.4.rc.3 lib/coverband/reporters/html_report.rb
coverband-4.2.4.rc.2 lib/coverband/reporters/html_report.rb
coverband-4.2.4.rc.1 lib/coverband/reporters/html_report.rb
coverband-4.2.3 lib/coverband/reporters/html_report.rb
coverband-4.2.3.rc.2 lib/coverband/reporters/html_report.rb
coverband-4.2.3.rc.1 lib/coverband/reporters/html_report.rb
coverband-4.2.2 lib/coverband/reporters/html_report.rb
coverband-4.2.2.rc.1 lib/coverband/reporters/html_report.rb
coverband-4.2.1 lib/coverband/reporters/html_report.rb
coverband-4.2.1.rc4 lib/coverband/reporters/html_report.rb
coverband-4.2.1.rc3 lib/coverband/reporters/html_report.rb
coverband-4.2.1.rc2 lib/coverband/reporters/html_report.rb
coverband-4.2.1.rc1 lib/coverband/reporters/html_report.rb