Class: SCSSLint::Runner

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

Overview

Finds and aggregates all lints found by running the registered linters against a set of SCSS files.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/scss_lint/runner.rb', line 11

def initialize(options = {})
  @lints = []

  included_linters = LinterRegistry.
    extract_linters_from(options.fetch(:included_linters, []))

  included_linters = LinterRegistry.linters if included_linters.empty?

  excluded_linters = LinterRegistry.
    extract_linters_from(options.fetch(:excluded_linters, []))

  @linters = (included_linters - excluded_linters).map(&:new)
end

Instance Attribute Details

#lintersObject (readonly)

Returns the value of attribute linters.



9
10
11
# File 'lib/scss_lint/runner.rb', line 9

def linters
  @linters
end

#lintsObject (readonly)

Returns the value of attribute lints.



9
10
11
# File 'lib/scss_lint/runner.rb', line 9

def lints
  @lints
end

Instance Method Details

#lints?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/scss_lint/runner.rb', line 38

def lints?
  lints.any?
end

#run(files = []) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/scss_lint/runner.rb', line 25

def run(files = [])
  raise NoFilesError, 'No SCSS files specified' if files.empty?
  raise NoLintersError, 'No linters specified' if linters.empty?

  files.each do |file|
    find_lints(file)
  end

  linters.each do |linter|
    @lints += linter.lints
  end
end