class Peaches::Finder
Attributes
cache[RW]
Public Class Methods
Public Instance Methods
build_cache()
click to toggle source
Builds the cache excluding files that start with .
# File lib/peaches/finder.rb, line 40 def build_cache all_files = [] Find.find(@root) do |path| if FileTest.directory?(path) if File.basename(path)[0] == ?. Find.prune else next end else path.slice!("#{@root}/") all_files << path end end return all_files end
find(string)
click to toggle source
FuzzyFind files from the cache
Paarameters¶ ↑
- string
-
The string you want to use to find matching files, if left black it will bring up all the files
# File lib/peaches/finder.rb, line 20 def find(string) string = string.split(//).join(".*?") pattern = "/#{string}/i" results = self.cache.grep /#{string}/i return results end
refresh_cache()
click to toggle source
forces a refresh of the file list cache
# File lib/peaches/finder.rb, line 30 def refresh_cache @cache = build_cache end