Sha256: 96724d494859d14c0aaaad4fa44a2e89ec36ffe1d167604ee05f0a1ab3cf3f8a

Contents?: true

Size: 1001 Bytes

Versions: 85

Compression:

Stored size: 1001 Bytes

Contents

module SimpleCov::ArrayMergeHelper
  # Merges an array of coverage results with self
  def merge_resultset(array)
    new_array = []

    self.each_with_index do |element, i|
      new_array[i] = element
    end

    array.each_with_index do |element, i|
      if element.nil? and 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

module SimpleCov::HashMergeHelper
  # Merges the given Coverage.result hash with self
  def merge_resultset(hash)
    new_resultset = {}
    (self.keys + hash.keys).each do |filename|
      new_resultset[filename] = []
    end

    new_resultset.each do |filename, data|
      new_resultset[filename] = (self[filename] || []).merge_resultset(hash[filename] || [])
    end
    new_resultset
  end
end

Array.send :include, SimpleCov::ArrayMergeHelper
Hash.send :include, SimpleCov::HashMergeHelper

Version data entries

85 entries across 64 versions & 9 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.7 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.6 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.5 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.4 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.2 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
tdiary-5.0.1 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/merge_helpers.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/simplecov-0.9.0/lib/simplecov/merge_helpers.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/simplecov-0.9.0/lib/simplecov/merge_helpers.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/simplecov-0.9.0/lib/simplecov/merge_helpers.rb
simplecov-0.9.2 lib/simplecov/merge_helpers.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/simplecov-0.8.2/lib/simplecov/merge_helpers.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/simplecov-0.8.2/lib/simplecov/merge_helpers.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/simplecov-0.8.2/lib/simplecov/merge_helpers.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/simplecov-0.8.2/lib/simplecov/merge_helpers.rb
simplecov-0.9.1 lib/simplecov/merge_helpers.rb
simplecov-0.9.0 lib/simplecov/merge_helpers.rb
simplecov-0.8.2 lib/simplecov/merge_helpers.rb
simplecov-0.8.1 lib/simplecov/merge_helpers.rb