Class: Contestify::Local::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/contestify/judges/local/configuration.rb

Overview

Local::Configuration holds all the logic to configure a contest from a local directory. This class must implement the ‘self.configure!` method.

Class Method Summary collapse

Class Method Details

.configure!(base_folder) ⇒ Object

Contestify::Configuration.configure! is *the only* method you should call from the contest interface. All the other methods should be called from here. This is the only method needed for future strategies for other judges.

This should be called in a directory structure such that you have a ‘base_folder` with one folder for each problem you want to upload to the server. Each of these problems folders should have all the input/output files you want to use as test cases.

This method must return the absolute paths of the problem folders in an array. This return value will be used in Contestify::Uploader.upload!

Parameters

base_folder<String>

The base folder where all the problems folders are stored.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/contestify/judges/local/configuration.rb', line 25

def self.configure!(base_folder)
  puts green "=> Configuring problems (#{base_folder})"
  problem_index = 0
  Dir.glob("*").select { |f| File.directory?(f) }.map do |dir|
    Dir.chdir File.join(base_folder, dir)
    dirid = Dir.pwd.split('/').last[0...8]
    puts green "==> #{dirid.upcase}"
    rename_data_files
    convert_to_unix_format
    add_problem_config(dirid, problem_index)
    problem_index += 1
    puts green "==> All the work for #{dirid.upcase} is done"
    # Return the absolute path for this problem
    Dir.pwd
  end
end