Class: Polytrix::ChallengeRunner
- Inherits:
-
Thor::Shell::Color
- Object
- Thor::Shell::Color
- Polytrix::ChallengeRunner
show all
- Includes:
- Executor, Util::FileSystem
- Defined in:
- lib/polytrix/challenge_runner.rb
Instance Attribute Summary
Attributes included from Executor
#env, #executor
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Executor
#execute
#find_file, #relativize
included
#ansi2html, #escape_html, #highlight, #slugify
Instance Method Details
#run_challenge(challenge, spies = Polytrix::Spies) ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/polytrix/challenge_runner.rb', line 33
def run_challenge(challenge, spies = Polytrix::Spies)
source_file = challenge[:source_file].to_s
basedir = challenge[:basedir].to_s
command = challenge_command(source_file, basedir)
spies.observe(challenge) do
execution_result = run_command(command, cwd: basedir, env: environment_variables(challenge[:vars]))
challenge[:result] = Result.new(execution_result: execution_result, source_file: source_file)
end
challenge[:result]
end
|
#run_command(command, opts = { cwd: Dir.pwd }) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/polytrix/challenge_runner.rb', line 24
def run_command(command, opts = { cwd: Dir.pwd })
if Polytrix.configuration.dry_run
puts "Would have run #{command} with #{opts.inspect}"
else
say_status 'polytrix:execute', command
execute(command, opts)
end
end
|