Class: TestLauncher::Search::Ag::Interface
- Inherits:
-
Object
- Object
- TestLauncher::Search::Ag::Interface
- Defined in:
- lib/test_launcher/search/ag.rb
Instance Attribute Summary collapse
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Instance Method Summary collapse
- #grep(regex, file_pattern) ⇒ Object
-
#initialize(shell) ⇒ Interface
constructor
A new instance of Interface.
- #ls_files(pattern) ⇒ Object
- #pattern_to_regex(pattern) ⇒ Object
- #root_path ⇒ Object
Constructor Details
#initialize(shell) ⇒ Interface
Returns a new instance of Interface.
10 11 12 |
# File 'lib/test_launcher/search/ag.rb', line 10 def initialize(shell) @shell = shell end |
Instance Attribute Details
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
8 9 10 |
# File 'lib/test_launcher/search/ag.rb', line 8 def shell @shell end |
Instance Method Details
#grep(regex, file_pattern) ⇒ Object
18 19 20 |
# File 'lib/test_launcher/search/ag.rb', line 18 def grep(regex, file_pattern) shell.run("ag '#{regex}' --file-search-regex '#{pattern_to_regex(file_pattern)}'") end |
#ls_files(pattern) ⇒ Object
14 15 16 |
# File 'lib/test_launcher/search/ag.rb', line 14 def ls_files(pattern) shell.run("ag -g '.*#{pattern_to_regex(pattern)}.*'") end |
#pattern_to_regex(pattern) ⇒ Object
30 31 32 |
# File 'lib/test_launcher/search/ag.rb', line 30 def pattern_to_regex(pattern) pattern.gsub("*", ".*") end |
#root_path ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/test_launcher/search/ag.rb', line 22 def root_path shell.run("git rev-parse --show-toplevel").first.tap do if $? != 0 raise NotInRepoError, "test_launcher must be used in a git repository" end end end |