Module: SimpleCov

### Home Classes Methods

### In Files

- lib/simplecov.rb
- lib/simplecov/filter.rb
- lib/simplecov/formatter.rb
- lib/simplecov/railtie.rb
- lib/simplecov/result.rb
- lib/simplecov/source_file.rb
- lib/simplecov/version.rb

### Namespace

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

### Methods

- ::filtered
- ::grouped
- ::load_adapter
- ::result
- ::result?
- ::start
- ::usable?

### 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

Code coverage for ruby 1.9. Please check out README for a full introduction.

### Constants

VERSION

### Attributes

running[RW]

### Public Class Methods

filtered(files) click to toggle source

Applies the configured filters to the given array of SimpleCov::SourceFile items

    # File lib/simplecov.rb, line 68
    def filtered(files)
      result = files.clone
      filters.each do |filter|
        result = result.reject {|source_file| filter.matches?(source_file) }
      end
      SimpleCov::FileList.new result
    end

grouped(files) click to toggle source

Applies the configured groups to the given array of SimpleCov::SourceFile items

    # File lib/simplecov.rb, line 79
    def grouped(files)
      grouped = {}
      grouped_files = []
      groups.each do |name, filter|
        grouped[name] = SimpleCov::FileList.new(files.select {|source_file| filter.matches?(source_file)})
        grouped_files += grouped[name]
      end
      if groups.length > 0 and (other_files = files.reject {|source_file| grouped_files.include?(source_file)}).length > 0
        grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
      end
      grouped
    end

load_adapter(name) click to toggle source

Applies the adapter of given name on SimpleCov configuration

    # File lib/simplecov.rb, line 95
    def load_adapter(name)
      adapters.load(name)
    end

result() click to toggle source

Returns the result for the current coverage run, merging it across test suites from cache using SimpleCov::ResultMerger if use_merging is activated (default)

    # File lib/simplecov.rb, line 43
    def result
      @result ||= SimpleCov::Result.new(Coverage.result) if running
      # If we're using merging of results, store the current result
      # first, then merge the results and return those
      if use_merging
        SimpleCov::ResultMerger.store_result(@result) if @result
        return SimpleCov::ResultMerger.merged_result
      else
        return @result if defined? @result
      end
    ensure
      self.running = false
    end

result?() click to toggle source

Returns nil if the result has not been computed Otherwise, returns the result

    # File lib/simplecov.rb, line 61
    def result?
      defined? @result and @result
    end

start(adapter=nil, &block) click to toggle source

Sets up SimpleCov to run against your project. You can optionally specify an adapter to use as well as configuration with a block:

    SimpleCov.start
     OR
    SimpleCov.start 'rails' # using rails adapter
     OR
    SimpleCov.start do
      add_filter 'test'
    end
      OR
    SimpleCov.start 'rails' do
      add_filter 'test'
    end

Please check out the RDoc for SimpleCov::Configuration to find about available config options

    # File lib/simplecov.rb, line 28
    def start(adapter=nil, &block)
      return false unless SimpleCov.usable?

      require 'coverage'
      load_adapter(adapter) unless adapter.nil?
      Coverage.start
      configure(&block) if block_given?
      @result = nil
      self.running = true
    end

usable?() click to toggle source

Checks whether we're on a proper version of ruby (1.9+) and returns false if this is not the case, also printing an appropriate warning

    # File lib/simplecov.rb, line 103
    def usable?
      unless "1.9".respond_to?(:encoding)
        warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
        return false
      end
      true
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.