chef-handler-elapsed-time 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -30,6 +30,20 @@ Create a recipe with the following:
30
30
  action :nothing
31
31
  end.run_action(:enable)
32
32
 
33
+ ### Options
34
+
35
+ You can pass an argument of `max_width` to the handler to define the
36
+ maximum width the bar can be in order to fit onto your screen if
37
+ required.
38
+
39
+ Example:
40
+
41
+ chef_handler "Chef::Handler::ElapsedTime" do
42
+ source "chef/handler/elapsed_time"
43
+ action :nothing
44
+ arguments :max_width => 10 # narrow bar
45
+ end.run_action(:enable)
46
+
33
47
  ### Example output
34
48
 
35
49
  $ chef-client
@@ -10,8 +10,12 @@
10
10
  class Chef
11
11
  class Handler
12
12
  class ElapsedTime < Chef::Handler
13
- BAR_MAXLEN = 30
14
- VERSION = '0.1.1'
13
+
14
+ def initialize(config={})
15
+ @config = config
16
+ @config[:max_width] ||= 30
17
+ @config
18
+ end
15
19
 
16
20
  def report
17
21
  max_time = all_resources.max_by{ |r| r.elapsed_time}.elapsed_time
@@ -21,9 +25,12 @@ class Chef
21
25
  Chef::Log.info "%-#{max_resource_length}s %s"%["========", "============"]
22
26
  all_resources.each do |r|
23
27
  char = if r.updated then "+" else "-" end
24
- bar = char * ( BAR_MAXLEN * (r.elapsed_time/max_time))
28
+ bar = char * ( @config[:max_width] * (r.elapsed_time/max_time))
25
29
  Chef::Log.info "%-#{max_resource_length}s %s"%[full_name(r), bar]
26
30
  end
31
+ Chef::Log.info ""
32
+ Chef::Log.info " * '+' denotes a resource which updated this run"
33
+ Chef::Log.info " * '-' denotes a resource which did not update this run"
27
34
  end
28
35
 
29
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-handler-elapsed-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: