Class: RSpecTracer::Filter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_tracer/filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Internal Filter — see RSpecTracer for the user-facing surface. Internal dispatch shim for the user-facing ‘add_filter` / `add_coverage_filter` DSL. The user passes a String / Regexp / Proc / Array; `Filter.register` wraps it in the matching subclass so the engine can call a uniform `#match?(source_file)`.

Direct Known Subclasses

ArrayFilter, BlockFilter, RegexFilter, StringFilter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ Filter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal method on the tracer pipeline.



43
44
45
# File 'lib/rspec_tracer/filter.rb', line 43

def initialize(filter)
  @filter = filter
end

Instance Attribute Details

#filterObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal attribute.



14
15
16
# File 'lib/rspec_tracer/filter.rb', line 14

def filter
  @filter
end

Class Method Details

.filter_class(filter) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal helper for the tracer pipeline.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rspec_tracer/filter.rb', line 26

def self.filter_class(filter)
  case filter
  when String
    StringFilter
  when Regexp
    RegexFilter
  when Proc
    BlockFilter
  when Array
    ArrayFilter
  else
    raise ArgumentError, 'Unknow filter'
  end
end

.register(filter) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal helper for the tracer pipeline.



18
19
20
21
22
# File 'lib/rspec_tracer/filter.rb', line 18

def self.register(filter)
  return filter if filter.is_a?(Filter)

  filter_class(filter).new(filter)
end

Instance Method Details

#match?(_source_file) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal method on the tracer pipeline.

Returns:

  • (Boolean)


49
50
51
# File 'lib/rspec_tracer/filter.rb', line 49

def match?(_source_file)
  raise "#{self.class.name}#match? is not intended for direct use"
end