Sha256: 81bab308c1606d497f2b6b29317967ac936d464812e9df584fa2912506483be3

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

# std libs
require 'forwardable'

# third party libs
# You will need to have gem "colorize" installed!
# NOTE: You will need to require "colorized_string" in your own code,
#       in order for this alternate Printer class to load

class Printer
  attr_accessor :colors, :color

  extend Forwardable
  def_delegators :@colors, :rotate!, :first
  def initialize
    @colors = ColorizedString.colors.dup.reject { |x| x.match?(/black|white/) }
  end

  # Log statement when a file starts loading
  def s(file, type)
    printf "🚥 #{ColorizedString["[RequireBench-#{type}]"].colorize(first)} 📖 %s 🚥\n", file
    rotate!
  end

  # Log statement when a file completed loading
  def p(seconds, file, type)
    printf "🚥 #{ColorizedString["[RequireBench-#{type}]"].colorize(first)} ☑️ %10f %s 🚥\n", seconds, file
    rotate!
  end

  # Log statement when a file raises an error while loading
  def e(error, file, type)
    printf "🚥 #{ColorizedString["[RequireBench-#{type}]"].colorize(first)} ❌ '#{error.class}: #{error.message}' loading %s 🚥\n#{error.backtrace.join("\n")}",
           file
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
require_bench-1.0.4.pre.alpha.4 lib/require_bench/color_printer.rb
require_bench-1.0.4.pre.alpha.2 lib/require_bench/color_printer.rb