Class: GhBbAudit::KeywordMatcher
- Inherits:
-
Object
- Object
- GhBbAudit::KeywordMatcher
- Defined in:
- lib/gh_bb_audit/keyword_matcher.rb
Instance Method Summary collapse
-
#initialize(keywords) ⇒ KeywordMatcher
constructor
A new instance of KeywordMatcher.
- #matched_file_paths(repo_file_paths) ⇒ Object
- #repo_contains_keyword?(repo_file_paths) ⇒ Boolean
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
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 |