free_mutant/lib/mutant/runner.rb

101 lines
1.5 KiB
Ruby
Raw Normal View History

2012-08-14 16:45:34 -04:00
module Mutant
2013-04-20 14:50:36 -04:00
# Runner baseclass
2012-08-14 16:45:34 -04:00
class Runner
2013-04-20 14:50:36 -04:00
include Adamantium::Flat, AbstractType, Equalizer.new(:config)
extend MethodObject
2012-08-14 16:45:34 -04:00
# Return config
#
# @return [Mutant::Config]
#
# @api private
#
attr_reader :config
# Initialize object
2012-08-16 13:26:15 -04:00
#
2012-11-21 14:49:23 -05:00
# @param [Config] config
2012-08-16 13:26:15 -04:00
#
# @return [undefined]
#
# @api private
#
2012-11-21 14:49:23 -05:00
def initialize(config)
2013-01-15 17:46:05 -05:00
@config = config
@start = Time.now
2012-08-14 16:45:34 -04:00
run
@end = Time.now
2013-01-15 17:46:05 -05:00
end
# Return runtime
#
# @return [Float]
#
# @api private
#
def runtime
2013-06-14 14:54:02 -04:00
@end - @start
end
memoize :runtime
2013-03-27 10:52:02 -04: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 23:31:21 -04:00
#
2013-03-27 10:52:02 -04:00
abstract_method :success?
2013-04-20 14:50:36 -04:00
# Return reporter
#
# @return [Reporter]
#
# @api private
#
def reporter
config.reporter
end
private
2012-08-14 16:45:34 -04:00
# Perform operation
2012-08-16 13:26:15 -04:00
#
# @return [undefined]
#
# @api private
#
abstract_method :run
2012-08-14 16:45:34 -04:00
2013-04-20 14:50:36 -04:00
# Return reporter
#
# @param [Object] object
#
# @return [undefined]
#
# @api private
#
def report(object)
reporter.report(object)
end
2013-06-14 14:54:02 -04:00
end # Runner
end # Mutant