class Coverband::Utils::Result
Attributes
Explicitly set the Time this result has been created
Returns all files that are applicable to this result (sans filters!) as instances of Coverband::SourceFile. Aliased as :source_files
Returns the original Coverage.result used for this instance of Coverband::Result
Returns all files that are applicable to this result (sans filters!) as instances of Coverband::SourceFile. Aliased as :source_files
Public Class Methods
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
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
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
Returns all filenames for source files contained in this result
# File lib/coverband/utils/result.rb, line 40 def filenames files.map(&:filename) end