Sha256: c2d516fe7bcc9baf2a0e1e046c021aef939b646e56c1bb0ec71ed8b4dd90a7bc
Contents?: true
Size: 912 Bytes
Versions: 2
Compression:
Stored size: 912 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| p 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-pg-extras-3.2.0 | lib/ruby-pg-extras/diagnose_print.rb |
ruby-pg-extras-3.1.0 | lib/ruby-pg-extras/diagnose_print.rb |