Class: Contest::Driver::DriverBase
- Inherits:
-
DriverEvent
- Object
- DriverEvent
- Contest::Driver::DriverBase
- Defined in:
- lib/contest/driver/base.rb
Direct Known Subclasses
AizuOnlineJudgeDriver, CodeforcesDriver, KattisDriver, UvaOnlineJudgeDriver
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #define_options(&block) ⇒ Object
- #get_commit_message(status) ⇒ Object
- #get_commit_message_ext ⇒ Object
- #get_desc ⇒ Object
- #get_opts ⇒ Object
- #get_opts_ext ⇒ Object
- #get_problem_id(options) ⇒ Object
- #get_site_name ⇒ Object
-
#initialize ⇒ DriverBase
constructor
A new instance of DriverBase.
- #initialize_ext ⇒ Object
- #resolve_language(label) ⇒ Object
-
#submit ⇒ Object
submit a solution.
- #submit_ext(config, source_path, options) ⇒ Object
Methods inherited from DriverEvent
Constructor Details
#initialize ⇒ DriverBase
Returns a new instance of DriverBase.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/contest/driver/base.rb', line 20 def initialize # submit options @options ||= {} # site config @config ||= {} @config["file"] ||= {} @config["submit_rules"] ||= {} # call DriverEvent#initialize super initialize_ext end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
18 19 20 |
# File 'lib/contest/driver/base.rb', line 18 def config @config end |
#options ⇒ Object
Returns the value of attribute options.
18 19 20 |
# File 'lib/contest/driver/base.rb', line 18 def @options end |
Instance Method Details
#define_options(&block) ⇒ Object
69 70 71 72 |
# File 'lib/contest/driver/base.rb', line 69 def &block @blocks ||= [] @blocks.push(block) end |
#get_commit_message(status) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/contest/driver/base.rb', line 109 def status if @options[:message].nil? = @config["submit_rules"]["message"] || DEFAULT_COMMIT_MESSAGE = .gsub '${site}', get_site_name = .gsub '${problem-id}', get_problem_id() = .gsub '${status}', status = "\n#{}" unless .nil? else = @options[:message] end end |
#get_commit_message_ext ⇒ Object
105 106 107 |
# File 'lib/contest/driver/base.rb', line 105 def nil end |
#get_desc ⇒ Object
65 66 67 |
# File 'lib/contest/driver/base.rb', line 65 def get_desc '' end |
#get_opts ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/contest/driver/base.rb', line 74 def get_opts get_opts_ext() do opt( :source, "Specify submitted code (Ex: main.cpp)", :type => :string, :required => false, ) opt( :language, "Specify programming language (Ex: C++, Java or etc...)", :type => :string, :required => false, ) opt( :message, "Set git-commit message", :type => :string, :required => false, ) end Trollop:: ARGV, @blocks do |blocks| version "git-contest driver" # set driver options blocks.each do |b| instance_eval &b end end end |
#get_opts_ext ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/contest/driver/base.rb', line 36 def get_opts_ext # Example: # define_options do # opt( # :problem_id, # "Problem ID (Ex: 1000, 123, 0123, etc...)", # :type => :string, # :required => true, # ) # end raise 'TODO: Implement' end |
#get_problem_id(options) ⇒ Object
53 54 55 |
# File 'lib/contest/driver/base.rb', line 53 def get_problem_id() raise 'TODO: Implement' end |
#get_site_name ⇒ Object
49 50 51 |
# File 'lib/contest/driver/base.rb', line 49 def get_site_name raise 'TODO: Implement' end |
#initialize_ext ⇒ Object
32 33 34 |
# File 'lib/contest/driver/base.rb', line 32 def initialize_ext nil end |
#resolve_language(label) ⇒ Object
57 58 59 |
# File 'lib/contest/driver/base.rb', line 57 def resolve_language(label) raise 'TODO: Implement' end |
#submit ⇒ Object
submit a solution
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/contest/driver/base.rb', line 123 def submit @options[:source] = Utils.resolve_path( @options[:source] || @config["submit_rules"]["source"] || DEFAULT_SOURCE_PATH ) if Utils.check_file_map(@options[:source], @config["file"]["ext"]) @options[:language] ||= Utils.resolve_file_map(@options[:source], @config["file"]["ext"]) else @options[:language] ||= Utils.resolve_language(@options[:source]) end @options[:language] = resolve_language Utils.normalize_language(@options[:language]) submit_ext() end |
#submit_ext(config, source_path, options) ⇒ Object
61 62 63 |
# File 'lib/contest/driver/base.rb', line 61 def submit_ext(config, source_path, ) raise 'TODO: Implement' end |