Thursday, February 23, 2017

puts_debuggerer

puts_debuggerer

Ruby tools for improved puts debugging, automatically displaying bonus useful information such as file, line number and source code.
Partially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)

Instructions

Bundler

Add the following to bundler's Gemfile.
gem 'puts_debuggerer'

Manual

Or manually install and require library.
gem install puts_debuggerer
require 'puts_debuggerer'

Usage

Simple invoke global pd method anywhere you'd like to see line number and source code with output. If the argument is a pure string, the print out is simplified by not showing duplicate source.
Quickly find printed lines by running a find (e.g. CTRL+F) for "pd " or ".inspect => "
Happy puts debugging!
Example Code:
# /Users/User/finance_calculator_app/pd_test.rb # line 1
bug = 'beattle'                                 # line 2
pd "Show me the source of the bug: #{bug}"      # line 3
pd 'What line number am I?'                     # line 4
Example Printout:
pd /Users/User/finance_calculator_app/pd_test.rb:3 "Show me the source of the bug: #{bug}".inspect => "Show me the source of the bug: beattle"
pd /Users/User/finance_calculator_app/pd_test.rb:4 "What line number am I?"

More at puts_debuggerer

No comments: