Class: Chef::Handler::ElapsedTime
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- Chef::Handler::ElapsedTime
- Defined in:
- lib/chef/handler/elapsed_time.rb
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ ElapsedTime
constructor
A new instance of ElapsedTime.
- #report ⇒ Object
Methods inherited from Chef::Handler
#full_name, #max_resource_length, #unit_width
Constructor Details
#initialize(config = {}) ⇒ ElapsedTime
14 15 16 17 18 |
# File 'lib/chef/handler/elapsed_time.rb', line 14 def initialize(config={}) @config = config @config[:max_width] ||= 30 @config end |
Instance Method Details
#report ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/chef/handler/elapsed_time.rb', line 20 def report @max_time = all_resources.max_by{ |r| r.elapsed_time}.elapsed_time @max_resource = all_resources.max_by{ |r| full_name(r).length} Chef::Log.info "%-#{max_resource_length}s %s"%["Resource", " Elapsed Time"] Chef::Log.info "%-#{max_resource_length}s %s"%["========", " ============"] all_resources.each do |r| char = if r.updated then "+" else "-" end = "#{char} " + char * ( @config[:max_width] * (r.elapsed_time/@max_time)) Chef::Log.info "%-#{max_resource_length}s %s"%[full_name(r), ] end Chef::Log.info "" Chef::Log.info "Slowest Resource : #{full_name(@max_resource)} (%.6fs)"%[@max_time] Chef::Log.info "Scale : %.6fs per unit width"%[unit_width] Chef::Log.info " * '+' denotes a resource which updated this run" Chef::Log.info " * '-' denotes a resource which did not update this run" end |