Sha256: dd6fedfffd2cf4780e006bfda33bca680d145b65da898e18a60b0abbdeb9ae30

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

module Mutant
  class Reporter
    class CLI
      class Printer
        # Printer for runner status
        class Status < self

          delegate(:active_jobs, :payload)

          ACTIVE_JOB_HEADER = 'Active Jobs:'.freeze
          ACTIVE_JOB_FORMAT = '%d: %s'.freeze

          # Print progress for collector
          #
          # @return [undefined]
          #
          # @api private
          def run
            visit(EnvProgress, payload)
            job_status
            info('Active subjects: %d', active_subject_results.length)
            visit_collection(SubjectProgress, active_subject_results)
          end

        private

          # Print worker status
          #
          # @return [undefined]
          #
          # @api private
          def job_status
            return if active_jobs.empty?
            info(ACTIVE_JOB_HEADER)
            active_jobs.sort_by(&:index).each do |job|
              info(ACTIVE_JOB_FORMAT, job.index, job.payload.identification)
            end
          end

          # Active subject results
          #
          # @return [Array<Result::Subject>]
          #
          # @api private
          def active_subject_results
            active_subjects = active_jobs.map(&:payload).flat_map(&:subject)

            payload.subject_results.select do |subject_result|
              active_subjects.include?(subject_result.subject)
            end
          end

        end # Status
      end # Printer
    end # CLI
  end # Reporter
end # Mutant

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.8.8 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.7 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.6 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.5 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.4 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.3 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.2 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.1 lib/mutant/reporter/cli/printer/status.rb