Sha256: 83147f468d027821acfb54afdaa0f5a70c648148c8320582549ffc409e7591c1

Contents?: true

Size: 509 Bytes

Versions: 5

Compression:

Stored size: 509 Bytes

Contents

module PryMoves::Painter

  class Canvas < String

    def <<(text)
      if length > 2000
        super("... (cut)")
        throw :cut
      end
      super
    end

  end

  def self.colorize(obj)
    colored_str = Canvas.new
    i = obj.inspect
    obj = obj.class if i.is_a?(String) && i.start_with?("#<")
    catch (:cut) do
      Pry::ColorPrinter.pp obj, colored_str
    end
    colored_str.chomp
  rescue => e
    "⛔️ Inspect error: #{e}\n" +
      "#{e.backtrace.first(3).join("\n")}"
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pry-moves-1.0.4 lib/pry-moves/painter.rb
pry-moves-1.0.3 lib/pry-moves/painter.rb
pry-moves-1.0.2 lib/pry-moves/painter.rb
pry-moves-1.0.1 lib/pry-moves/painter.rb
pry-moves-1.0.0 lib/pry-moves/painter.rb