class Gem::StreamUI::VerboseDownloadReporter

def done

def done
  @progress = 100 if @units == '%'
  update_display(true, true)
end

def fetch(file_name, total_bytes)

def fetch(file_name, total_bytes)
  @file_name = file_name
  @total_bytes = total_bytes.to_i
  @units = @total_bytes.zero? ? 'B' : '%'
  update_display(false)
end

def initialize(out_stream, *args)

def initialize(out_stream, *args)
  @out = out_stream
  @progress = 0
end

def update(bytes)

def update(bytes)
  new_progress = if @units == 'B' then
                   bytes
                 else
                   ((bytes.to_f * 100) / total_bytes.to_f).ceil
                 end
  return if new_progress == @progress
  @progress = new_progress
  update_display
end

def update_display(show_progress = true, new_line = false)

def update_display(show_progress = true, new_line = false)
  return unless @out.tty?
  if show_progress then
    @out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
  else
    @out.print "Fetching: %s" % @file_name
  end
  @out.puts if new_line
end