Class: Fif

Inherits:
Object
  • Object
show all
Defined in:
lib/fif.rb,
lib/fif/search.rb,
lib/fif/version.rb,
lib/fif/dumb_search.rb

Defined Under Namespace

Classes: DumbSearch, Search

Constant Summary collapse

VERSION =
'0.5.1'

Class Method Summary collapse

Class Method Details

.search(arguments, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fif.rb', line 8

def self.search(arguments, options)
  klass = options[:dumb] ? DumbSearch : Search
  s = klass.new(arguments, options)

  Dir.recurse(options[:folder]) do |file|
    if s.file_match(file) && !File.binary?(file)
      f = File.new(file)
      f.each do |line|
        begin
          if s.line_match(line)
            yield "#{file}:#{f.lineno}:\t#{s.line_format(line)}"
          end
        rescue ArgumentError
          puts "Ignoring unreadable file: #{file}"
        end
      end
    end
  end

end