diff options
author | Thom May <thom@chef.io> | 2016-03-03 10:11:29 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-03-03 10:11:29 +0000 |
commit | 788ec4597c9f1517c26d85703bdc79ea01e5ff53 (patch) | |
tree | 23364a04f0906df0697565ba84f9163b48a61298 /lib/chef/formatters | |
parent | a4d98365c1d68d7a24fba62783538951d2bbd2e0 (diff) | |
parent | 9c7bc8730af9ddba70d5095301517ae9e07e5024 (diff) | |
download | chef-788ec4597c9f1517c26d85703bdc79ea01e5ff53.tar.gz |
Merge branch 'remote-file-download-progress' of https://github.com/brandocorp/chef into tm/remote_file_download_progress
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r-- | lib/chef/formatters/doc.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index 5462241049..31732066a8 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 @@ -258,6 +259,21 @@ class Chef indent end + def resource_action_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}/100 %", :green + end + end + end + # Called when a resource fails, but will retry. def resource_failed_retriable(resource, action, retry_count, exception) end |