Class: Chef::Taste::TableDisplay
- Inherits:
-
Object
- Object
- Chef::Taste::TableDisplay
- Defined in:
- lib/chef/taste/display.rb
Overview
Displays the cookbook dependency status in a table format
Class Method Summary collapse
-
.print(dependencies) ⇒ Object
Prints the status of dependent cookbooks as a table.
-
.status_to_symbol_and_color(status) ⇒ String
Given the status of the cookbook, this method will convert it to the unicode symbol and color.
Class Method Details
.print(dependencies) ⇒ Object
Prints the status of dependent cookbooks as a table
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/chef/taste/display.rb', line 60 def print(dependencies) rows = [] headings = %w(Name Requirement Used Latest Status Changelog) dependencies.each do |dependency| status_symbol, color = status_to_symbol_and_color(dependency.status) rows << [ dependency.name, dependency.requirement, dependency.version_used, dependency.latest, { value: status_symbol.send(color), alignment: :center }, dependency.changelog ] end # If any of the cookbook is out-of-date table = Terminal::Table.new headings: headings, rows: rows puts table if dependencies.any? { |dep| dep.status == 'out-of-date' } puts "Status: out-of-date ( #{X_MARK} )".red else puts "Status: up-to-date ( #{TICK_MARK} )".green end end |
.status_to_symbol_and_color(status) ⇒ String
Given the status of the cookbook, this method will convert it to the unicode symbol and color. The up-to-date cookbook will receive a green color TICK mark whereas the out-of-date cookbook will receive a red color ‘X’ mark.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/chef/taste/display.rb', line 93 def status_to_symbol_and_color(status) case status when 'up-to-date' return TICK_MARK, 'green' when'out-of-date' return X_MARK, 'red' else return '', 'white' end end |