Class: GhBbAudit::KeywordMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gh_bb_audit/keyword_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(keywords) ⇒ KeywordMatcher

Returns a new instance of KeywordMatcher.



4
5
6
# File 'lib/gh_bb_audit/keyword_matcher.rb', line 4

def initialize(keywords)
  @keyword_regex = Regexp.union(keywords)
end

Instance Method Details

#matched_file_paths(repo_file_paths) ⇒ Object



12
13
14
# File 'lib/gh_bb_audit/keyword_matcher.rb', line 12

def matched_file_paths(repo_file_paths)
  repo_file_paths.select { |files|  @keyword_regex.match(files) }
end

#repo_contains_keyword?(repo_file_paths) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/gh_bb_audit/keyword_matcher.rb', line 8

def repo_contains_keyword?(repo_file_paths)
  !(matched_file_paths(repo_file_paths).empty?)
end