class GrepInteractors::GrepInPaths

Public Instance Methods

call(query, file_paths) click to toggle source
# File lib/grep_interactors/grep_in_paths.rb, line 5
def call(query, file_paths)
  file_paths.reduce([]) do |accum, file_path|
    lines = File.open(file_path).readlines

    accum + lines.each_with_index.map do |line, index|
      ("#{file_path}:#{index + 1}") if string_matcher.match?(line, query)
    end.compact
  end.flatten
end