Remove progress report throttling from public interface of formatters

This commit is contained in:
Markus Schirp 2014-08-10 22:16:53 +00:00
parent ac8fe85810
commit 522cf418a7
2 changed files with 17 additions and 28 deletions

View file

@ -57,9 +57,7 @@ module Mutant
# @api private
#
def progress(collector)
format.throttle do
write(format.progress(collector))
end
write(format.progress(collector))
self
end

View file

@ -15,14 +15,6 @@ module Mutant
#
abstract_method :progress
# Throttle report execution
#
# @return [self]
#
# @api private
#
abstract_method :throttle
# Format result
#
# @param [Result::Env] env
@ -54,7 +46,6 @@ module Mutant
buffer.public_send(name, *args, &block)
end
end
end # Output
private
@ -116,21 +107,9 @@ module Mutant
# @api private
#
def progress(collector)
format(Printer::Collector, collector)
end
# Call block throttled
#
# @return [self]
#
# @api private
#
def throttle
now = Time.now
return if @last_frame && (now - @last_frame) < OUTPUT_RATE
yield
@last_frame = now
self
throttle do
format(Printer::Collector, collector)
end.to_s
end
private
@ -146,10 +125,22 @@ module Mutant
#
# StringIO.new(Tput::INSTANCE.restore, BUFFER_FLAGS)
#
buffer = StringIO.new
buffer = StringIO.new
buffer << tput.restore
end
# Call block throttled
#
# @return [self]
#
# @api private
#
def throttle
now = Time.now
return if @last_frame && (now - @last_frame) < OUTPUT_RATE
yield.tap { @last_frame = now }
end
end # Framed
end # Format
end # CLI