Show More
Commit Description:
add option -A <opt> to box. This options allow more argument to be explicitly passed to the program...
Commit Description:
add option -A <opt> to box. This options allow more argument to be explicitly passed to the program
We have to use this because if the argument we wish to pass to the program is option (in -? format),
box will intepret it as its option and failed accordingly.
be noted that, by the definition of getopt, these options will be put after original argument
(check the code for more info)
References:
File last commit:
Show/Diff file:
Action:
lib/configuration.rb
| 84 lines
| 2.4 KiB
| text/x-ruby
| RubyLexer
|
|
r22 | module Grader | ||
|
r23 | # This singleton class holds basic configurations for grader. When | ||
# running in each mode, grader uses resources from different | ||||
# directories and outputs differently. Usually the attributes name | ||||
# are descriptive; below we explain more on each attributes. | ||||
|
r22 | class Configuration | ||
|
r23 | # Rails' environment: "development", "production" | ||
attr_accessor :rails_env | ||||
|
r22 | |||
|
r23 | # Grader looks for problem [prob] in problem_dir/[prob], and store | ||
# execution results for submission [x] of user [u] in directory | ||||
# user_result_dir/[u]/[x] | ||||
|
r22 | attr_accessor :problems_dir | ||
attr_accessor :user_result_dir | ||||
|
r23 | |||
# If report_grader=true, the grader would add a row in model | ||||
# GraderProcess. It would report itself with grader_hostname and | ||||
# process id. | ||||
|
r22 | attr_accessor :report_grader | ||
attr_accessor :grader_hostname | ||||
|
r23 | |||
# If talkative=true, grader would report status to console. If | ||||
# logging=true, grader would report status to a log file located | ||||
# in log_dir, in a file name mode.options.pid. TODO: defined | ||||
# log file naming. | ||||
attr_accessor :talkative | ||||
attr_accessor :logging | ||||
attr_accessor :log_dir | ||||
# These are directories related to the test interface. | ||||
attr_accessor :test_request_input_base_dir | ||||
attr_accessor :test_request_output_base_dir | ||||
attr_accessor :test_request_problem_templates_dir | ||||
# Comment received from the grading script will be filtered | ||||
# through Configuration#report_comment. How this method behave | ||||
# depends on this option; right now only two formats, :short and | ||||
# :long | ||||
attr_accessor :comment_report_style | ||||
def report_comment(comment) | ||||
case comment_report_style | ||||
when :short | ||||
|
r37 | if comment.chomp =~ /^[\[\]P]+$/ # all P's | ||
|
r23 | 'passed' | ||
|
r37 | elsif comment.chomp =~ /[Cc]ompil.*[Ee]rror/ | ||
'compilation error' | ||||
|
r23 | else | ||
'failed' | ||||
end | ||||
when :full | ||||
comment.chomp | ||||
end | ||||
end | ||||
# Codes for singleton | ||||
private_class_method :new | ||||
|
r22 | |||
@@instance = nil | ||||
def self.get_instance | ||||
if @@instance==nil | ||||
@@instance = new | ||||
end | ||||
@@instance | ||||
end | ||||
private | ||||
def initialize | ||||
@talkative = false | ||||
|
r23 | @log_file = nil | ||
|
r22 | @report_grader = false | ||
@grader_hostname = `hostname`.chomp | ||||
@rails_env = 'development' | ||||
|
r23 | @comment_report_style = :full | ||
|
r22 | end | ||
end | ||||
end | ||||