class Superbot::Runner::CLI::RootCommand

Public Instance Methods

execute() click to toggle source
# File lib/superbot/runner/cli/root_command.rb, line 15
def execute
  open_teleport
  sorted_files.each(&method(:run_test_file))
ensure
  close_teleport
end

Private Instance Methods

close_teleport() click to toggle source
# File lib/superbot/runner/cli/root_command.rb, line 64
def close_teleport
  @teleport&.kill
end
open_teleport() click to toggle source
# File lib/superbot/runner/cli/root_command.rb, line 24
def open_teleport
  return if no_teleport?

  @teleport = Thread.new do
    Superbot::Teleport::CLI::RootCommand.new('teleport').run(teleport_options)
  rescue StandardError => e
    abort "Teleport error: #{e.message}"
  end

  sleep 0.1 until @teleport.stop?
end
run_test_file(test_file) click to toggle source
# File lib/superbot/runner/cli/root_command.rb, line 55
def run_test_file(test_file)
  file_extension = File.extname(test_file)
  puts "Running #{test_file}"
  case file_extension
  when '.side' then Superbot::Runner::Side.run(test_file)
  else puts "#{file_extension} scripts are not supported yet"
  end
end
sorted_files() click to toggle source
# File lib/superbot/runner/cli/root_command.rb, line 44
def sorted_files
  if File.directory?(path)
    Dir.glob(File.join(path, '*'))
       .map! { |f| [f.gsub(path, ''), f] }
       .sort
       .map(&:last)
  else
    [path]
  end
end
teleport_options() click to toggle source
# File lib/superbot/runner/cli/root_command.rb, line 36
def teleport_options
  {
    '--browser' => browser,
    '--region' => region,
    '--org' => organization
  }.compact.to_a.flatten
end