Sha256: 1986ffad1b01867b42278d330884dfe2c738ff0a04f666c8f694f87d988e687a
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'atcoder_greedy' require 'atcoder_greedy/command' require 'atcoder_greedy/lib/atcoder' def get_language_id(extname) case extname when '.rb' 2010 when '.cpp' 2003 when '.c' 2001 else raise "Unknown extname: #{extname}" end end module AtcoderGreedy class Command < Thor desc 'submit [SUBMIT_FILE]', 'submit your solution' # TODO: 提出言語のオプション def submit(submit_file) print "Submit [#{submit_file}] ... " contest_info = YAML.load_file("./.contest_info.yml") problem = File.basename(submit_file, '.*') if contest_info[:task].include?(:"#{problem}") task_id = contest_info[:task][:"#{problem}"][:id] else raise "Unknown problem: #{problem}" end atcoder = Atcoder.new atcoder.login(contest_info[:url]) submit_url = contest_info[:url] + "/submit?task_id=#{task_id}" atcoder.agent.get(submit_url) do |page| p = page.form_with(action: "/submit?task_id=#{task_id}") do |f| f.field_with(name: 'source_code').value = File.open(submit_file).read f.field_with(name: 'task_id').value = task_id f.field_with(name: "language_id_#{task_id}").value = get_language_id(File.extname(submit_file)) end.submit puts 'Done!' Launchy.open p.uri end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
atcoder_greedy-0.5.0 | lib/atcoder_greedy/command/submit.rb |