Skip to main content

`AmazingPrintInspect` does not colorize

Consider a service that includes the AmazingPrintInspect config.

Here is the minimal example.

ConvenientService::Dependencies.require_amazing_print_inspect

class Service
include ::ConvenientService::Standard::Config
include ::ConvenientService::AmazingPrintInspect::Config

def result
success(foo: :bar, baz: :qux)
end
end

When it is called from the console like IRB.

Service.result

The result should be pretty-printed by amazing_print.

But it actually outputs some "weird escape characters" ^[[0;37m, ^[[0m or ^[[0;33m like in the screenshot below.

One way to fix that problem is to activate Amazing Print IRB integration.

AmazingPrint.irb!

Thus the output is colorized as expected.

In case you are using Pry, Amazing Print has integration for it as well.

AmazingPrint.pry!