Class: TestLauncher::Queries::MultiPathQuery

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/test_launcher/queries.rb

Instance Attribute Summary

Attributes inherited from BaseQuery

#request

Instance Method Summary collapse

Methods inherited from BaseQuery

#initialize

Constructor Details

This class inherits a constructor from TestLauncher::Queries::BaseQuery

Instance Method Details

#commandObject



153
154
155
156
157
158
159
# File 'lib/test_launcher/queries.rb', line 153

def command
  return unless request.search_string.include?(" ")
  return if test_cases.empty?

  shell.notify("Found #{pluralize(file_count, "file")}.")
  runner.multiple_files(test_cases)
end

#filesObject



170
171
172
173
174
175
176
177
178
179
# File 'lib/test_launcher/queries.rb', line 170

def files
  if found_files.any? {|files_array| files_array.empty? }
    if !found_files.all? {|files_array| files_array.empty? }
      shell.warn("It looks like you're searching for multiple files, but we couldn't identify them all.")
    end
    []
  else
    found_files.flatten.uniq
  end
end

#found_filesObject



181
182
183
184
185
# File 'lib/test_launcher/queries.rb', line 181

def found_files
  @found_files ||= queries.map {|query|
    searcher.test_files(query)
  }
end

#queriesObject



187
188
189
# File 'lib/test_launcher/queries.rb', line 187

def queries
  @queries ||= request.search_string.split(" ")
end

#test_casesObject



161
162
163
164
165
166
167
168
# File 'lib/test_launcher/queries.rb', line 161

def test_cases
  @test_cases ||= files.map { |file_path|
    request.test_case(
      file: file_path,
      request: request,
    )
  }
end