Sha256: a427f1a13124d2a9bab96ccc69c830d07b2e12e715c2771e3da32810905cfe67
Contents?: true
Size: 901 Bytes
Versions: 16
Compression:
Stored size: 901 Bytes
Contents
# frozen_string_literal: true require "terminal-table" module RubyPgExtras class DiagnosePrint def self.call(data) new.call(data) end def call(data) rows = data.sort do |el| el.fetch(:ok) ? 1 : -1 end.map do |el| symbol = el.fetch(:ok) ? "√" : "x" color = el.fetch(:ok) ? :green : :red [ colorize("[#{symbol}] - #{el.fetch(:check_name)}", color), colorize(el.fetch(:message), color), ] end puts Terminal::Table.new( title: title, rows: rows, ) end private def title "ruby-pg-extras - diagnose report" end def colorize(string, color) if color == :red "\e[0;31;49m#{string}\e[0m" elsif color == :green "\e[0;32;49m#{string}\e[0m" else raise "Unsupported color: #{color}" end end end end
Version data entries
16 entries across 16 versions & 1 rubygems