Sha256: 030fd5eaa2882aa39645e5d640d93f20bb8c575d1063bf98485761d4b1509b73

Contents?: true

Size: 1006 Bytes

Versions: 2

Compression:

Stored size: 1006 Bytes

Contents

require 'polytrix'
require 'rbconfig'

module Polytrix
  module Runners
    autoload :LinuxChallengeRunner, 'polytrix/runners/linux_challenge_runner'
    autoload :WindowsChallengeRunner, 'polytrix/runners/windows_challenge_runner'
  end

  class ChallengeRunner < Thor::Shell::Color
    include Polytrix::Core::FileSystemHelper
    include Polytrix::Runners::Executor

    attr_accessor :env

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

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

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

    private

    def middleware
      Polytrix.configuration.middleware
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polytrix-0.1.2 lib/polytrix/challenge_runner.rb
polytrix-0.1.1 lib/polytrix/challenge_runner.rb