free_mutant/lib/mutant/runner.rb

101 lines
1.4 KiB
Ruby
Raw Normal View History

2012-08-14 22:45:34 +02:00
module Mutant
2013-04-20 20:50:36 +02:00
# Runner baseclass
2012-08-14 22:45:34 +02:00
class Runner
2013-04-20 20:50:36 +02:00
include Adamantium::Flat, AbstractType, Equalizer.new(:config)
extend MethodObject
2012-08-14 22:45:34 +02:00
# Return config
#
# @return [Mutant::Config]
#
# @api private
#
attr_reader :config
# Initialize object
2012-08-16 19:26:15 +02:00
#
2012-11-21 20:49:23 +01:00
# @param [Config] config
2012-08-16 19:26:15 +02:00
#
# @return [undefined]
#
# @api private
#
2012-11-21 20:49:23 +01:00
def initialize(config)
2013-01-15 23:46:05 +01:00
@config = config
@start = Time.now
2012-08-14 22:45:34 +02:00
run
@end = Time.now
2013-01-15 23:46:05 +01:00
end
# Return runtime
#
# @return [Float]
#
# @api private
#
def runtime
@end - @start
end
memoize :runtime
2013-03-27 15:52:02 +01:00
# Test if runner failed
#
# @return [true]
# if failed
#
# @return [false]
# otherwise
#
# @api private
#
def failed?
!success?
end
# Test if runner is successful
#
# @return [true]
# if successful
#
# @return [false]
# otherwise
#
# @api private
2013-04-17 20:31:21 -07:00
#
2013-03-27 15:52:02 +01:00
abstract_method :success?
2013-04-20 20:50:36 +02:00
# Return reporter
#
# @return [Reporter]
#
# @api private
#
def reporter
config.reporter
end
private
2012-08-14 22:45:34 +02:00
# Perform operation
2012-08-16 19:26:15 +02:00
#
# @return [undefined]
#
# @api private
#
abstract_method :run
2012-08-14 22:45:34 +02:00
2013-04-20 20:50:36 +02:00
# Return reporter
#
# @param [Object] object
#
# @return [undefined]
#
# @api private
#
def report(object)
reporter.report(object)
end
end
end