Sha256: 08f50430fce3923dbd52b0501ec6ada8837cbafde5d0a3dcc8530cc8c5a1b688

Contents?: true

Size: 472 Bytes

Versions: 2

Compression:

Stored size: 472 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
    obj = obj.class if obj.inspect.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

2 entries across 2 versions & 1 rubygems

Version Path
pry-moves-0.1.13 lib/pry-moves/painter.rb
pry-moves-0.1.12 lib/pry-moves/painter.rb