Class: MutatorRails::MutationLog

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutator_rails/mutation_log.rb

Constant Summary collapse

HEADER =
(['log',
'kills',
'alive',
'total',
'pct killed',
'mutations per sec',
'runtime',
'failure',
'j1'].join("\t") + "\n").freeze

Instance Method Summary collapse

Constructor Details

#initializeMutationLog

Returns a new instance of MutationLog.



18
19
20
21
22
# File 'lib/mutator_rails/mutation_log.rb', line 18

def initialize(*)
  super

  @content = File.read(target_log)
end

Instance Method Details

#aliveObject



48
49
50
# File 'lib/mutator_rails/mutation_log.rb', line 48

def alive
  content.match(/Alive:.+?(\d+)$/)[1].to_i rescue 0
end

#complete?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/mutator_rails/mutation_log.rb', line 32

def complete?
  /^Subjects: / === content
end

#detailsObject



36
37
38
39
40
# File 'lib/mutator_rails/mutation_log.rb', line 36

def details
  [klass, kills, alive, total, pct, mutations_per_sec, runtime, failure, j1]
rescue
  []
end

#j1Object



52
53
54
# File 'lib/mutator_rails/mutation_log.rb', line 52

def j1
  content.match(/Jobs:.+?(\d+)$/)[1].to_i rescue 2
end


56
57
58
# File 'lib/mutator_rails/mutation_log.rb', line 56

def link
  "=HYPERLINK(\"#{relative_path}\",\"#{klass}\")"
end

#pctObject



42
43
44
45
46
# File 'lib/mutator_rails/mutation_log.rb', line 42

def pct
  return 100 unless total.positive?

  ((100.0 * kills.to_f) / total).round(3)
end

#to_sObject



24
25
26
27
28
29
30
# File 'lib/mutator_rails/mutation_log.rb', line 24

def to_s
  return '' unless complete?

  [link, kills, alive, total, pct, mutations_per_sec, runtime, failure, j1].join("\t")
rescue
  ''
end