Class: Most::Submission
Instance Method Summary
collapse
#create_test_case
#create_options
#path
#method_missing
Constructor Details
#initialize(name = 'Anonymous Submission', tests = [], options = Options.new(), entities = {}, &block) ⇒ Submission
Returns a new instance of Submission.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/most/structures/submission.rb', line 42
def initialize(name = 'Anonymous Submission',
tests = [],
options = Options.new(),
entities = {}, &block)
@name = name
@tests = tests
@entities = entities
options(options)
instance_eval(&block) if block_given?
parameters = SERVICES[:environment].options[:submission_parameters]
unless parameters.nil? or @options.nil?
@options[:submission_parameters] = parameters
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class MetaProgrammable
Instance Method Details
#add_test(test, &block) ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/most/structures/submission.rb', line 82
def add_test(test, &block)
@tests ||= []
if test.is_a?(Class) and block_given?
@tests << test.new(&block)
else
@tests << test
end
end
|
#options(*args) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/most/structures/submission.rb', line 60
def options(*args)
result = nil
if args.empty?
@options ||= Options.new()
result = @options
else
options = args.size == 1 ? args.first : args
unless options.is_a?(Options)
options = options.try(:to_options)
if options.nil?
options = Options.new()
end
end
result = @options = options
end
result
end
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/most/structures/submission.rb', line 91
def run()
SERVICES[:environment].show_message("Working...")
SERVICES[:environment].state("Processing submission #{@name}")
SERVICES[:environment].state("Number of test cases: #{@tests.size}")
result = Report.new("Submission: #{@name}")
if @options[:tests/:report/:specs]
result.specs = {:name => @name,
:tests => @tests}
end
@tests.each do |test|
result << test.run(@options, @entities)
unless result.last.last.last[:success]
break if @options[:tests/:break/:unsuccessful]
end
unless result.last.last.last[:correct]
break if @options[:tests/:break/:incorrect]
end
end
SERVICES[:environment].state("|--> Finished.")
result.to_yaml()
end
|