lib/keypair.rb
# try filename with suffix and without suffixes.
# Checks all paths without suffix first, then try all paths for all suffixes.
try filename with suffix and without suffixes.
Checks all paths without suffix first, then try all paths for all suffixes.
try filename with suffix and without suffixes . Checks all paths without suffix first then try all paths for all suffixes .
def find_file_in_path_with_suffix(file, extra_paths, suffixes=[],
                                    try_wo_suffix=true)
    suffixes_to_try = suffixes.dup
    suffixes_to_try.push '' if try_wo_suffix
    suffixes_to_try.map {|s| file + s }.each do |suffixed|
      fullpath = if File.file?(File.expand_path(suffixed))
                   ::File.expand_path(suffixed)
                 else
                   search_in_known_locations(suffixed, extra_paths)
                 end
      return fullpath if fullpath
    end
    nil
  end
def find_file_in_path_with_suffix ( file , extra_paths , suffixes = [ ] , try_wo_suffix = true ) suffixes_to_try = suffixes . dup suffixes_to_try . push '' if try_wo_suffix suffixes_to_try . map { | s | file + s } . each do | suffixed | fullpath = if File . file? ( File . expand_path ( suffixed ) ) :: File . expand_path ( suffixed ) else search_in_known_locations ( suffixed , extra_paths ) end return fullpath if fullpath end nil end
try filename with suffix and without suffixes.
try filename with suffix and without suffixes .
file
extra_paths
suffixes
try_wo_suffix