amazing_tap 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +73 -12
- data/lib/amazing_tap/version.rb +1 -1
- data/lib/amazing_tap.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '019dd9259e1444c65ca33a93706e9d7657e7282b834be82c770d6a8d68931b70'
|
|
4
|
+
data.tar.gz: 58d6ef4119ea94a0d37a1fe1e8a7d0036974ec75a4c72d0cb37e9959f1a00c76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e55b7a83f6b4bd0c292d7377d578724588baef68ce9411d21937aa529c00ea5f5faf3d46a361cf83c744909c391947a5339966d167f94afa1c82c9ef25310b9
|
|
7
|
+
data.tar.gz: ec061ac3c413bba46df4dd619b77f27bfecdaeca20267ba1d9407d9c82bad5be5f591ba9081ba1e841d89ea4f84bd050a126a3b2aa321e1f9095dbbfef7813e8
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.1.2] - 2026-08-08
|
|
6
|
+
|
|
7
|
+
- `AmazingTap.show_type` global toggle for the class in headers; per-call `type:` still overrides
|
|
8
|
+
|
|
9
|
+
## [0.1.1] - 2026-08-08
|
|
10
|
+
|
|
11
|
+
- README overhaul: typed hash intro example with real output, per-option outputs in Usage, link to colorized terminal screenshot
|
|
12
|
+
|
|
5
13
|
## [0.1.0] - 2026-08-08
|
|
6
14
|
|
|
7
15
|
First release as `amazing_tap`, forked from [tap_amazing_print](https://github.com/shu0115/tap_amazing_print) 0.1.1.
|
data/README.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Labeled, chain-safe debugging built on [amazing_print](https://github.com/amazing-print/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.
|
|
4
4
|
|
|
5
|
+
```ruby
|
|
6
|
+
require "amazing_tap"
|
|
7
|
+
|
|
8
|
+
user = {
|
|
9
|
+
id: 42,
|
|
10
|
+
name: "Ada Lovelace",
|
|
11
|
+
admin: true,
|
|
12
|
+
roles: [:owner, :editor]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
user.tapp
|
|
16
|
+
# user (Hash)
|
|
17
|
+
# {
|
|
18
|
+
# id: 42,
|
|
19
|
+
# name: "Ada Lovelace",
|
|
20
|
+
# admin: true,
|
|
21
|
+
# roles: [
|
|
22
|
+
# [0] :owner,
|
|
23
|
+
# [1] :editor
|
|
24
|
+
# ]
|
|
25
|
+
# }
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Output is colorized in a terminal: [screenshot](https://github.com/dportalesr/amazing_tap/blob/main/.github/tapp-intro.png)
|
|
29
|
+
|
|
5
30
|
Fork of [shu0115/tap_amazing_print](https://github.com/shu0115/tap_amazing_print).
|
|
6
31
|
|
|
7
32
|
## Installation
|
|
@@ -19,23 +44,58 @@ gem install amazing_tap
|
|
|
19
44
|
|
|
20
45
|
## Usage
|
|
21
46
|
|
|
47
|
+
Examples below use:
|
|
48
|
+
|
|
22
49
|
```ruby
|
|
23
|
-
|
|
50
|
+
user = { id: 42, name: "Ada Lovelace" }
|
|
51
|
+
```
|
|
24
52
|
|
|
25
|
-
|
|
53
|
+
Chained receivers are inferred as written:
|
|
26
54
|
|
|
27
|
-
|
|
28
|
-
|
|
55
|
+
```ruby
|
|
56
|
+
account.owner.tapp
|
|
57
|
+
# account.owner (Hash)
|
|
29
58
|
# {
|
|
30
|
-
# :
|
|
31
|
-
# :
|
|
59
|
+
# id: 42,
|
|
60
|
+
# name: "Ada Lovelace"
|
|
32
61
|
# }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Explicit label instead of inference:
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
user.tapp(:after_update)
|
|
68
|
+
# after_update (Hash)
|
|
69
|
+
# { ... }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Label without the class:
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
user.tapp(type: false)
|
|
76
|
+
# user
|
|
77
|
+
# { ... }
|
|
78
|
+
```
|
|
33
79
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
user.tapp(backtrace: true)
|
|
38
|
-
user
|
|
80
|
+
Append the full caller as `from` lines:
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
user.tapp(backtrace: true)
|
|
84
|
+
# user (Hash)
|
|
85
|
+
# { ... }
|
|
86
|
+
# from app/services/sync.rb:17:in 'Object#refresh'
|
|
87
|
+
# from app/services/sync.rb:19:in '<main>'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Or only the first N frames:
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
user.tapp(backtrace: 3)
|
|
94
|
+
# user (Hash)
|
|
95
|
+
# { ... }
|
|
96
|
+
# from app/services/sync.rb:22:in 'Object#persist'
|
|
97
|
+
# from app/services/sync.rb:26:in 'Object#sync'
|
|
98
|
+
# from app/services/sync.rb:28:in '<main>'
|
|
39
99
|
```
|
|
40
100
|
|
|
41
101
|
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:
|
|
@@ -43,7 +103,7 @@ Label inference reads the receiver expression at the call site. It covers local
|
|
|
43
103
|
```ruby
|
|
44
104
|
{ a: 1 }.tapp
|
|
45
105
|
# (Hash)
|
|
46
|
-
# { :
|
|
106
|
+
# { a: 1 }
|
|
47
107
|
```
|
|
48
108
|
|
|
49
109
|
Long output gets a closing marker so you can tell where each dump ends:
|
|
@@ -61,6 +121,7 @@ big_list.tapp
|
|
|
61
121
|
|
|
62
122
|
```ruby
|
|
63
123
|
AmazingTap.closing_threshold = 40 # lines before the closing "/label" appears; default 24
|
|
124
|
+
AmazingTap.show_type = false # drop the class from headers globally; per-call type: overrides
|
|
64
125
|
```
|
|
65
126
|
|
|
66
127
|
Output is colorized whenever amazing_print would colorize (tty, or `AmazingPrint.force_colors!`).
|
data/lib/amazing_tap/version.rb
CHANGED
data/lib/amazing_tap.rb
CHANGED
|
@@ -20,6 +20,16 @@ module AmazingTap
|
|
|
20
20
|
@closing_threshold ||= DEFAULT_CLOSING_THRESHOLD
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Global default for appending the receiver's class to the header.
|
|
24
|
+
# Per-call type: overrides it either way.
|
|
25
|
+
#
|
|
26
|
+
# @return [Boolean] defaults to true
|
|
27
|
+
attr_writer :show_type
|
|
28
|
+
|
|
29
|
+
def show_type
|
|
30
|
+
@show_type.nil? ? true : @show_type
|
|
31
|
+
end
|
|
32
|
+
|
|
23
33
|
# Extracts the receiver expression preceding .tapp/.tapap on the call-site
|
|
24
34
|
# line, e.g. "user" for `user.tapp` or "account.owner" for
|
|
25
35
|
# `account.owner.tapp`. Inference is textual: literals, parenthesized
|
|
@@ -85,7 +95,7 @@ module AmazingTap
|
|
|
85
95
|
# the first N frames (Integer) after the output
|
|
86
96
|
# @return [self]
|
|
87
97
|
# @raise [ArgumentError] when label is neither nil nor a Symbol
|
|
88
|
-
def tapp(label = nil, type:
|
|
98
|
+
def tapp(label = nil, type: AmazingTap.show_type, backtrace: false)
|
|
89
99
|
raise ArgumentError, "label must be a Symbol" unless label.nil? || label.is_a?(Symbol)
|
|
90
100
|
|
|
91
101
|
label ||= AmazingTap.infer_label(caller_locations(1, 1).first)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: amazing_tap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Portales Rosado
|
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
77
|
version: '0'
|
|
78
78
|
requirements: []
|
|
79
|
-
rubygems_version:
|
|
79
|
+
rubygems_version: 4.0.18
|
|
80
80
|
specification_version: 4
|
|
81
81
|
summary: amazing_tap
|
|
82
82
|
test_files: []
|