Class: Policial::StyleGuides::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/policial/style_guides/base.rb

Overview

Public: Base to contain common style guide logic.

Direct Known Subclasses

CoffeeScript, JavaScript, Ruby, Scss

Instance Method Summary collapse

Constructor Details

#initialize(config_loader, options = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/policial/style_guides/base.rb', line 7

def initialize(config_loader, options = {})
  @config_loader = config_loader
  @options = options
end

Instance Method Details

#config_fileObject



28
29
30
31
32
33
34
# File 'lib/policial/style_guides/base.rb', line 28

def config_file
  if @options[:config_file].to_s.strip.empty?
    default_config_file
  else
    @options[:config_file]
  end
end

#default_config_fileObject

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/policial/style_guides/base.rb', line 24

def default_config_file
  raise NotImplementedError, "must implement ##{__method__}"
end

#exclude_file?(_filename) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/policial/style_guides/base.rb', line 16

def exclude_file?(_filename)
  raise NotImplementedError, "must implement ##{__method__}"
end

#filename_patternObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/policial/style_guides/base.rb', line 20

def filename_pattern
  raise NotImplementedError, "must implement ##{__method__}"
end

#investigate?(filename) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/policial/style_guides/base.rb', line 36

def investigate?(filename)
  enabled? && matches_pattern?(filename) && !exclude_file?(filename)
end

#violations_in_file(_file) ⇒ Object

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/policial/style_guides/base.rb', line 12

def violations_in_file(_file)
  raise NotImplementedError, "must implement ##{__method__}"
end