Class: Coverband::Utils::Result
- Inherits:
-
Object
- Object
- Coverband::Utils::Result
- Extended by:
- Forwardable
- Defined in:
- lib/coverband/utils/result.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Defines when this result has been created.
-
#files ⇒ Object
(also: #source_files)
readonly
Returns all files that are applicable to this result (sans filters!) as instances of Coverband::SourceFile.
-
#original_result ⇒ Object
readonly
Returns the original Coverage.result used for this instance of Coverband::Result.
Class Method Summary collapse
-
.add_not_loaded_files(result, tracked_files) ⇒ Object
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).
Instance Method Summary collapse
-
#filenames ⇒ Object
Returns all filenames for source files contained in this result.
-
#initialize(original_result) ⇒ Result
constructor
Initialize a new Coverband::Result from given Coverage.result (a Hash of filenames each containing an array of coverage data).
Constructor Details
#initialize(original_result) ⇒ Result
Initialize a new Coverband::Result from given Coverage.result (a Hash of filenames each containing an array of coverage data)
31 32 33 34 35 36 37 |
# 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 |
Instance Attribute Details
#created_at ⇒ Object
Defines when this result has been created. Defaults to Time.now
45 46 47 |
# File 'lib/coverband/utils/result.rb', line 45 def created_at @created_at ||= Time.now end |
#files ⇒ Object (readonly) Also known as: source_files
Returns all files that are applicable to this result (sans filters!) as instances of Coverband::SourceFile. Aliased as :source_files
21 22 23 |
# File 'lib/coverband/utils/result.rb', line 21 def files @files end |
#original_result ⇒ Object (readonly)
Returns the original Coverage.result used for this instance of Coverband::Result
18 19 20 |
# File 'lib/coverband/utils/result.rb', line 18 def original_result @original_result end |
Class Method Details
.add_not_loaded_files(result, tracked_files) ⇒ Object
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).
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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.(file) result[absolute] ||= { "data" => [], "never_loaded" => true } end end result end |
Instance Method Details
#filenames ⇒ Object
Returns all filenames for source files contained in this result
40 41 42 |
# File 'lib/coverband/utils/result.rb', line 40 def filenames files.map(&:filename) end |