Class: TestLauncher::Search::Ag

Inherits:
Object
  • Object
show all
Defined in:
lib/test_launcher/search/ag.rb

Defined Under Namespace

Classes: Interface

Constant Summary collapse

NotInRepoError =
Class.new(BaseError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell, interface = Interface.new(shell)) ⇒ Ag

Returns a new instance of Ag.



37
38
39
40
# File 'lib/test_launcher/search/ag.rb', line 37

def initialize(shell, interface=Interface.new(shell))
  @interface = interface
  Dir.chdir(root_path) # MOVE ME!
end

Instance Attribute Details

#interfaceObject (readonly)

Returns the value of attribute interface.



35
36
37
# File 'lib/test_launcher/search/ag.rb', line 35

def interface
  @interface
end

Instance Method Details

#find_files(pattern) ⇒ Object



42
43
44
45
# File 'lib/test_launcher/search/ag.rb', line 42

def find_files(pattern)
  relative_pattern = strip_system_path(pattern)
  interface.ls_files(relative_pattern).map {|f| system_path(f)}
end

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



47
48
49
50
51
52
# File 'lib/test_launcher/search/ag.rb', line 47

def grep(regex, file_pattern: '*')
  results = interface.grep(regex, strip_system_path(file_pattern))
  results.map do |result|
    interpret_grep_result(result)
  end
end