Project

betterp

0.0
Low commit activity in last 3 years
No release in over a year
Overwrites Kernel#p to provide output with file path, line numbers, and profiling.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.1.3
~> 4.2
 Project Readme

betterp

Overview

betterp emulates Ruby's default p with a few extra goodies.

The standard Kernel#p method is overwritten with a version that provides the following features:

  • All output is prefixed with the file and line number that made the call to p
  • The output prefix is colourised. The colour is selected using a hash of the file path and line number so the colours are stable between each run.

The original semantics of Kernel#p are still applied, i.e. it returns the value(s) passed to it and the result of #inspect on each argument is output to a separate line.

Installation

Add the gem to your Gemfile

gem 'betterp', '~> 0.1.6'

And rebuild your bundle:

$ bundle install

Or install standalone:

$ gem install betterp -v '0.1.6'

Usage

Call p from anywhere in your code just as you normally would:

require 'betterp'

p 'hello'

betterp

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bobf/betterp

License

MIT License