Class: Isolator::Ignorer

Inherits:
Object
  • Object
show all
Defined in:
lib/isolator/ignorer.rb

Overview

Handle ignoring isolator errors using a yml file

Defined Under Namespace

Classes: AdapterIgnore, ParseError

Class Method Summary collapse

Class Method Details

.prepare(path:, regex_string: "^.*(#ignores#):.*$") ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/isolator/ignorer.rb', line 18

def prepare(path:, regex_string: "^.*(#ignores#):.*$")
  return unless File.exist?(path)

  ignores = begin
    YAML.load_file(path, aliases: true)
  rescue ArgumentError # support for older rubies https://github.com/rails/rails/commit/179d0a1f474ada02e0030ac3bd062fc653765dbe
    YAML.load_file(path)
  end

  raise ParseError.new(path, ignores.class) unless ignores.respond_to?(:fetch)

  Isolator.adapters.each do |id, adapter|
    ignored_paths = ignores.fetch(id, [])
    AdapterIgnore.new(adapter: adapter, ignored_paths: ignored_paths, regex_string: regex_string).prepare
  end
end