class Coverband::Utils::Results

Attributes

report[RW]
type[RW]

Public Class Methods

new(report) click to toggle source
# File lib/coverband/utils/results.rb, line 11
def initialize(report)
  self.report = report
  self.type = Coverband::MERGED_TYPE
  @results = {}
end

Public Instance Methods

file_from_path_with_type(full_path, results_type = :merged) click to toggle source
# File lib/coverband/utils/results.rb, line 48
def file_from_path_with_type(full_path, results_type = :merged)
  return unless get_results(results_type)

  get_results(results_type).source_files.find { |file| file.filename == full_path }
end
file_with_type(source_file, results_type) click to toggle source
# File lib/coverband/utils/results.rb, line 17
def file_with_type(source_file, results_type)
  return unless get_results(results_type)

  get_results(results_type).source_files.find { |file| file.filename == source_file.filename }
end
method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/coverband/utils/results.rb, line 54
def method_missing(method, *args)
  if get_results(type).respond_to?(method)
    get_results(type).send(method, *args)
  else
    super
  end
end
respond_to_missing?(method) click to toggle source
# File lib/coverband/utils/results.rb, line 62
def respond_to_missing?(method)
  if get_results(type).respond_to?(method)
    true
  else
    false
  end
end
runtime_relavent_lines(source_file) click to toggle source
# File lib/coverband/utils/results.rb, line 37
def runtime_relavent_lines(source_file)
  return 0 unless runtime_coverage

  eager_file = get_eager_file(source_file)
  runtime_file = get_runtime_file(source_file)

  return runtime_file.covered_lines_count unless eager_file

  eager_file.relevant_lines - eager_file.covered_lines_count
end
runtime_relevant_coverage(source_file) click to toggle source
# File lib/coverband/utils/results.rb, line 23
def runtime_relevant_coverage(source_file)
  return unless eager_loading_coverage && runtime_coverage

  eager_file = get_eager_file(source_file)
  runtime_file = get_runtime_file(source_file)

  return 0.0 unless runtime_file

  return runtime_file.formatted_covered_percent unless eager_file

  runtime_relavant_lines = eager_file.relevant_lines - eager_file.covered_lines_count
  runtime_file.runtime_relavant_calculations(runtime_relavant_lines) { |file| file.formatted_covered_percent }
end

Private Instance Methods

eager_loading_coverage() click to toggle source
# File lib/coverband/utils/results.rb, line 80
def eager_loading_coverage
  get_results(Coverband::EAGER_TYPE)
end
get_eager_file(source_file) click to toggle source
# File lib/coverband/utils/results.rb, line 72
def get_eager_file(source_file)
  eager_loading_coverage.source_files.find { |file| file.filename == source_file.filename }
end
get_results(type) click to toggle source

This is a first version of lazy loading the results for the full advantage we need to push lazy loading to the file level inside Coverband::Utils::Result

# File lib/coverband/utils/results.rb, line 93
def get_results(type)
  return nil unless Coverband::ALL_TYPES.include?(type)

  if @results.key?(type)
    @results[type]
  else
    @results[type] = Coverband::Utils::Result.new(report[type])
  end
end
get_runtime_file(source_file) click to toggle source
# File lib/coverband/utils/results.rb, line 76
def get_runtime_file(source_file)
  runtime_coverage.source_files.find { |file| file.filename == source_file.filename }
end
runtime_coverage() click to toggle source
# File lib/coverband/utils/results.rb, line 84
def runtime_coverage
  get_results(Coverband::RUNTIME_TYPE)
end