class TestBoosters::Boosters::Base

Public Class Methods

new(file_pattern, split_configuration_path, command) click to toggle source
# File lib/test_boosters/boosters/base.rb, line 5
def initialize(file_pattern, split_configuration_path, command)
  @command = command
  @file_pattern = file_pattern
  @split_configuration_path = split_configuration_path
end

Public Instance Methods

after_job() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 48
def after_job
  # Do nothing
end
before_job() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 44
def before_job
  # Do nothing
end
display_header() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 52
def display_header
  version = "Test Booster v#{TestBoosters::VERSION}"
  job_info = "Job #{job_index + 1} out of #{job_count}"

  TestBoosters::Shell.display_title("#{version} - #{job_info}")
end
distribution() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 59
def distribution
  @distribution ||= TestBoosters::Files::Distributor.new(@split_configuration_path,
                                                         @file_pattern,
                                                         job_count)
end
job_count() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 69
def job_count
  @job_count ||= cli_options[:job_count]
end
job_index() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 65
def job_index
  @job_index ||= cli_options[:job_index] - 1
end
run() click to toggle source

:reek: TooManyStatements

# File lib/test_boosters/boosters/base.rb, line 12
def run
  display_header

  before_job # execute some activities when the before the job starts

  distribution.display_info

  known, leftover = distribution.files_for(job_index)

  if cli_options[:dry_run]
    show_files_for_dry_run("known", known)
    show_files_for_dry_run("leftover", leftover)
    return 0
  end

  exit_status = TestBoosters::Job.run(@command, known, leftover)

  after_job # execute some activities when the job finishes

  exit_status
end
show_files_for_dry_run(label, files) click to toggle source
# File lib/test_boosters/boosters/base.rb, line 34
def show_files_for_dry_run(label, files)
  if files.empty?
    puts "[DRY RUN] No #{label} files."
    return
  end

  puts "\n[DRY RUN] Running tests for #{label} files:"
  puts files.map { |file| "- #{file}" }.join("\n")
end

Private Instance Methods

cli_options() click to toggle source
# File lib/test_boosters/boosters/base.rb, line 75
def cli_options
  @cli_options ||= TestBoosters::CliParser.parse
end