Class: Sanctify::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/sanctify/scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Scanner

Returns a new instance of Scanner.



8
9
10
11
12
13
14
# File 'lib/sanctify/scanner.rb', line 8

def initialize(args)
  config = args[:config] || {}
  @repo = Repo.new(args, ignored_paths: config['ignored_paths'])
  @matcher_list = MatcherList.new(
    custom_matchers: config['custom_matchers'],
    disabled_matchers: config['disabled_matchers'])
end

Instance Attribute Details

#matcher_listObject (readonly)

Returns the value of attribute matcher_list.



7
8
9
# File 'lib/sanctify/scanner.rb', line 7

def matcher_list
  @matcher_list
end

#repoObject (readonly)

Returns the value of attribute repo.



7
8
9
# File 'lib/sanctify/scanner.rb', line 7

def repo
  @repo
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/sanctify/scanner.rb', line 16

def run
  repo.added_lines.each do |line, path|
    matcher_list.each do |matcher|
      next if matcher.disabled?
      if matcher.regex.match(line)
        raise ScannerError, message(matcher, line, path)
      end
    end
  end
end