Class: Evilution::ExampleFilter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/example_filter.rb

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.

Instance Method Summary collapse

Constructor Details

#initialize(cache:, fallback: :full_file, source_cache: nil) ⇒ ExampleFilter

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.

Returns a new instance of ExampleFilter.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/evilution/example_filter.rb', line 11

def initialize(cache:, fallback: :full_file, source_cache: nil)
  raise ArgumentError, "invalid fallback: #{fallback.inspect}" unless VALID_FALLBACKS.include?(fallback)

  @cache = cache
  @fallback = fallback
  @source_cache = source_cache
end

Instance Method Details

#call(mutation, spec_paths) ⇒ 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.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/evilution/example_filter.rb', line 19

def call(mutation, spec_paths)
  return fallback_result(spec_paths) if spec_paths.nil? || spec_paths.empty?

  token = extract_token(mutation)
  return fallback_result(spec_paths) unless token

  locations = scan_specs(token, spec_paths)
  return fallback_result(spec_paths) if locations.empty?

  locations.sort
end