2014-05-12 13:48:15 +00:00
|
|
|
module Mutant
|
|
|
|
class Reporter
|
|
|
|
# Reporter to trace report calls, used as a spec adapter
|
|
|
|
class Trace
|
2014-08-10 22:09:29 +00:00
|
|
|
include Adamantium::Mutable, Anima.new(:start_calls, :progress_calls, :report_calls, :warn_calls)
|
2014-05-12 13:48:15 +00:00
|
|
|
|
|
|
|
# Return new trace reporter
|
|
|
|
#
|
2014-07-03 21:16:12 +00:00
|
|
|
# @return [Trace]
|
2014-05-12 13:48:15 +00:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.new
|
2014-07-03 21:16:12 +00:00
|
|
|
super(Hash[anima.attribute_names.map { |name| [name, []] }])
|
2014-07-02 19:23:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Warn with message
|
|
|
|
#
|
|
|
|
# @param [String] message
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def warn(message)
|
|
|
|
warn_calls << message
|
|
|
|
self
|
2014-05-12 13:48:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Report object
|
|
|
|
#
|
|
|
|
# @param [Object] object
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
2014-06-28 20:52:47 +00:00
|
|
|
# @api private
|
|
|
|
#
|
2014-05-12 13:48:15 +00:00
|
|
|
def report(object)
|
|
|
|
report_calls << object
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2014-08-10 22:09:29 +00:00
|
|
|
# Report new progress on object
|
|
|
|
#
|
|
|
|
# @param [Object] object
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def start(object)
|
|
|
|
start_calls << object
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2014-05-12 13:48:15 +00:00
|
|
|
# Report new progress on object
|
|
|
|
#
|
|
|
|
# @param [Object] object
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
2014-06-28 20:52:47 +00:00
|
|
|
# @api private
|
|
|
|
#
|
2014-05-12 13:48:15 +00:00
|
|
|
def progress(object)
|
|
|
|
progress_calls << object
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
end # Tracker
|
|
|
|
end # reporter
|
|
|
|
end # Mutant
|