2012-08-15 22:10:54 -04:00
|
|
|
module Mutant
|
|
|
|
# Abstract reporter
|
|
|
|
class Reporter
|
2013-01-15 17:46:05 -05:00
|
|
|
include Adamantium::Flat, AbstractType, Equalizer.new(:stats)
|
2012-08-15 22:10:54 -04:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Initialize reporter
|
2012-08-15 22:10:54 -04:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @param [Config] config
|
2012-08-15 22:10:54 -04:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
def initialize(config)
|
|
|
|
@stats = Stats.new
|
|
|
|
@config = config
|
|
|
|
end
|
2012-08-15 22:10:54 -04:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Report subject
|
2012-08-15 22:10:54 -04:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @param [Subject] subject
|
2012-08-15 22:10:54 -04:00
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
def subject(subject)
|
|
|
|
stats.count_subject
|
|
|
|
self
|
|
|
|
end
|
2012-08-15 22:10:54 -04:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Report mutation
|
2012-12-07 09:59:37 -05:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @param [Mutation] mutation
|
2012-12-07 09:59:37 -05:00
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
def mutation(mutation)
|
|
|
|
self
|
|
|
|
end
|
2012-12-07 09:59:37 -05:00
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
# Report killer
|
|
|
|
#
|
|
|
|
# @param [Killer] killer
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
def report_killer(killer)
|
|
|
|
stats.count_killer(killer)
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
2012-11-21 16:28:08 -05:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Test for running in debug mode
|
2012-11-21 16:28:08 -05:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @return [true]
|
|
|
|
# if running in debug mode
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
2012-11-21 16:28:08 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
def debug?
|
|
|
|
config.debug?
|
|
|
|
end
|
2012-12-10 18:17:19 -05:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Return stats
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @return [Reporter::Stats]
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
attr_reader :stats
|
2012-12-10 18:17:19 -05:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Return config
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @return [Config]
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
attr_reader :config
|
2012-12-10 18:17:19 -05:00
|
|
|
|
2013-01-15 17:46:05 -05:00
|
|
|
# Test if errors are present
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @return [true]
|
|
|
|
# if errors are present
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
def errors?
|
|
|
|
stats.errors?
|
2012-12-10 18:17:19 -05:00
|
|
|
end
|
2013-01-15 17:46:05 -05:00
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
end
|
|
|
|
end
|