Class: Codeowners::Cli::FilesFromParentFolder
- Inherits:
-
SuggestionStrategy
- Object
- SuggestionStrategy
- Codeowners::Cli::FilesFromParentFolder
- Defined in:
- lib/codeowners/cli/suggest_file_from_pattern.rb
Overview
Pick all files from parent folder of pattern. Apply fuzzy match search on all files to pick the best option.
Instance Method Summary collapse
-
#pick_suggestions ⇒ Object
Filter for files using fuzzy match search against all the files from the parent folder.
-
#query ⇒ Object
If the pattern use “/” it will consider “.” If the pattern uses Static files, it tries to reach the parent.
Methods inherited from SuggestionStrategy
Constructor Details
This class inherits a constructor from Codeowners::Cli::SuggestionStrategy
Instance Method Details
#pick_suggestions ⇒ Object
Filter for files using fuzzy match search against all the files from the parent folder.
66 67 68 69 70 |
# File 'lib/codeowners/cli/suggest_file_from_pattern.rb', line 66 def pick_suggestions require 'fuzzy_match' search = FuzzyMatch.new(suggest_files_for_pattern) search.find(@pattern) end |
#query ⇒ Object
If the pattern use “/” it will consider “.” If the pattern uses Static files, it tries to reach the parent. If the pattern revers to the root folder, pick all files from the current pattern dir.
76 77 78 79 80 |
# File 'lib/codeowners/cli/suggest_file_from_pattern.rb', line 76 def query parent_folders = @pattern.split('/')[0..-2] parent_folders << '*' if parent_folders[-1] != '*' File.join(*parent_folders) end |