class OJS::CLI
Constants
- CONFIG_PATH
- SAMPLE_CONFIG_PATH
Public Class Methods
new(*)
click to toggle source
Calls superclass method
# File lib/ojsubmitter/cli.rb, line 11 def initialize(*) super end
Public Instance Methods
init()
click to toggle source
# File lib/ojsubmitter/cli.rb, line 57 def init unless File.exist?(CONFIG_PATH) FileUtils.copy(SAMPLE_CONFIG_PATH, CONFIG_PATH) end end
list()
click to toggle source
# File lib/ojsubmitter/cli.rb, line 64 def list Logger.info "Available judges are below." Judge.valid_judges.each { |judge| Logger.info judge } end
submit()
click to toggle source
# File lib/ojsubmitter/cli.rb, line 46 def submit @config = set_options_from_config_file(options.to_h) judge_class.submit @config rescue UnknownJudgeError => err list end
version()
click to toggle source
# File lib/ojsubmitter/cli.rb, line 16 def version puts OJS::VERSION end
Private Instance Methods
judge_class()
click to toggle source
# File lib/ojsubmitter/cli.rb, line 78 def judge_class case @config['judge'].to_s.downcase when 'aoj', 'poj', 'spoj' OJS.const_get @config['judge'].upcase when 'codeforces', 'cf' OJS::Codeforces when 'atcoder' OJS::AtCoder else raise UnknownJudgeError end end
set_options_from_config_file(config)
click to toggle source
# File lib/ojsubmitter/cli.rb, line 70 def set_options_from_config_file(config) config_file = YAML.load_file(CONFIG_PATH) config_file.each do |key,val| config[key] ||= val end config end