Class: SimpleCov::Filter
- Inherits:
-
Object
- Object
- SimpleCov::Filter
- Defined in:
- lib/simplecov/filter.rb,
sig/simplecov.rbs
Overview
Base filter class. Inherit from this to create custom filters, and
override matches?(source_file).
Direct Known Subclasses
ArrayFilter, BlockFilter, GlobFilter, RegexFilter, StringFilter
Instance Attribute Summary collapse
-
#filter_argument ⇒ T
readonly
Returns the value of attribute filter_argument.
Class Method Summary collapse
-
.build_filter(filter_argument, string_filter: StringFilter) ⇒ Filter[untyped]
string_filterselects the semantics of bare String arguments: StringFilter's segment-substring match forskip, GlobFilter forcover. - .class_for_argument(filter_argument) ⇒ singleton(Filter)
Instance Method Summary collapse
-
#initialize(filter_argument) ⇒ Filter
constructor
A new instance of Filter.
- #matches?(_source_file) ⇒ Boolean
-
#path_only? ⇒ Boolean
Whether this filter's verdict depends only on the file's path, so it can be decided before that file has any coverage.
Constructor Details
#initialize(filter_argument) ⇒ Filter
Returns a new instance of Filter.
11 12 13 |
# File 'lib/simplecov/filter.rb', line 11 def initialize(filter_argument) @filter_argument = filter_argument end |
Instance Attribute Details
#filter_argument ⇒ T (readonly)
Returns the value of attribute filter_argument.
9 10 11 |
# File 'lib/simplecov/filter.rb', line 9 def filter_argument @filter_argument end |
Class Method Details
.build_filter(filter_argument, string_filter: StringFilter) ⇒ Filter[untyped]
string_filter selects the semantics of bare String arguments:
StringFilter's segment-substring match for skip, GlobFilter for
cover. It threads through Array elements so a list gets the same
treatment as its members.
31 32 33 34 35 36 37 38 39 |
# File 'lib/simplecov/filter.rb', line 31 def self.build_filter(filter_argument, string_filter: StringFilter) case filter_argument when Filter then filter_argument when String then string_filter.new(filter_argument) when Array ArrayFilter.new(filter_argument.map { |arg| build_filter(arg, string_filter: string_filter) }) else class_for_argument(filter_argument).new(filter_argument) end end |
.class_for_argument(filter_argument) ⇒ singleton(Filter)
41 42 43 44 |
# File 'lib/simplecov/filter.rb', line 41 def self.class_for_argument(filter_argument) filter_classes_by_argument_type.find { |type, _| filter_argument.is_a?(type) }&.last || raise(ConfigurationError, "You have provided an unrecognized filter type") end |
Instance Method Details
#matches?(_source_file) ⇒ Boolean
15 16 17 |
# File 'lib/simplecov/filter.rb', line 15 def matches?(_source_file) raise NotImplementedError, "The base filter class is not intended for direct use" end |
#path_only? ⇒ Boolean
Whether this filter's verdict depends only on the file's path, so it can be decided before that file has any coverage. Used when recording which tracked files a process did not load. Defaults to false so a custom filter is never guessed at (#1250).
23 24 25 |
# File 'lib/simplecov/filter.rb', line 23 def path_only? false end |