Sha256: 53aeaa2c592c1192e977bc981f45bd218b07ae647503e85d8043869c50a3727a

Contents?: true

Size: 1.71 KB

Versions: 10

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

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

      def initialize(store, options = {})
        self.page = options.fetch(:page) { nil }
        self.open_report = options.fetch(:open_report) { true }
        # TODO: refactor notice out to top level of web only
        self.notice = options.fetch(:notice) { nil }
        self.base_path = options.fetch(:base_path) { "./" }
        self.filename = options.fetch(:filename) { nil }

        coverband_reports = Coverband::Reporters::Base.report(store, options)
        # NOTE: at the moment the optimization around paging and filenames only works for hash redis store
        self.filtered_report_files = if (page || filename) && store.is_a?(Coverband::Adapters::HashRedisStore)
          coverband_reports
        else
          self.class.fix_reports(coverband_reports)
        end
      end

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

      def report
        report_dynamic_html
      end

      def report_data
        report_dynamic_data
      end

      private

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

      def report_dynamic_data
        Coverband::Utils::HTMLFormatter.new(filtered_report_files,
          base_path: base_path,
          page: page,
          notice: notice).format_dynamic_data!
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
coverband-6.1.4 lib/coverband/reporters/html_report.rb
coverband-6.1.3 lib/coverband/reporters/html_report.rb
coverband-6.1.2 lib/coverband/reporters/html_report.rb
coverband-6.1.2.rc.1 lib/coverband/reporters/html_report.rb
coverband-6.1.1 lib/coverband/reporters/html_report.rb
coverband-6.1.0 lib/coverband/reporters/html_report.rb
coverband-6.0.3.rc.4 lib/coverband/reporters/html_report.rb
coverband-6.0.3.rc.3 lib/coverband/reporters/html_report.rb
coverband-6.0.3.rc.2 lib/coverband/reporters/html_report.rb
coverband-6.0.3.rc.1 lib/coverband/reporters/html_report.rb