module SimpleCov

def add_not_loaded_files(result)


the line-by-line coverage to zero (if relevant) or nil (comments / whitespace etc).
Finds files that were to be tracked but were not loaded and initializes
def add_not_loaded_files(result)
  if tracked_files
    result = result.dup
    Dir[tracked_files].each do |file|
      absolute = File.expand_path(file)
      result[absolute] ||= LinesClassifier.new.classify(File.foreach(absolute))
    end
  end
  result
end

def clear_result


Clear out the previously cached .result. Primarily useful in testing
def clear_result
  @result = nil
end

def filtered(files)


Applies the configured filters to the given array of SimpleCov::SourceFile items
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

def grouped(files)


Applies the configured groups to the given array of SimpleCov::SourceFile items
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.empty? && !(other_files = files.reject { |source_file| grouped_files.include?(source_file) }).empty?
    grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
  end
  grouped
end

def load_adapter(name)

def load_adapter(name)
  warn "#{Kernel.caller.first}: [DEPRECATION] #load_adapter is deprecated. Use #load_profile instead."
  load_profile(name)
end

def load_profile(name)


Applies the profile of given name on SimpleCov configuration
def load_profile(name)
  profiles.load(name)
end

def result


from cache using SimpleCov::ResultMerger if use_merging is activated (default)
Returns the result for the current coverage run, merging it across test suites
def result
  return @result if result?
  # Collect our coverage result
  if running
    @result = SimpleCov::Result.new add_not_loaded_files(Coverage.result)
  end
  # If we're using merging of results, store the current result
  # first (if there is one), then merge the results and return those
  if use_merging
    SimpleCov::ResultMerger.store_result(@result) if result?
    @result = SimpleCov::ResultMerger.merged_result
  end
  @result
ensure
  self.running = false
end

def result?


Otherwise, returns the result
Returns nil if the result has not been computed
def result?
  defined?(@result) && @result
end

def start(profile = nil, &block)


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

end
add_filter 'test'
SimpleCov.start 'rails' do
OR
end
add_filter 'test'
SimpleCov.start do
OR
SimpleCov.start 'rails' # using rails profile
OR
SimpleCov.start
You can optionally specify a profile to use as well as configuration with a block:
Sets up SimpleCov to run against your project.
def start(profile = nil, &block)
  if SimpleCov.usable?
    load_profile(profile) if profile
    configure(&block) if block_given?
    @result = nil
    self.running = true
    self.pid = Process.pid
    Coverage.start
  else
    warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
    warn "Starting with SimpleCov 1.0.0, even no-op compatibility with Ruby <= 1.8 will be entirely dropped."
    false
  end
end

def usable?


provides coverage support
Checks whether we're on a proper version of Ruby (likely 1.9+) which
def usable?
  return @usable if defined?(@usable) && !@usable.nil?
  @usable = begin
    require "coverage"
    require "simplecov/jruby_fix"
    true
  rescue LoadError
    false
  end
end