summaryrefslogtreecommitdiff
path: root/lib/chef/formatters
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-03-15 21:05:49 +0000
committerThom May <thom@may.lt>2016-03-15 21:05:49 +0000
commitc1a389c2a8452e9b796aa1d34c4d9e51f4af30c7 (patch)
treeed2cc9b0c226a21ba3b9ab6b101fa76cb2db4891 /lib/chef/formatters
parent47cd0cb9f2c14ced5a17ea0d1da34b9aeaaf36d8 (diff)
parentff539423f067ee83c07dcf73cbf688c6a07f64ae (diff)
downloadchef-c1a389c2a8452e9b796aa1d34c4d9e51f4af30c7.tar.gz
Merge pull request #4658 from chef/tm/remote_file_download_progress11.9
Remote file download progress
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r--lib/chef/formatters/doc.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb
index 3f832f1e92..d43f1993b2 100644
--- a/lib/chef/formatters/doc.rb
+++ b/lib/chef/formatters/doc.rb
@@ -23,6 +23,7 @@ class Chef
@start_time = Time.now
@end_time = @start_time
@skipped_resources = 0
+ @progress = {}
end
def elapsed_time
@@ -284,6 +285,21 @@ class Chef
indent
end
+ def resource_update_progress(resource, current, total, interval)
+ @progress[resource] ||= 0
+
+ percent_complete = (current.to_f / total.to_f * 100).to_i
+
+ if percent_complete > @progress[resource]
+
+ @progress[resource] = percent_complete
+
+ if percent_complete % interval == 0
+ start_line " - Progress: #{percent_complete}%", :green
+ end
+ end
+ end
+
# Called when a resource fails, but will retry.
def resource_failed_retriable(resource, action, retry_count, exception)
end