module FileCrawler::Finder::Command::Search
Public Instance Methods
search(path, options={})
click to toggle source
# File lib/file_crawler/finder/command/search.rb, line 6 def search(path, options={}) tap { @directories = search_directories(path, options) } end
search_directories(path, options={})
click to toggle source
# File lib/file_crawler/finder/command/search.rb, line 12 def search_directories(path, options={}) result = [] cmd = "find #{path} -type d" if options[:maxdepth] && options[:maxdepth] > 0 cmd = "find #{path} -maxdepth #{options[:maxdepth]} -type d" end if options[:grep] cmd += "| grep #{options[:grep].inspect}" end exec(cmd).each_line {|item| item.chomp! valid = true if options[:exclude_invisible_file] filename = File.basename(item) valid = !filename.start_with?('.') end result << item if valid } result end