123456789_123456789_123456789_123456789_123456789_

Class: SimpleCov::Filter

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/simplecov/filter.rb

Overview

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

def passes?(source_file)
  false
end

end

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(filter_argument) ⇒ Filter

[ GitHub ]

  
# File 'lib/simplecov/filter.rb', line 18

def initialize(filter_argument)
  @filter_argument = filter_argument
end

Class Method Details

.build_filter(filter_argument)

[ GitHub ]

  
# File 'lib/simplecov/filter.rb', line 31

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)

[ GitHub ]

  
# File 'lib/simplecov/filter.rb', line 37

def self.class_for_argument(filter_argument)
  case filter_argument
  when String
    SimpleCov::StringFilter
  when Regexp
    SimpleCov::RegexFilter
  when Array
    SimpleCov::ArrayFilter
  when Proc
    SimpleCov::BlockFilter
  else
    raise ArgumentError, "You have provided an unrecognized filter type"
  end
end

Instance Attribute Details

#filter_argument (readonly)

[ GitHub ]

  
# File 'lib/simplecov/filter.rb', line 16

attr_reader :filter_argument

Instance Method Details

#matches?(_source_file) ⇒ Boolean

[ GitHub ]

  
# File 'lib/simplecov/filter.rb', line 22

def matches?(_source_file)
  raise "The base filter class is not intended for direct use"
end

#passes?(source_file) ⇒ Boolean

[ GitHub ]

  
# File 'lib/simplecov/filter.rb', line 26

def passes?(source_file)
  warn "#{Kernel.caller.first}: [DEPRECATION] #passes? is deprecated. Use #matches? instead."
  matches?(source_file)
end