Module: Reviser::Criteria::Execution

Defined in:
lib/reviser/criteria/execution.rb

Overview

Needed stuff for Checker when it comes to executing both compiled and interpreted languages

Author:

  • Renan Strauss

Instance Method Summary collapse

Instance Method Details

#executeObject

Determines how to execute the program thanks to Cfg, then returns its exec status(es)



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/reviser/criteria/execution.rb', line 41

def execute
	outputs = []
	if  Cfg.has_key? :execution_value
		if Cfg[:execution_value].respond_to? 'each'
			Cfg[:execution_value].each do |v|
				outputs << make_exec(v)
			end
		else
			if Cfg.has_key? :execution_count
				outputs[Cfg[:execution_value]] = []
				Cfg[:execution_count].times do
					outputs << make_exec(Cfg[:execution_value])
				end
			else
				outputs << make_exec(Cfg[:execution_value])
			end
		end
	else
			Cfg[:execution_count].times do
				outputs << make_exec
			end
	end

	result = outputs.join("\r")
	manufacture do |format|
		format.html { '<div class="console">' + CGI.escapeHTML(result) + '</div>' }
		format.csv { result }
		format.xls { result }
	end
end