Module: ERBLint::LinterRegistry

Overview

Stores all linters available to the application.

Constant Summary collapse

CUSTOM_LINTERS_DIR =
'.erb-linters'

Class Method Summary collapse

Class Method Details

.clearObject



10
11
12
# File 'lib/erb_lint/linter_registry.rb', line 10

def clear
  @linters = nil
end

.find_by_name(name) ⇒ Object



18
19
20
# File 'lib/erb_lint/linter_registry.rb', line 18

def find_by_name(name)
  linters.detect { |linter| linter.simple_name == name }
end

.included(linter_class) ⇒ Object



14
15
16
# File 'lib/erb_lint/linter_registry.rb', line 14

def included(linter_class)
  @loaded_linters << linter_class
end

.lintersObject



22
23
24
25
26
27
# File 'lib/erb_lint/linter_registry.rb', line 22

def linters
  @linters ||= begin
    load_custom_linters
    @loaded_linters
  end
end

.load_custom_linters(directory = CUSTOM_LINTERS_DIR) ⇒ Object



29
30
31
32
# File 'lib/erb_lint/linter_registry.rb', line 29

def load_custom_linters(directory = CUSTOM_LINTERS_DIR)
  ruby_files = Dir.glob(File.expand_path(File.join(directory, '**', '*.rb')))
  ruby_files.each { |file| require file }
end