class Chef::Taste::TableDisplay
Displays the cookbook dependency status in a table format
Public Class Methods
print(dependencies)
click to toggle source
Prints the status of dependent cookbooks as a table
@param dependencies [Array<Dependency>] list of cookbook dependency objects
# 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)
click to toggle source
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.
@param status [String] the status of the cookbook
@return [String, String] status symbol and color
# 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