Sha256: 3b517916ae3e89d191ab960b0ee5559d09998423579b91619c26078c96f3aaf2

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

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]
          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]
          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>]
          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

7 entries across 7 versions & 1 rubygems

Version Path
mutant-0.8.23 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.22 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.21 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.20 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.19 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.18 lib/mutant/reporter/cli/printer/status.rb
mutant-0.8.17 lib/mutant/reporter/cli/printer/status.rb