Integrate awesome_print with Rails Console and Interactive Ruby -
awesome_print is code beautifying library available for beautifying Rails & Ruby code. This can be integrated with interactive Ruby and Rails console if you follow the instructions given below.
awesome_print : This is available as open source on Github
Source : awesome_print
Option 1 - Integrate with Interactive Ruby
Step 1. Install
This gem can be installed with following command -
This command will install the latest version of the gem awesome_print for you.
Step 2. Test
To test awesome_print, you need to start your Ruby environment and require awesome_print for your console,
The ap (awesome_print) command prints the result by formatting & beautifying the argument data passed to it
Step 3. Set as default for irb
You can set awesome_print formatting as default formatting for your output by putting following lines in .irbrc file.
If .irbrc file has not been created yet, then create a new one.
Open irbrc file:
Step 4. Restart
Then begin new terminal session and start interactive Ruby console. This will have awesome_print as the default output formatter for you.
Option 2 - Integrate with Rails application
Step 1. Add to Gemfile
Add the awesome_print gem in the Gemfile as given below in group development (Meaning you want to use this gem only for the development environment)
This will use gem awesome_print for your Rails application.
Step 2. Test Rails console
When you start the Rails console using
It will print output directly using the awesome_print library that you added in the group development.