amazing_tap
Labeled, chain-safe debugging built on amazing_print. tapp pretty-prints the receiver with a label inferred from the variable it was called on, plus its class and optional caller frames, then returns the receiver unchanged. Native Object#tap is not touched.
Fork of shu0115/tap_amazing_print.
Installation
# Gemfile
gem "amazing_tap", group: :development
Or standalone:
gem install amazing_tap
Usage
require "amazing_tap"
user = { id: 7, name: "Ada" }
user.tapp
# user (Hash)
# {
# :id => 7,
# :name => "Ada"
# }
account.owner.tapp # chains inferred as written: "account.owner (Hash)"
user.tapp(:after_update) # explicit label instead of inference
user.tapp(type: false) # label without the class
user.tapp(backtrace: true) # appends " from <frame>" lines for the full caller
user.tapp(backtrace: 3) # first 3 frames only
Label inference reads the receiver expression at the call site. It covers local variables, @ivars, $globals, dotted chains, and index access. When the source is not inferable (literals, parenthesized calls, multiline chains, REPL/eval), the header falls back to the class alone:
{ a: 1 }.tapp
# (Hash)
# { :a => 1 }
Long output gets a closing marker so you can tell where each dump ends:
big_list.tapp
# big_list (Array)
# [
# ... more than 24 lines ...
# ]
# /big_list
Configuration
AmazingTap.closing_threshold = 40 # lines before the closing "/label" appears; default 24
Output is colorized whenever amazing_print would colorize (tty, or AmazingPrint.force_colors!).
tapap
tapap is an alias of tapp.
Development
bundle install
bundle exec rspec
License
MIT. See LICENSE.txt.