Module: Reviser::Criteria::Compilation

Includes:
Helpers::System
Defined in:
lib/reviser/criteria/compilation.rb

Overview

Needed stuff for compiled languages such as C, Java, and so on.

Author:

  • Yann Prono

  • Renan Strauss

Instance Method Summary collapse

Methods included from Helpers::System

#exec_with_timeout, #find_executable

Instance Method Details

#compileObject

Only here for compiled language,



39
40
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
# File 'lib/reviser/criteria/compilation.rb', line 39

def compile
	#
	# For now, we compile only if there's
	# no missing file
	# We should maybe make it more
	# understandable in the Cfg
	#
	if missing_files.empty?
		result = ''

		cmd = "#{Cfg[Cfg.has_key?(:preferred_build_command) && :preferred_build_command || :default_build_command]}"
		out = exec_with_timeout cmd

		if out.has_key? :process_status
			result = "Exit status: 0\r#{out[:stdout]}" unless out[:process_status].exitstatus != 0
		else
			if Cfg.has_key? :preferred_build_command
				out = exec_with_timeout Cfg[:default_build_command]
			end
		end

		result = "#{out[:stdout]}\r#{out[:stderr]}"

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