Class: RSpec::Coverage::Result
- Inherits:
-
Object
- Object
- RSpec::Coverage::Result
- Extended by:
- Forwardable
- Defined in:
- lib/rspec/coverage/result.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root, coverage = {}) ⇒ Result
constructor
A new instance of Result.
- #to_h ⇒ Object
- #traverse(*results, &block) ⇒ Object
- #traverse!(*results) ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
3 4 5 |
# File 'lib/rspec/coverage/result.rb', line 3 def root @root end |
Class Method Details
.traverse(*results, &block) ⇒ Object
8 9 10 |
# File 'lib/rspec/coverage/result.rb', line 8 def self.traverse *results, &block new("", results.shift).traverse(*results, &block).to_h end |
Instance Method Details
#to_h ⇒ Object
36 37 38 |
# File 'lib/rspec/coverage/result.rb', line 36 def to_h @coverage.dup end |
#traverse(*results, &block) ⇒ Object
12 13 14 |
# File 'lib/rspec/coverage/result.rb', line 12 def traverse *results, &block RSpec::Coverage::Result.new(root, @coverage.dup).traverse!(*results, &block) end |
#traverse!(*results) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/coverage/result.rb', line 16 def traverse! *results results.unshift self files = results.map(&:keys).flatten.uniq files.each do |file| next unless file.start_with? root lines = results.map{ |r| r[file] || [] } len = lines.map(&:length).max @coverage[file] = len.times.map do |i| yield file, *lines.map { |ls| ls[i] } end end self end |