Class: Polytrix::ChallengeRunner

Inherits:
Thor::Shell::Color
  • Object
show all
Includes:
Polytrix::Core::FileSystemHelper, Runners::Executor
Defined in:
lib/polytrix/challenge_runner.rb

Instance Attribute Summary collapse

Attributes included from Runners::Executor

#executor

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Runners::Executor

#execute

Methods included from Polytrix::Core::FileSystemHelper

#find_file, #recursive_parent_search

Methods included from StringHelpers

included

Methods included from StringHelpers::ClassMethods

#slugify

Instance Attribute Details

#envObject

Returns the value of attribute env.



14
15
16
# File 'lib/polytrix/challenge_runner.rb', line 14

def env
  @env
end

Class Method Details

.create_runnerObject



16
17
18
19
20
21
22
23
# File 'lib/polytrix/challenge_runner.rb', line 16

def self.create_runner
  case RbConfig::CONFIG['host_os']
  when /mswin(\d+)|mingw/i
    Runners::WindowsChallengeRunner.new
  else
    Runners::LinuxChallengeRunner.new
  end
end

Instance Method Details

#run_challenge(challenge) ⇒ Object



34
35
36
37
# File 'lib/polytrix/challenge_runner.rb', line 34

def run_challenge(challenge)
  middleware.call(challenge)
  challenge.result
end

#run_command(command) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/polytrix/challenge_runner.rb', line 25

def run_command(command)
  if Polytrix.configuration.dry_run
    puts "Would have run #{command}"
  else
    say_status 'polytrix:execute', command
    execute command
  end
end