mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
501 B
26 lines
501 B
require 'progress_bar'
|
|
|
|
module Docs
|
|
class ProgressBarSubscriber < Subscriber
|
|
self.namespace = 'scraper'
|
|
|
|
def running(event)
|
|
@progress_bar = ::ProgressBar.new event.payload[:urls].length
|
|
@progress_bar.write
|
|
end
|
|
|
|
def queued(event)
|
|
@progress_bar.max += event.payload[:urls].length
|
|
@progress_bar.write
|
|
end
|
|
|
|
def process_response(event)
|
|
@progress_bar.increment!
|
|
end
|
|
|
|
def ignore_response(event)
|
|
@progress_bar.increment!
|
|
end
|
|
end
|
|
end
|