Sha256: f91af8f67d96e48015233f6b7a13e3aa8975e59a0504d7a13a537e315ba12894
Contents?: true
Size: 1.85 KB
Versions: 18
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true ############################################################################## # Awesome Print Plugin ############################################################################## # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/CyclomaticComplexity begin require 'awesome_print' require 'io/console' module Kernel def sap(*messages) columns = if IO.console IO.console.winsize[1] else 80 end puts print "\e[1;37m" print " #{Time.now} ".center(columns, '*') print "\e[0m\n" puts root_path = if defined?(Rails) Rails.root.to_s else `git rev-parse --show-toplevel` end caller[0...5].each do |line| relative_line = line.gsub!(root_path.strip, '.') color = if relative_line == line '35' else '1;30' end print "\e[#{color}m" print line print "\e[0m\n" end puts Array(messages).each_with_index do |message, index| if message.respond_to?(:class) print "\e[32m" if defined?(::ActiveRecord::Base) && message.class.ancestors.include?(::ActiveRecord::Base) ap message.class else puts "Class: #{message.class}" print "Class Name: #{message.class.name}" end print "\e[0m\n" puts end ap(message, :raw => true) puts unless index + 1 == Array(messages).length end end end rescue LoadError end # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/AbcSize
Version data entries
18 entries across 18 versions & 1 rubygems