Class: TestRun::Searchers::GitSearcher

Inherits:
Struct
  • Object
show all
Defined in:
lib/test_run/searchers/git_searcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#shellObject

Returns the value of attribute shell

Returns:

  • (Object)

    the current value of shell



3
4
5
# File 'lib/test_run/searchers/git_searcher.rb', line 3

def shell
  @shell
end

Instance Method Details

#find_files(pattern) ⇒ Object



5
6
7
# File 'lib/test_run/searchers/git_searcher.rb', line 5

def find_files(pattern)
  shell.run("git ls-files '*#{pattern}*'")
end

#grep(regex, file_pattern: '*') ⇒ Object



9
10
11
12
13
14
# File 'lib/test_run/searchers/git_searcher.rb', line 9

def grep(regex, file_pattern: '*')
  results = shell.run("git grep --untracked '#{regex}' -- '#{file_pattern}'")
  results.map do |result|
    interpret_grep_result(result)
  end
end