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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c4b473b57dcf521b113674ad0431d7da96e3478588e1462ad237ff256e56288
4
- data.tar.gz: 35a26f22961d7157a546875c1620b33dafd02204326cdc3617a09cf96bc22b08
3
+ metadata.gz: '019dd9259e1444c65ca33a93706e9d7657e7282b834be82c770d6a8d68931b70'
4
+ data.tar.gz: 58d6ef4119ea94a0d37a1fe1e8a7d0036974ec75a4c72d0cb37e9959f1a00c76
5
5
  SHA512:
6
- metadata.gz: d87b4f5bed0c1494deb79e5d3c587a92711ee3c955ea8ea054e0b0e3eacfe5a169c3d8d61e69311ebffb9b18cbebc0334ec26263a7a7b335b7f0dfb9ffa06a18
7
- data.tar.gz: 3cafc6a035ef83800e4f5f8f8cd7f0092e6b8d04ca644418ef7fd09105114ba5dc4ab56e80e2e21074f2f26d3b7ba9738d7a787f0d2438830c4e80c4ee25919f
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
- require "amazing_tap"
50
+ user = { id: 42, name: "Ada Lovelace" }
51
+ ```
24
52
 
25
- user = { id: 7, name: "Ada" }
53
+ Chained receivers are inferred as written:
26
54
 
27
- user.tapp
28
- # user (Hash)
55
+ ```ruby
56
+ account.owner.tapp
57
+ # account.owner (Hash)
29
58
  # {
30
- # :id => 7,
31
- # :name => "Ada"
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
- account.owner.tapp # chains inferred as written: "account.owner (Hash)"
35
- user.tapp(:after_update) # explicit label instead of inference
36
- user.tapp(type: false) # label without the class
37
- user.tapp(backtrace: true) # appends " from <frame>" lines for the full caller
38
- user.tapp(backtrace: 3) # first 3 frames only
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
- # { :a => 1 }
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!`).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AmazingTap
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
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: true, backtrace: false)
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.0
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: 3.7.2
79
+ rubygems_version: 4.0.18
80
80
  specification_version: 4
81
81
  summary: amazing_tap
82
82
  test_files: []