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.
require "amazing_tap"
user = {
id: 42,
name: "Ada Lovelace",
admin: true,
roles: [:owner, :editor]
}
user.tapp
# user (Hash)
# {
# id: 42,
# name: "Ada Lovelace",
# admin: true,
# roles: [
# [0] :owner,
# [1] :editor
# ]
# }Output is colorized in a terminal: screenshot
Fork of shu0115/tap_amazing_print.
# Gemfile
gem "amazing_tap", group: :developmentOr standalone:
gem install amazing_tapExamples below use:
user = { id: 42, name: "Ada Lovelace" }Chained receivers are inferred as written:
account.owner.tapp
# account.owner (Hash)
# {
# id: 42,
# name: "Ada Lovelace"
# }Explicit label instead of inference:
user.tapp(:after_update)
# after_update (Hash)
# { ... }Label without the class:
user.tapp(type: false)
# user
# { ... }Append the full caller as from lines:
user.tapp(backtrace: true)
# user (Hash)
# { ... }
# from app/services/sync.rb:17:in 'Object#refresh'
# from app/services/sync.rb:19:in '<main>'Or only the first N frames:
user.tapp(backtrace: 3)
# user (Hash)
# { ... }
# from app/services/sync.rb:22:in 'Object#persist'
# from app/services/sync.rb:26:in 'Object#sync'
# from app/services/sync.rb:28:in '<main>'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_listAmazingTap.closing_threshold = 40 # lines before the closing "/label" appears; default 24
AmazingTap.show_type = false # drop the class from headers globally; per-call type: overridesOutput is colorized whenever amazing_print would colorize (tty, or AmazingPrint.force_colors!).
tapap is an alias of tapp.
bundle install
bundle exec rspecMIT. See LICENSE.txt.