Class: Attest::PossibleTestsConfigurator

Inherits:
Object
  • Object
show all
Defined in:
lib/attest/interface/possible_tests_configurator.rb

Class Method Summary collapse

Class Method Details

.configure(included_locations, excluded_locations = nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/attest/interface/possible_tests_configurator.rb', line 4

def configure(included_locations, excluded_locations = nil)
  raise "Need to know location for tests" if included_locations.compact.size == 0
  possible_test_files = included_test_files included_locations
  files_to_ignore = excluded_test_files excluded_locations
  possible_test_files - files_to_ignore
end

.excluded_test_files(excluded_locations) ⇒ Object



15
16
17
18
# File 'lib/attest/interface/possible_tests_configurator.rb', line 15

def excluded_test_files(excluded_locations)
  return [] if excluded_locations.nil?
  file_list_from_list_of excluded_locations
end

.file_list_from_list_of(locations) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/attest/interface/possible_tests_configurator.rb', line 20

def file_list_from_list_of(locations)
  file_list = []
  locations.compact.each do |location|
    expanded_location = File.expand_path(location)
    file_list << file_list_from_single(expanded_location)
  end
  file_list.flatten
end

.file_list_from_single(location) ⇒ Object



29
30
31
32
# File 'lib/attest/interface/possible_tests_configurator.rb', line 29

def file_list_from_single(location)
  return location if File.file? location
  Dir[File.join(File.expand_path(location), "**/*.rb")].collect { |ruby_file| ruby_file }
end

.included_test_files(included_locations) ⇒ Object



11
12
13
# File 'lib/attest/interface/possible_tests_configurator.rb', line 11

def included_test_files(included_locations)
  file_list_from_list_of included_locations
end