free_mutant/lib/mutant/reporter.rb

102 lines
1.5 KiB
Ruby
Raw Normal View History

module Mutant
# Abstract reporter
class Reporter
2013-01-15 17:46:05 -05:00
include Adamantium::Flat, AbstractType, Equalizer.new(:stats)
2013-01-15 17:46:05 -05:00
# Initialize reporter
#
2013-01-15 17:46:05 -05:00
# @param [Config] config
#
# @api private
#
2013-01-15 17:46:05 -05:00
def initialize(config)
@stats = Stats.new
@config = config
end
2013-01-15 17:46:05 -05:00
# Report subject
#
2013-01-15 17:46:05 -05:00
# @param [Subject] subject
#
# @return [self]
#
# @api private
#
2013-01-15 17:46:05 -05:00
def subject(subject)
stats.count_subject
self
end
2013-01-15 17:46:05 -05:00
# Report mutation
#
2013-01-15 17:46:05 -05:00
# @param [Mutation] mutation
#
# @return [self]
#
# @api private
#
2013-01-15 17:46:05 -05:00
def mutation(mutation)
self
end
# 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
2013-01-15 17:46:05 -05:00
# Test for running in debug mode
#
2013-01-15 17:46:05 -05:00
# @return [true]
# if running in debug mode
#
# @return [false]
# otherwise
#
# @api private
#
2013-01-15 17:46:05 -05:00
def debug?
config.debug?
end
2013-01-15 17:46:05 -05:00
# Return stats
#
2013-01-15 17:46:05 -05:00
# @return [Reporter::Stats]
#
# @api private
#
2013-01-15 17:46:05 -05:00
attr_reader :stats
2013-01-15 17:46:05 -05:00
# Return config
#
2013-01-15 17:46:05 -05:00
# @return [Config]
#
# @api private
#
2013-01-15 17:46:05 -05:00
attr_reader :config
2013-01-15 17:46:05 -05:00
# Test if errors are present
#
2013-01-15 17:46:05 -05:00
# @return [true]
# if errors are present
#
# @return [false]
# otherwise
#
# @api private
#
2013-01-15 17:46:05 -05:00
def errors?
stats.errors?
end
2013-01-15 17:46:05 -05:00
end
end