Module: SimpleCov::ResultMerger

### Home Classes Methods

### In Files

- lib/simplecov/result_merger.rb

### Methods

- ::merged_result
- ::results
- ::resultset
- ::resultset_path
- ::store_result
- ::stored_data

### Class/Module Index

Quicksearch

- SimpleCov
- SimpleCov::Adapters
- SimpleCov::ArrayMergeHelper
- SimpleCov::BlockFilter
- SimpleCov::CommandGuesser
- SimpleCov::Configuration
- SimpleCov::CoverageDataError
- SimpleCov::ExitCodes
- SimpleCov::FileList
- SimpleCov::Filter
- SimpleCov::Formatter
- SimpleCov::Formatter::MultiFormatter
- SimpleCov::Formatter::SimpleFormatter
- SimpleCov::HashMergeHelper
- SimpleCov::JSON
- SimpleCov::LastRun
- SimpleCov::Railtie
- SimpleCov::Result
- SimpleCov::ResultMerger
- SimpleCov::SourceFile
- SimpleCov::SourceFile::Line
- SimpleCov::StringFilter

No matching classes.

# SimpleCov::ResultMerger

Singleton that is responsible for caching, loading and merging SimpleCov::Results into a single result for coverage analysis based upon multiple test suites.

### Public Class Methods

merged_result() click to toggle source

Gets all SimpleCov::Results from cache, merges them and produces a new SimpleCov::Result with merged coverage data and the command_name for the result consisting of a join on all source result's names

    # File lib/simplecov/result_merger.rb, line 52
    def merged_result
      merged = {}
      results.each do |result|
        merged = result.original_result.merge_resultset(merged)
      end
      result = SimpleCov::Result.new(merged)
      # Specify the command name
      result.command_name = results.map(&:command_name).sort.join(", ")
      result
    end

results() click to toggle source

Gets the resultset hash and re-creates all included instances of SimpleCov::Result from that. All results that are above the SimpleCov.merge_timeout will be dropped. Returns an array of SimpleCov::Result items.

    # File lib/simplecov/result_merger.rb, line 35
    def results
      results = []
      resultset.each do |command_name, data|
        result = SimpleCov::Result.from_hash(command_name => data)
        # Only add result if the timeout is above the configured threshold
        if (Time.now - result.created_at) < SimpleCov.merge_timeout
          results << result
        end
      end
      results
    end

resultset() click to toggle source

Loads the cached resultset from YAML and returns it as a Hash

    # File lib/simplecov/result_merger.rb, line 14
    def resultset
      if stored_data
        SimpleCov::JSON.parse(stored_data)
      else
        {}
      end
    end

resultset_path() click to toggle source

The path to the .resultset.json cache file

    # File lib/simplecov/result_merger.rb, line 9
    def resultset_path
      File.join(SimpleCov.coverage_path, '.resultset.json')
    end

store_result(result) click to toggle source

Saves the given SimpleCov::Result in the resultset cache

    # File lib/simplecov/result_merger.rb, line 64
    def store_result(result)
      new_set = resultset
      command_name, data = result.to_hash.first
      new_set[command_name] = data
      File.open(resultset_path, "w+") do |f|
        f.puts SimpleCov::JSON.dump(new_set)
      end
      true
    end

stored_data() click to toggle source

Returns the contents of the resultset cache as a string or if the file is missing or empty nil

    # File lib/simplecov/result_merger.rb, line 23
    def stored_data
      if File.exist?(resultset_path) and stored_data = File.read(resultset_path) and stored_data.length >= 2
        stored_data
      else
        nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.