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
pry
pry-rescue
ruby-progressbar
thor
GEM
@ -52,6 +53,7 @@ GEM
interception (>= 0.5)
pry
rake (10.4.2)
ruby-progressbar (1.7.5)
slop (3.6.0)
thor (0.19.1)
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-rescue"
spec.add_runtime_dependency "highline"
spec.add_runtime_dependency "ruby-progressbar"
end

View file

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