Skip to main content

`AwesomePrintInspect` does not colorize results

Consider a service that includes the AwesomePrintInspect config.

Here is the minimal example.

ConvenientService::Dependencies.require_awesome_print_inspect

class Service
include ::ConvenientService::Standard::Config
include ::ConvenientService::AwesomePrintInspect::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 awesome_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 Awesome Print IRB integration.

AwesomePrint.irb!

Thus the output is colorized as expected.

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

AwesomePrint.pry!