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

Version Path
simplecov-0.11.1 lib/simplecov/merge_helpers.rb
simplecov-0.11.0 lib/simplecov/merge_helpers.rb
suzuko-0.1.8 vendor/bundle/ruby/2.0.0/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
suzuko-0.1.7 vendor/bundle/ruby/2.0.0/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/simplecov-0.10.0/lib/simplecov/merge_helpers.rb
simplecov-0.10.0 lib/simplecov/merge_helpers.rb