Class: SimpleCov::ArrayFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/simplecov/filter.rb,
sig/simplecov.rbs

Overview

Matches when any of the component filters built from the array's elements match. Note: filter_argument holds the built Filter objects, not the raw array passed to new.

Instance Attribute Summary

Attributes inherited from Filter

#filter_argument

Instance Method Summary collapse

Methods inherited from Filter

build_filter, class_for_argument

Constructor Details

#initialize(filter_argument) ⇒ ArrayFilter

Returns a new instance of ArrayFilter.

Parameters:

  • filter_argument (Array[filter_arg])


152
153
154
155
156
157
158
# File 'lib/simplecov/filter.rb', line 152

def initialize(filter_argument)
  filter_objects = filter_argument.map do |arg|
    Filter.build_filter(arg)
  end

  super(filter_objects)
end

Instance Method Details

#matches?(source_files_list) ⇒ Boolean

Returns true if any of the filters in the array match the given source file. Configure this Filter like StringFilter.new(['some/path', /^some_regex/, Proc.new {|src_file| ... }])

Parameters:

Returns:

  • (Boolean)


167
168
169
170
171
# File 'lib/simplecov/filter.rb', line 167

def matches?(source_files_list)
  filter_argument.any? do |arg|
    arg.matches?(source_files_list)
  end
end

#path_only?Boolean

Whether the verdict depends only on the path, so it can be decided before the file has any coverage.

Returns:

  • (Boolean)


161
162
163
# File 'lib/simplecov/filter.rb', line 161

def path_only?
  filter_argument.all?(&:path_only?)
end