class Policial::StyleGuides::Base

Public: Base to contain common style guide logic.

Public Class Methods

new(config_loader, options = {}) click to toggle source
# File lib/policial/style_guides/base.rb, line 7
def initialize(config_loader, options = {})
  @config_loader = config_loader
  @options = options
end

Public Instance Methods

config_file() click to toggle source
# 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_file() click to toggle source
# File lib/policial/style_guides/base.rb, line 24
def default_config_file
  raise NotImplementedError, "must implement ##{__method__}"
end
exclude_file?(_filename) click to toggle source
# File lib/policial/style_guides/base.rb, line 16
def exclude_file?(_filename)
  raise NotImplementedError, "must implement ##{__method__}"
end
filename_pattern() click to toggle source
# File lib/policial/style_guides/base.rb, line 20
def filename_pattern
  raise NotImplementedError, "must implement ##{__method__}"
end
investigate?(filename) click to toggle source
# File lib/policial/style_guides/base.rb, line 36
def investigate?(filename)
  enabled? && matches_pattern?(filename) && !exclude_file?(filename)
end
violations_in_file(_file) click to toggle source
# File lib/policial/style_guides/base.rb, line 12
def violations_in_file(_file)
  raise NotImplementedError, "must implement ##{__method__}"
end

Private Instance Methods

enabled?() click to toggle source
# File lib/policial/style_guides/base.rb, line 42
def enabled?
  @options[:enabled] != false
end
matches_pattern?(filename) click to toggle source
# File lib/policial/style_guides/base.rb, line 46
def matches_pattern?(filename)
  !(filename =~ filename_pattern).nil?
end