class Coverband::Utils::Result

Attributes

created_at[W]

Explicitly set the Time this result has been created

files[R]

Returns all files that are applicable to this result (sans filters!) as instances of Coverband::SourceFile. Aliased as :source_files

original_result[R]

Returns the original Coverage.result used for this instance of Coverband::Result

source_files[R]

Returns all files that are applicable to this result (sans filters!) as instances of Coverband::SourceFile. Aliased as :source_files

Public Class Methods

add_not_loaded_files(result, tracked_files) click to toggle source

Finds files that were to be tracked but were not loaded and initializes the line-by-line coverage to zero (if relevant) or nil (comments / whitespace etc).

# File lib/coverband/utils/result.rb, line 51
def self.add_not_loaded_files(result, tracked_files)
  if tracked_files
    # TODO: Can we get rid of this dup it wastes memory
    result = result.dup
    Dir[tracked_files].each do |file|
      absolute = File.expand_path(file)
      result[absolute] ||= {
        "data" => Array.new(File.foreach(absolute).count) { 0 },
        "never_loaded" => true
      }
    end
  end

  result
end
new(original_result) click to toggle source

Initialize a new Coverband::Result from given Coverage.result (a Hash of filenames each containing an array of coverage data)

# File lib/coverband/utils/result.rb, line 31
def initialize(original_result)
  @original_result = (original_result || {}).freeze

  @files = Coverband::Utils::FileList.new(@original_result.map { |filename, coverage|
    Coverband::Utils::SourceFile.new(filename, coverage) if File.file?(filename)
  }.compact.sort_by(&:short_name))
end

Public Instance Methods

created_at() click to toggle source

Defines when this result has been created. Defaults to Time.now

# File lib/coverband/utils/result.rb, line 45
def created_at
  @created_at ||= Time.now
end
filenames() click to toggle source

Returns all filenames for source files contained in this result

# File lib/coverband/utils/result.rb, line 40
def filenames
  files.map(&:filename)
end