Sha256: 59109eb83359a0fc53b6b2d3675696be391f72c7cd118760ce2b22f2ad1ae634
Contents?: true
Size: 992 Bytes
Versions: 14
Compression:
Stored size: 992 Bytes
Contents
module SimpleCov module ArrayMergeHelper # Merges an array of coverage results with self def merge_resultset(array) new_array = dup array.each_with_index do |element, i| if element.nil? && new_array[i].nil? new_array[i] = nil else local_value = element || 0 other_value = new_array[i] || 0 new_array[i] = local_value + other_value end end new_array end end end module SimpleCov module HashMergeHelper # Merges the given Coverage.result hash with self def merge_resultset(hash) new_resultset = {} (keys + hash.keys).each do |filename| new_resultset[filename] = [] end new_resultset.each_key do |filename| new_resultset[filename] = (self[filename] || []).merge_resultset(hash[filename] || []) end new_resultset end end end Array.send :include, SimpleCov::ArrayMergeHelper Hash.send :include, SimpleCov::HashMergeHelper
Version data entries
14 entries across 14 versions & 5 rubygems