Sha256: 181aacb88e6e132f41ec754c5c0ad9fcf32c8ea1ef6fce39cb86b6841c2bcba8
Contents?: true
Size: 899 Bytes
Versions: 33
Compression:
Stored size: 899 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
33 entries across 33 versions & 1 rubygems