Class: TestLauncher::Searchers::Git
- Inherits:
-
Object
- Object
- TestLauncher::Searchers::Git
- Defined in:
- lib/test_launcher/search/git.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_files(pattern) ⇒ Object
- #grep(regex, file_pattern: '*') ⇒ Object
-
#initialize(shell) ⇒ Git
constructor
A new instance of Git.
Constructor Details
#initialize(shell) ⇒ Git
Returns a new instance of Git.
9 10 11 12 |
# File 'lib/test_launcher/search/git.rb', line 9 def initialize(shell) @shell = shell Dir.chdir(root_path) end |
Class Method Details
.valid? ⇒ Boolean
5 6 7 |
# File 'lib/test_launcher/search/git.rb', line 5 def self.valid? end |
Instance Method Details
#find_files(pattern) ⇒ Object
14 15 16 |
# File 'lib/test_launcher/search/git.rb', line 14 def find_files(pattern) shell.run("git ls-files '*#{pattern}*'").map {|f| system_path(f)} end |
#grep(regex, file_pattern: '*') ⇒ Object
18 19 20 21 22 23 |
# File 'lib/test_launcher/search/git.rb', line 18 def grep(regex, file_pattern: '*') results = shell.run("git grep --untracked --extended-regexp '#{regex}' -- '#{file_pattern}'") results.map do |result| interpret_grep_result(result) end end |