Module: Covet::CollectionCompressor

Defined in:
lib/covet/collection_compressor.rb

Class Method Summary collapse

Class Method Details

.compress(coverage_info) ⇒ Object

Turn sparse Array returned from ‘Coverage.peek_result` into more compact representation - a Hash of only the lines that were executed at least once.

Parameters:

  • coverage_info (Hash)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/covet/collection_compressor.rb', line 8

def self.compress(coverage_info)
  ret = {}
  coverage_info.each do |fname, cov_ary|
    ret[fname] ||= {}
    cov_ary.each_with_index do |times_run, idx|
      next if times_run.to_i == 0
      ret[fname][idx+1] = times_run # lineno = idx + 1
    end
  end
  ret
end