class SimpleCov::Filter

Base filter class. Inherit from this to create custom filters, and overwrite the passes?(source_file) instance method

# A sample class that rejects all source files. class StupidFilter < SimpleCov::Filter

def passes?(source_file)
  false
end

end

Attributes

filter_argument[R]

Public Class Methods

build_filter(filter_argument) click to toggle source
# File lib/simplecov/filter.rb, line 30
def self.build_filter(filter_argument)
  return filter_argument if filter_argument.is_a?(SimpleCov::Filter)

  class_for_argument(filter_argument).new(filter_argument)
end
class_for_argument(filter_argument) click to toggle source
# File lib/simplecov/filter.rb, line 36
def self.class_for_argument(filter_argument)
  if filter_argument.is_a?(String)
    SimpleCov::StringFilter
  elsif filter_argument.is_a?(Regexp)
    SimpleCov::RegexFilter
  elsif filter_argument.is_a?(Array)
    SimpleCov::ArrayFilter
  elsif filter_argument.is_a?(Proc)
    SimpleCov::BlockFilter
  else
    raise ArgumentError, "You have provided an unrecognized filter type"
  end
end
new(filter_argument) click to toggle source
# File lib/simplecov/filter.rb, line 17
def initialize(filter_argument)
  @filter_argument = filter_argument
end

Public Instance Methods

matches?(_source_file) click to toggle source
# File lib/simplecov/filter.rb, line 21
def matches?(_source_file)
  raise "The base filter class is not intended for direct use"
end
passes?(source_file) click to toggle source
# File lib/simplecov/filter.rb, line 25
def passes?(source_file)
  warn "#{Kernel.caller.first}: [DEPRECATION] #passes? is deprecated. Use #matches? instead."
  matches?(source_file)
end