class Codeowners::Cli::FilesFromParentFolder
Pick all files from parent folder of pattern. Apply fuzzy match search on all files to pick the best option.
Public Instance Methods
pick_suggestions()
click to toggle source
Filter
for files using fuzzy match search against all the files from the parent folder.
# 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()
click to toggle source
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.
# 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
Private Instance Methods
normalize_path(file)
click to toggle source
# File lib/codeowners/cli/suggest_file_from_pattern.rb, line 89 def normalize_path(file) Pathname.new(file) .relative_path_from(Pathname.new('.')).to_s end
suggest_files_for_pattern()
click to toggle source
# File lib/codeowners/cli/suggest_file_from_pattern.rb, line 84 def suggest_files_for_pattern files = Dir[query] || [] files.map(&method(:normalize_path)) end