Module: Contest::Driver::Utils

Defined in:
lib/contest/driver/common.rb

Class Method Summary collapse

Class Method Details

.normalize_language(label) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/contest/driver/common.rb', line 30

def self.normalize_language label
  case label
  when "c", "C"
    return "clang"
  when "cpp", "C++", "c++"
    return "cpp"
  when "c++11", "C++11"
    return "cpp11"
  when "cs", "c#", "C#"
    return "cs"
  when "d", "D", "dlang"
    return "dlang"
  when "go", "golang"
    return "golang"
  when "hs", "haskell", "Haskell"
    return "haskell"
  when "java", "Java"
    return "java"
  when "ocaml", "ml", "OCaml"
    return "ocaml"
  when "Delphi", "delphi"
    return "delphi"
  when "pascal", "Pascal"
    return "pascal"
  when "perl", "Perl", "pl"
    return "perl"
  when "php", "PHP"
    return "php"
  when "python2"
    return "python2"
  when "python3", "python", "Python", "py"
    return "python3"
  when "ruby", "rb", "Ruby"
    return "ruby"
  when "scala", "Scala"
    return "scala"
  else
    abort "unknown language @ normalize language"
  end
end

.resolve_language(path) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/contest/driver/common.rb', line 21

def self.resolve_language path
  regexp = /\.([a-z0-9]+)$/
  if path.match(regexp)
    return path.match(regexp)[1]
  else
    return nil
  end
end

.resolve_path(path) ⇒ Object



16
17
18
19
# File 'lib/contest/driver/common.rb', line 16

def self.resolve_path path
  path = `ls #{path} | cat | head -n 1`
  path.strip
end