Class: Covered::Files
Overview
Collects coverage information keyed by source path.
Instance Attribute Summary collapse
- #Coverage indexed by expanded source path.(indexedbyexpandedsourcepath.) ⇒ Object readonly
-
#paths ⇒ Object
Returns the value of attribute paths.
Instance Method Summary collapse
-
#[](path) ⇒ Object
Get or create coverage for the given path.
-
#add(coverage) ⇒ Object
Merge coverage for the given path into this collection.
-
#annotate(path, line_number, value) ⇒ Object
Add an annotation to a line in the given path.
-
#clear ⇒ Object
Remove all tracked coverage data.
-
#each ⇒ Object
Enumerate tracked coverage objects.
-
#empty? ⇒ Boolean
Whether there are no tracked paths.
-
#initialize ⇒ Files
constructor
Initialize an empty coverage collection.
-
#mark(path, line_number, value) ⇒ Object
Mark a line in the given path as executed.
Methods inherited from Base
#accept?, #expand_path, #finish, #relative_path, #start
Constructor Details
#initialize ⇒ Files
Initialize an empty coverage collection.
15 16 17 18 19 |
# File 'lib/covered/files.rb', line 15 def initialize(*) super @paths = {} end |
Instance Attribute Details
#Coverage indexed by expanded source path.(indexedbyexpandedsourcepath.) ⇒ Object (readonly)
22 |
# File 'lib/covered/files.rb', line 22 attr_accessor :paths |
#paths ⇒ Object
Returns the value of attribute paths.
22 23 24 |
# File 'lib/covered/files.rb', line 22 def paths @paths end |
Instance Method Details
#[](path) ⇒ Object
Get or create coverage for the given path.
27 28 29 |
# File 'lib/covered/files.rb', line 27 def [](path) @paths[path] ||= Coverage.for(path) end |
#add(coverage) ⇒ Object
Merge coverage for the given path into this collection.
55 56 57 |
# File 'lib/covered/files.rb', line 55 def add(coverage) self[coverage.path].merge!(coverage) end |
#annotate(path, line_number, value) ⇒ Object
Add an annotation to a line in the given path.
49 50 51 |
# File 'lib/covered/files.rb', line 49 def annotate(path, line_number, value) self[path].annotate(line_number, value) end |
#clear ⇒ Object
Remove all tracked coverage data.
73 74 75 |
# File 'lib/covered/files.rb', line 73 def clear @paths.clear end |
#each ⇒ Object
Enumerate tracked coverage objects.
63 64 65 66 67 68 69 |
# File 'lib/covered/files.rb', line 63 def each return to_enum unless block_given? @paths.each_value do |coverage| yield coverage end end |
#empty? ⇒ Boolean
Whether there are no tracked paths.
33 34 35 |
# File 'lib/covered/files.rb', line 33 def empty? @paths.empty? end |
#mark(path, line_number, value) ⇒ Object
Mark a line in the given path as executed.
41 42 43 |
# File 'lib/covered/files.rb', line 41 def mark(path, line_number, value) self[path].mark(line_number, value) end |