Class: SlimLint::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/slim_lint/runner.rb

Overview

Responsible for running the applicable linters against the desired files.

Instance Method Summary collapse

Instance Method Details

#run(options = {}) ⇒ SlimLint::Report

Runs the appropriate linters against the desired files given the specified options.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :config_file (String)

    path of configuration file to load

  • :config (SlimLint::Configuration)

    configuration to use

  • :excluded_files (Array<String>)
  • :included_linters (Array<String>)
  • :excluded_linters (Array<String>)

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/slim_lint/runner.rb', line 16

def run(options = {})
  config = load_applicable_config(options)
  linter_selector = SlimLint::LinterSelector.new(config, options)

  if options[:stdin_file_path].nil?
    files = extract_applicable_files(config, options)
    lints = files.map do |file|
      collect_lints(File.read(file), file, linter_selector, config)
    end.flatten
  else
    files = [options[:stdin_file_path]]
    lints = collect_lints($stdin.read, options[:stdin_file_path], linter_selector, config)
  end

  SlimLint::Report.new(lints, files)
end