Sha256: a7dfc95310fec5c1fc004b1eb2ed392198f96b917978a83d021f90c6ea18ce25

Contents?: true

Size: 931 Bytes

Versions: 11

Compression:

Stored size: 931 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] || []).extend(SimpleCov::ArrayMergeHelper).merge_resultset(hash[filename] || [])
      end
      new_resultset
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
cvss-suite-1.0.8 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.7 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.6 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.5 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.4 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.3 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.2 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.1 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
cvss-suite-1.0.0 vendor/cache/ruby/2.2.0/gems/simplecov-0.11.2/lib/simplecov/merge_helpers.rb
simplecov-0.11.2 lib/simplecov/merge_helpers.rb