Class: Mutant::Runner::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/runner/collector.rb

Overview

Parallel process collector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeundefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize object



13
14
15
16
17
18
19
# File 'lib/mutant/runner/collector.rb', line 13

def initialize(*)
  super
  @start                = Time.now
  @aggregate            = Hash.new { |hash, key| hash[key] = [] }
  @activity             = Hash.new(0)
  @last_mutation_result = nil
end

Instance Attribute Details

#last_mutation_resultResult::Mutation? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return last mutation result



31
32
33
# File 'lib/mutant/runner/collector.rb', line 31

def last_mutation_result
  @last_mutation_result
end

Instance Method Details

#active_subject_resultsArray<Result::Subject>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return active subject results



39
40
41
# File 'lib/mutant/runner/collector.rb', line 39

def active_subject_results
  active_subjects.map(&method(:subject_result))
end

#finish(mutation_result) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Handle mutation finish



79
80
81
82
83
84
85
86
87
88
# File 'lib/mutant/runner/collector.rb', line 79

def finish(mutation_result)
  @last_mutation_result = mutation_result

  subject = mutation_result.mutation.subject

  @activity[subject] -= 1
  @aggregate[subject] << mutation_result

  self
end

#resultResult::Env

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return current result



49
50
51
52
53
54
55
56
# File 'lib/mutant/runner/collector.rb', line 49

def result
  Result::Env.new(
    env:             env,
    runtime:         Time.now - @start,
    subject_results: subject_results,
    done:            false
  )
end

#start(mutation) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Handle mutation start



66
67
68
69
# File 'lib/mutant/runner/collector.rb', line 66

def start(mutation)
  @activity[mutation.subject] += 1
  self
end