From b53cb336f7f5d630ddad7a71dde9b9ae3efd3f99 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Mon, 30 Nov 2015 01:00:52 +0100 Subject: [PATCH] Add a progressbar ! --- Gemfile.lock | 2 ++ epafh.gemspec | 1 + lib/epafh/crawler.rb | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3455575..b55d884 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/epafh.gemspec b/epafh.gemspec index dcfb14d..c4a6491 100644 --- a/epafh.gemspec +++ b/epafh.gemspec @@ -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 diff --git a/lib/epafh/crawler.rb b/lib/epafh/crawler.rb index 87d38af..6d19997 100644 --- a/lib/epafh/crawler.rb +++ b/lib/epafh/crawler.rb @@ -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