free_mutant/lib/mutant/reporter.rb

137 lines
1.9 KiB
Ruby
Raw Normal View History

module Mutant
# Abstract reporter
class Reporter
2013-01-15 23:46:05 +01:00
include Adamantium::Flat, AbstractType, Equalizer.new(:stats)
2013-01-15 23:46:05 +01:00
# Initialize reporter
#
2013-01-15 23:46:05 +01:00
# @param [Config] config
#
# @api private
#
2013-01-15 23:46:05 +01:00
def initialize(config)
@stats = Stats.new
@config = config
end
2013-01-21 23:53:25 +01:00
# Test for success
#
# @return [true]
# if there are subjects and no errors
#
# @return [false]
# otherwise
#
# @api private
#
def success?
stats.success?
end
# Report start
#
# @param [Config] config
#
# @return [self]
#
# @api private
#
def start(_config)
self
end
# Report stop
#
# @return [self]
#
# @api private
#
def stop
self
end
2013-01-15 23:46:05 +01:00
# Report subject
#
2013-01-15 23:46:05 +01:00
# @param [Subject] subject
#
# @return [self]
#
# @api private
#
def subject(_subject)
2013-01-15 23:46:05 +01:00
stats.count_subject
self
end
2013-01-15 23:46:05 +01:00
# Report mutation
#
2013-01-15 23:46:05 +01:00
# @param [Mutation] mutation
#
# @return [self]
#
# @api private
#
def mutation(_mutation)
2013-01-15 23:46:05 +01:00
self
end
# Report killer
#
# @param [Killer] killer
#
# @return [self]
#
# @api private
#
2013-01-15 23:46:05 +01:00
def report_killer(killer)
stats.count_killer(killer)
self
end
2013-01-15 23:46:05 +01:00
# Test for running in debug mode
#
2013-01-15 23:46:05 +01:00
# @return [true]
# if running in debug mode
#
# @return [false]
# otherwise
#
# @api private
#
2013-01-15 23:46:05 +01:00
def debug?
config.debug?
end
2013-01-15 23:46:05 +01:00
# Return stats
#
2013-01-15 23:46:05 +01:00
# @return [Reporter::Stats]
#
# @api private
#
2013-01-15 23:46:05 +01:00
attr_reader :stats
2013-01-15 23:46:05 +01:00
# Return config
#
2013-01-15 23:46:05 +01:00
# @return [Config]
#
# @api private
#
2013-01-15 23:46:05 +01:00
attr_reader :config
2013-01-15 23:46:05 +01:00
# Test if errors are present
#
2013-01-15 23:46:05 +01:00
# @return [true]
# if errors are present
#
# @return [false]
# otherwise
#
# @api private
#
2013-01-15 23:46:05 +01:00
def errors?
stats.errors?
end
2013-01-15 23:46:05 +01:00
end
end