class Utils::Grepper

def match(filename)

def match(filename)
  @filename = filename
  bn = File.basename(filename)
  @output = []
  s = File.stat(filename)
  if s.directory? && bn =~ PRUNE
    $DEBUG and warn "Pruning '#{filename}'."
    Utils::Find.prune
  end
  if s.file? && bn !~ SKIP && (!@name_pattern || @name_pattern.match(bn))
    File.open(filename, 'rb') do |file|
      if file.binary? != true
        $DEBUG and warn "Matching '#{filename}'."
        match_lines file
      else
        $DEBUG and warn "Skipping binary file '#{filename}'."
      end
    end
  else
    $DEBUG and warn "Skipping '#{filename}'."
  end
  unless @output.empty?
    case
    when @args['l'], @args['e']
      @output.uniq!
      @pathes.concat @output
    else
      STDOUT.puts @output
    end
    @output.clear
  end
  self
rescue SystemCallError => e
  warn "Caught #{e.class}: #{e}"
  nil
end