Add a progressbar !

This commit is contained in:
Glenn Y. Rolland 2015-11-30 01:00:52 +01:00
parent 1460435676
commit b53cb336f7
3 changed files with 8 additions and 1 deletions

View file

@ -10,6 +10,7 @@ PATH
mechanize mechanize
pry pry
pry-rescue pry-rescue
ruby-progressbar
thor thor
GEM GEM
@ -52,6 +53,7 @@ GEM
interception (>= 0.5) interception (>= 0.5)
pry pry
rake (10.4.2) rake (10.4.2)
ruby-progressbar (1.7.5)
slop (3.6.0) slop (3.6.0)
thor (0.19.1) thor (0.19.1)
unf (0.1.4) unf (0.1.4)

View file

@ -30,5 +30,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "pry" spec.add_runtime_dependency "pry"
spec.add_runtime_dependency "pry-rescue" spec.add_runtime_dependency "pry-rescue"
spec.add_runtime_dependency "highline" spec.add_runtime_dependency "highline"
spec.add_runtime_dependency "ruby-progressbar"
end end

View file

@ -1,4 +1,6 @@
require 'ruby-progressbar'
class Epafh::Crawler class Epafh::Crawler
attr_reader :imap attr_reader :imap
attr_reader :contacts attr_reader :contacts
@ -51,7 +53,6 @@ class Epafh::Crawler
# Skip examination of no addresses are remaining # Skip examination of no addresses are remaining
if remaining_emails.empty? then if remaining_emails.empty? then
print "."
return return
end end
@ -114,10 +115,13 @@ class Epafh::Crawler
end end
def examine_message_list mailbox_name, ids def examine_message_list mailbox_name, ids
progressbar = ProgressBar.create(:total => ids.size)
ids.each do |id| ids.each do |id|
@imap.select mailbox_name #GYR: TEST @imap.select mailbox_name #GYR: TEST
message = imap.fetch(id, [@saved_key])[0] message = imap.fetch(id, [@saved_key])[0]
examine_message message examine_message message
progressbar.increment
end end
rescue IOError rescue IOError
# re-connect and try again # re-connect and try again