Sha256: 0613204e7cb0b6df815a547eca5d117e0c022d362b0e1ce0d6ed903631f20ea7
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require_relative "command" require_relative "parallel_executor" module PeerCommander # Runs the listed commands with a configurable level of parallelism class CommandRunner def initialize(commands) @commands = commands @command_results = [] end def execute(parallelism: 1) start = Time.now @command_results = ParallelExecutor.new.execute(commands, parallelism) @duration = Time.now - start @command_results end def success? raise Errors::CommandNotExecutedError if command_results.empty? @command_results.all?(&:success?) end def failed? !success? end def all_commands raise Errors::CommandNotExecutedError if command_results.empty? @command_results end def successful_commands raise Errors::CommandNotExecutedError if command_results.empty? @command_results.select(&:success?) end def failed_commands raise Errors::CommandNotExecutedError if command_results.empty? @command_results.select(&:failed?) end def duration raise Errors::CommandNotExecutedError if command_results.empty? @duration end private attr_reader :commands, :command_results end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
peer_commander-0.1.0 | lib/peer_commander/command_runner.rb |