puts_debuggerer 0.13.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +147 -84
- data/VERSION +1 -1
- data/lib/pd.rb +2 -0
- data/lib/puts_debuggerer/core_ext/kernel.rb +8 -0
- data/lib/puts_debuggerer.rb +4 -1
- metadata +6 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a2fbaa9054ef66fe1c92936402e68a375c1899d225a6ca4dd91283785c813d
|
4
|
+
data.tar.gz: cd63108d9a2862e9569393b5efe9a3e5074a4b4393937b035092e733b7981553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b7f7802d6b2c4bba93c336cd234d1550eecb20245a1a122d9fb383d4219eec8fc88c52b59ed042bc39c8863f47151b1357969f3de610f185b65f7e526b0d22
|
7
|
+
data.tar.gz: ff4e1dd6a42fd3d5e43983c8e56671ee98dee8d60869f67d4af36b37bd10fdf78ec9c45067f724b32c5a265249aa944f853cf3dc812aec94c4e9f98ae7c5e114
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
# Puts Debuggerer
|
2
|
-
##
|
1
|
+
# Puts Debuggerer 1.0.0
|
2
|
+
## Debugger-less Debugging FTW
|
3
|
+
## [Featured in State of the Art Rails 2023 Edition](https://github.com/DanielVartanov/state-of-the-art-rails/tree/bd7a509f5f0ab07cebfeada779b5c73e1eaf22ed)
|
3
4
|
[![Gem Version](https://badge.fury.io/rb/puts_debuggerer.svg)](http://badge.fury.io/rb/puts_debuggerer)
|
4
|
-
[![Build Status](https://travis-ci.org/AndyObtiva/puts_debuggerer.svg?branch=master)](https://travis-ci.org/AndyObtiva/puts_debuggerer)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/puts_debuggerer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/puts_debuggerer?branch=master)
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/81d8f6e046eb1b4a36f4/maintainability)](https://codeclimate.com/github/AndyObtiva/puts_debuggerer/maintainability)
|
7
7
|
|
8
8
|
(credit to Aaron Patterson for partial inspiration: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html)
|
9
9
|
|
10
|
+
If you like [Awesome_Print](https://rubygems.org/gems/awesome_print) (or [Amazing_Print](https://github.com/amazing-print/amazing_print)), you will love Puts Debuggerer (which builds upon them)!
|
11
|
+
|
10
12
|
Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.
|
11
13
|
|
12
14
|
In day-to-day test-driven development and simple app debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Still, there are a number of problems with puts debugging, like difficulty in locating puts statements in a large output log, knowing which methods and line numbers were invoked, identifying which variables were printed, and seeing the content of structured hashes and arrays in an understandable format.
|
13
15
|
|
14
|
-
Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, code statements, headers, footers, stack traces, and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print).
|
16
|
+
Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, headers, footers, stack traces, and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer).
|
15
17
|
|
16
18
|
[puts_debuggerer](https://rubygems.org/gems/puts_debuggerer) automates tips mentioned in [this blog post](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html) by Aaron Patterson using the `pd` method available everywhere after requiring the [gem](https://rubygems.org/gems/puts_debuggerer).
|
17
19
|
|
@@ -20,18 +22,25 @@ Basic Example:
|
|
20
22
|
```ruby
|
21
23
|
# /Users/User/trivia_app.rb # line 1
|
22
24
|
require 'pd' # line 2
|
23
|
-
|
24
|
-
|
25
|
+
class TriviaApp # line 3
|
26
|
+
def question # line 4
|
27
|
+
bug_or_band = 'Beatles' # line 5
|
28
|
+
pd bug_or_band # line 6
|
29
|
+
end # line 7
|
30
|
+
end # line 8
|
31
|
+
TriviaApp.new.question # line 9
|
25
32
|
```
|
26
33
|
|
27
34
|
Output:
|
28
35
|
|
29
36
|
```bash
|
30
|
-
[PD] /Users/User/trivia_app.rb:
|
31
|
-
> pd bug_or_band
|
32
|
-
=> "
|
37
|
+
[PD] /Users/User/trivia_app.rb:6 in TriviaApp.question
|
38
|
+
> pd bug_or_band # line 6
|
39
|
+
=> "Beatles"
|
33
40
|
```
|
34
41
|
|
42
|
+
`pd` revealed that the variable contains the band name "Beatles" as its value not the bug "Beetle", in addition to revealing the printed code statement `pd bug_or_band`, the file name `/Users/User/trivia_app.rb`, the line number `6`, the class name `TriviaApp`, and the invoked method name `question`.
|
43
|
+
|
35
44
|
## Background
|
36
45
|
|
37
46
|
It can be quite frustrating to lose puts statements in a large output or log file. One way to help find them is add an announcer (e.g. `puts "The Order Total"`) or a header (e.g. `puts '>'*80`) before every puts statement. Unfortunately, that leads to repetitive wasteful effort that adds up quickly over many work sessions and interrupts thinking flow while solving problems.
|
@@ -63,7 +72,7 @@ Which gets lost in a logging stream such as:
|
|
63
72
|
(0.2ms) COMMIT
|
64
73
|
```
|
65
74
|
|
66
|
-
Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name
|
75
|
+
Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name, line number, and invoked class method automatically for dead-easy debugging:
|
67
76
|
|
68
77
|
```ruby
|
69
78
|
pd order_total
|
@@ -77,7 +86,7 @@ Output:
|
|
77
86
|
(0.2ms) BEGIN
|
78
87
|
SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]]
|
79
88
|
(0.3ms) COMMIT
|
80
|
-
[PD] /Users/User/ordering/order.rb:39
|
89
|
+
[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total
|
81
90
|
> pd order_total
|
82
91
|
=> 195.50
|
83
92
|
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
@@ -98,19 +107,19 @@ Output:
|
|
98
107
|
```
|
99
108
|
(2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
100
109
|
ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
101
|
-
[PD] /Users/User/ordering/order.rb:39
|
110
|
+
[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total
|
102
111
|
> pd order_total
|
103
112
|
=> 195.50
|
104
113
|
(0.2ms) BEGIN
|
105
114
|
SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]]
|
106
115
|
(0.3ms) COMMIT
|
107
|
-
[PD] /Users/User/ordering/order.rb:40
|
116
|
+
[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total
|
108
117
|
> pd order_summary
|
109
118
|
=> "Pragmatic Ruby Book"
|
110
119
|
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
111
120
|
(0.2ms) BEGIN
|
112
121
|
(0.2ms) COMMIT
|
113
|
-
[PD] /Users/User/ordering/order.rb:41
|
122
|
+
[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total
|
114
123
|
> pd order_details
|
115
124
|
=> "[Hard Cover] Pragmatic Ruby Book - English Version"
|
116
125
|
```
|
@@ -137,19 +146,19 @@ Output:
|
|
137
146
|
(2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
138
147
|
ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
139
148
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
140
|
-
[PD] /Users/User/ordering/order.rb:39
|
149
|
+
[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total
|
141
150
|
> pd order_total, header: true
|
142
151
|
=> 195.50
|
143
152
|
(0.2ms) BEGIN
|
144
153
|
SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]]
|
145
154
|
(0.3ms) COMMIT
|
146
|
-
[PD] /Users/User/ordering/order.rb:40
|
155
|
+
[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total
|
147
156
|
> pd order_summary
|
148
157
|
=> "Pragmatic Ruby Book"
|
149
158
|
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
150
159
|
(0.2ms) BEGIN
|
151
160
|
(0.2ms) COMMIT
|
152
|
-
[PD] /Users/User/ordering/order.rb:41
|
161
|
+
[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total
|
153
162
|
> pd order_details
|
154
163
|
=> "[Hard Cover] Pragmatic Ruby Book - English Version"
|
155
164
|
```
|
@@ -176,19 +185,19 @@ Output:
|
|
176
185
|
(2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
177
186
|
ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
178
187
|
################################################################################
|
179
|
-
[PD] /Users/User/ordering/order.rb:39
|
188
|
+
[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total
|
180
189
|
> pd order_total, header: '>'*80
|
181
190
|
=> 195.50
|
182
191
|
(0.2ms) BEGIN
|
183
192
|
SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]]
|
184
193
|
(0.3ms) COMMIT
|
185
|
-
[PD] /Users/User/ordering/order.rb:40
|
194
|
+
[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total
|
186
195
|
> pd order_summary
|
187
196
|
=> "Pragmatic Ruby Book"
|
188
197
|
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
189
198
|
(0.2ms) BEGIN
|
190
199
|
(0.2ms) COMMIT
|
191
|
-
[PD] /Users/User/ordering/order.rb:41
|
200
|
+
[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total
|
192
201
|
> pd order_details, footer: '<'*80
|
193
202
|
=> "[Hard Cover] Pragmatic Ruby Book - English Version"
|
194
203
|
################################################################################
|
@@ -216,7 +225,7 @@ Output:
|
|
216
225
|
(2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
217
226
|
ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
218
227
|
********************************************************************************
|
219
|
-
[PD] /Users/User/ordering/order.rb:39
|
228
|
+
[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total
|
220
229
|
> pd order_total, caller: true, wrapper: true
|
221
230
|
=> 195.50
|
222
231
|
/Users/User/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
|
@@ -260,13 +269,13 @@ Output:
|
|
260
269
|
(0.2ms) BEGIN
|
261
270
|
SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]]
|
262
271
|
(0.3ms) COMMIT
|
263
|
-
[PD] /Users/User/ordering/order.rb:40
|
272
|
+
[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total
|
264
273
|
> pd order_summary
|
265
274
|
=> "Pragmatic Ruby Book"
|
266
275
|
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
267
276
|
(0.2ms) BEGIN
|
268
277
|
(0.2ms) COMMIT
|
269
|
-
[PD] /Users/User/ordering/order.rb:41
|
278
|
+
[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total
|
270
279
|
> pd order_details
|
271
280
|
=> "[Hard Cover] Pragmatic Ruby Book - English Version"
|
272
281
|
```
|
@@ -291,7 +300,7 @@ pd order_details
|
|
291
300
|
(2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
292
301
|
ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
293
302
|
********************************************************************************
|
294
|
-
[PD] /Users/User/ordering/order.rb:39
|
303
|
+
[PD] /Users/User/ordering/order.rb:39 in Order.calculate_order_total
|
295
304
|
> pd order_total, caller: 3, wrapper: true
|
296
305
|
=> 195.50
|
297
306
|
/Users/User/.rvm/gems/ruby-2.7.1/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
|
@@ -301,13 +310,13 @@ pd order_details
|
|
301
310
|
(0.2ms) BEGIN
|
302
311
|
SQL (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", 2017-08-24 22:56:52 UTC], ["updated_at", 2017-08-24 22:56:52 UTC]]
|
303
312
|
(0.3ms) COMMIT
|
304
|
-
[PD] /Users/User/ordering/order.rb:40
|
313
|
+
[PD] /Users/User/ordering/order.rb:40 in Order.calculate_order_total
|
305
314
|
> pd order_summary
|
306
315
|
=> "Pragmatic Ruby Book"
|
307
316
|
ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
|
308
317
|
(0.2ms) BEGIN
|
309
318
|
(0.2ms) COMMIT
|
310
|
-
[PD] /Users/User/ordering/order.rb:41
|
319
|
+
[PD] /Users/User/ordering/order.rb:41 in Order.calculate_order_total
|
311
320
|
> pd order_details
|
312
321
|
=> "[Hard Cover] Pragmatic Ruby Book - English Version"
|
313
322
|
```
|
@@ -320,10 +329,10 @@ There are many more options and features in [puts_debuggerer](https://rubygems.o
|
|
320
329
|
|
321
330
|
This is the recommended way for installing in [Rails](rubyonrails.org) apps in addition to configuring the [`app_path` option](#putsdebuggererapp_path).
|
322
331
|
|
323
|
-
Add the following to bundler's `Gemfile
|
332
|
+
Add the following to bundler's `Gemfile` (in Rails, you can optionally limit to the `:development` and `:test` groups).
|
324
333
|
|
325
334
|
```ruby
|
326
|
-
gem 'puts_debuggerer', '~> 0.
|
335
|
+
gem 'puts_debuggerer', '~> 1.0.0'
|
327
336
|
```
|
328
337
|
|
329
338
|
Run:
|
@@ -334,12 +343,22 @@ bundle
|
|
334
343
|
|
335
344
|
Optionally, you may configure the [Rails](rubyonrails.org) initializer `config/initializers/puts_debuggerer_options.rb` with further customizations as per the [Options](#options) section below.
|
336
345
|
|
346
|
+
Also, you may want to add the following to the initializer too if you limited the `puts_debuggerer` gem to the `:development` and `:test` groups:
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
unless Rails.env.development? || Rails.env.test?
|
350
|
+
def pd(*args, &block) # `pd(...)` in Ruby 2.7+
|
351
|
+
# No Op (just a stub in case developers forget troubleshooting pd calls in the code and deploy to production)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
```
|
355
|
+
|
337
356
|
### Option 2: Manual
|
338
357
|
|
339
358
|
Or manually install and require library.
|
340
359
|
|
341
360
|
```bash
|
342
|
-
gem install puts_debuggerer -
|
361
|
+
gem install puts_debuggerer -v1.0.0
|
343
362
|
```
|
344
363
|
|
345
364
|
```ruby
|
@@ -364,7 +383,7 @@ Still, if you do not need it, you may disable by setting `PutsDebuggerer.print_e
|
|
364
383
|
PutsDebuggerer.print_engine = :puts
|
365
384
|
```
|
366
385
|
|
367
|
-
If you also avoid requiring 'awesome_print', PutsDebuggerer
|
386
|
+
If you also avoid requiring 'awesome_print', PutsDebuggerer will NOT require it either if it sees that you have a different `print_engine`. In fact, you may switch to another print engine if you prefer like [amazing_print](https://github.com/amazing-print/amazing_print) as [explained here](https://github.com/AndyObtiva/puts_debuggerer#putsdebuggererprint_engine).
|
368
387
|
|
369
388
|
You may also avoid requiring in Bundler `Gemfile` with `require: false`:
|
370
389
|
|
@@ -375,13 +394,39 @@ gem "puts_debuggerer"
|
|
375
394
|
|
376
395
|
### Usage
|
377
396
|
|
378
|
-
First, add `pd` method anywhere in your code to display details about an object or expression (if you're used to awesome_print, you're in luck! puts_debuggerer includes awesome_print as the default print engine for output).
|
397
|
+
First, add `pd` method anywhere in your code to display details about an object or expression (if you're used to awesome_print, you're in luck! puts_debuggerer includes awesome_print (or amazing_print if preferred) as the default print engine for output).
|
398
|
+
|
399
|
+
Example:
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
# /Users/User/trivia_app.rb # line 1
|
403
|
+
require 'pd' # line 2
|
404
|
+
class TriviaApp # line 3
|
405
|
+
def question # line 4
|
406
|
+
bug_or_band = 'Beatles' # line 5
|
407
|
+
pd bug_or_band # line 6
|
408
|
+
end # line 7
|
409
|
+
end # line 8
|
410
|
+
TriviaApp.new.question # line 9
|
411
|
+
```
|
412
|
+
|
413
|
+
Output:
|
414
|
+
|
415
|
+
```bash
|
416
|
+
[PD] /Users/User/trivia_app.rb:6 in TriviaApp.question
|
417
|
+
> pd bug_or_band # line 6
|
418
|
+
=> "Beatles"
|
419
|
+
```
|
420
|
+
|
421
|
+
In addition to the object/expression output, you get to see the source file name, line number, invoked class method, and source code to help you debug and troubleshoot problems quicker (it even works in IRB).
|
422
|
+
|
423
|
+
You can use `pd` at the top-level main object too, and it prings `Object.<main>` for the class/method.
|
379
424
|
|
380
425
|
Example:
|
381
426
|
|
382
427
|
```ruby
|
383
428
|
# /Users/User/finance_calculator_app/pd_test.rb # line 1
|
384
|
-
bug = '
|
429
|
+
bug = 'Beetle' # line 2
|
385
430
|
pd "Show me the source of the bug: #{bug}" # line 3
|
386
431
|
pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 4
|
387
432
|
```
|
@@ -389,19 +434,18 @@ pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 4
|
|
389
434
|
Output:
|
390
435
|
|
391
436
|
```bash
|
392
|
-
[PD] /Users/User/finance_calculator_app/pd_test.rb:3
|
437
|
+
[PD] /Users/User/finance_calculator_app/pd_test.rb:3 in Object.<main>
|
393
438
|
> pd "Show me the source of the bug: #{bug}"
|
394
|
-
=> "Show me the source of the bug:
|
395
|
-
[PD] /Users/User/finance_calculator_app/pd_test.rb:4
|
439
|
+
=> "Show me the source of the bug: Beetle"
|
440
|
+
[PD] /Users/User/finance_calculator_app/pd_test.rb:4 in Object.<main>
|
396
441
|
> pd "Show me the result of the calculation: #{(12.0/3.0)}"
|
397
442
|
=> "Show me the result of the calculation: 4.0"
|
398
443
|
```
|
399
444
|
|
400
|
-
In addition to the main object/expression output, you get to see the source file name, line number, and source code to help you debug and troubleshoot problems quicker (it even works in IRB).
|
401
|
-
|
402
445
|
Second, quickly locate printed lines using the Find feature (e.g. CTRL+F) by looking for:
|
403
446
|
* [PD]
|
404
447
|
* file:line_number
|
448
|
+
* class.method
|
405
449
|
* known ruby expression.
|
406
450
|
|
407
451
|
Third, easily remove your ` pd ` statements via the source code Find feature once done debugging.
|
@@ -419,7 +463,7 @@ greeting = "Hello #{pd(name)}" # line 3
|
|
419
463
|
Output:
|
420
464
|
|
421
465
|
```bash
|
422
|
-
[PD] /Users/User/greeting_app/pd_test.rb:3
|
466
|
+
[PD] /Users/User/greeting_app/pd_test.rb:3 in Object.<main>
|
423
467
|
> greeting = "Hello #{pd(name)}"
|
424
468
|
=> "Hello Robert"
|
425
469
|
```
|
@@ -463,7 +507,7 @@ Prints out:
|
|
463
507
|
|
464
508
|
```bash
|
465
509
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
466
|
-
[PD] /Users/User/project/piecemeal.rb:3
|
510
|
+
[PD] /Users/User/project/piecemeal.rb:3 in Object.<main>
|
467
511
|
> pd data, header: true
|
468
512
|
=> [1, [2, 3]]
|
469
513
|
```
|
@@ -481,7 +525,7 @@ Prints out:
|
|
481
525
|
```bash
|
482
526
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
483
527
|
-<[PD]>-
|
484
|
-
/Users/User/project/piecemeal.rb:3
|
528
|
+
/Users/User/project/piecemeal.rb:3 in Object.<main>
|
485
529
|
> pd data, header: '>'*80, footer: '<'*80, announcer: " -<[PD]>-\n "
|
486
530
|
=> [1, [2, 3]]
|
487
531
|
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
@@ -505,16 +549,16 @@ Example:
|
|
505
549
|
```ruby
|
506
550
|
# /Users/User/finance_calculator_app/pd_test.rb # line 1
|
507
551
|
PutsDebuggerer.app_path = File.join('/Users', 'User', 'finance_calculator_app') # line 2
|
508
|
-
bug = '
|
552
|
+
bug = 'Beetle' # line 3
|
509
553
|
pd "Show me the source of the bug: #{bug}" # line 4
|
510
554
|
```
|
511
555
|
|
512
556
|
Example Printout:
|
513
557
|
|
514
558
|
```bash
|
515
|
-
[PD] /pd_test.rb:4
|
559
|
+
[PD] /pd_test.rb:4 in Object.<main>
|
516
560
|
> pd "Show me the source of the bug: #{bug}"
|
517
|
-
=> "Show me the source of the bug:
|
561
|
+
=> "Show me the source of the bug: Beetle"
|
518
562
|
```
|
519
563
|
|
520
564
|
#### `PutsDebuggerer.header`
|
@@ -536,7 +580,7 @@ Prints out:
|
|
536
580
|
|
537
581
|
```bash
|
538
582
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
539
|
-
[PD] /Users/User/example.rb:1
|
583
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
540
584
|
> pd (x=1), header: true
|
541
585
|
=> "1"
|
542
586
|
```
|
@@ -551,7 +595,7 @@ Prints out:
|
|
551
595
|
|
552
596
|
```bash
|
553
597
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
554
|
-
[PD] /Users/User/example.rb:1
|
598
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
555
599
|
> pd (x=1), h: :t
|
556
600
|
=> "1"
|
557
601
|
```
|
@@ -568,11 +612,11 @@ Prints out:
|
|
568
612
|
|
569
613
|
```bash
|
570
614
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
571
|
-
[PD] /Users/User/example.rb:2
|
615
|
+
[PD] /Users/User/example.rb:2 in Object.<main>
|
572
616
|
> pd (x=1)
|
573
617
|
=> "1"
|
574
618
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
575
|
-
[PD] /Users/User/example.rb:3
|
619
|
+
[PD] /Users/User/example.rb:3 in Object.<main>
|
576
620
|
> pd (x=2)
|
577
621
|
=> "2"
|
578
622
|
```
|
@@ -595,7 +639,7 @@ pd (x=1), footer: true
|
|
595
639
|
Prints out:
|
596
640
|
|
597
641
|
```bash
|
598
|
-
[PD] /Users/User/example.rb:1
|
642
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
599
643
|
> pd (x=1), footer: true
|
600
644
|
=> "1"
|
601
645
|
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
@@ -610,7 +654,7 @@ pd (x=1), f: :t
|
|
610
654
|
Prints out:
|
611
655
|
|
612
656
|
```bash
|
613
|
-
[PD] /Users/User/example.rb:1
|
657
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
614
658
|
> pd (x=1), f: :t
|
615
659
|
=> "1"
|
616
660
|
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
@@ -627,11 +671,11 @@ pd (x=2)
|
|
627
671
|
Prints out:
|
628
672
|
|
629
673
|
```bash
|
630
|
-
[PD] /Users/User/example.rb:2
|
674
|
+
[PD] /Users/User/example.rb:2 in Object.<main>
|
631
675
|
> pd (x=1)
|
632
676
|
=> "1"
|
633
677
|
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
634
|
-
[PD] /Users/User/example.rb:3
|
678
|
+
[PD] /Users/User/example.rb:3 in Object.<main>
|
635
679
|
> pd (x=2)
|
636
680
|
=> "2"
|
637
681
|
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
@@ -656,7 +700,7 @@ Prints out:
|
|
656
700
|
|
657
701
|
```bash
|
658
702
|
********************************************************************************
|
659
|
-
[PD] /Users/User/example.rb:1
|
703
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
660
704
|
> pd x=1, wrapper: true
|
661
705
|
=> "1"
|
662
706
|
********************************************************************************
|
@@ -672,7 +716,7 @@ Prints out:
|
|
672
716
|
|
673
717
|
```bash
|
674
718
|
********************************************************************************
|
675
|
-
[PD] /Users/User/example.rb:1
|
719
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
676
720
|
> pd x=1, w: :t
|
677
721
|
=> "1"
|
678
722
|
********************************************************************************
|
@@ -690,12 +734,12 @@ Prints out:
|
|
690
734
|
|
691
735
|
```bash
|
692
736
|
********************************************************************************
|
693
|
-
[PD] /Users/User/example.rb:2
|
737
|
+
[PD] /Users/User/example.rb:2 in Object.<main>
|
694
738
|
> pd (x=1)
|
695
739
|
=> "1"
|
696
740
|
********************************************************************************
|
697
741
|
********************************************************************************
|
698
|
-
[PD] /Users/User/example.rb:3
|
742
|
+
[PD] /Users/User/example.rb:3 in Object.<main>
|
699
743
|
> pd (x=2)
|
700
744
|
=> "2"
|
701
745
|
********************************************************************************
|
@@ -716,7 +760,7 @@ pd (true ||
|
|
716
760
|
Prints out:
|
717
761
|
|
718
762
|
```
|
719
|
-
[PD] /Users/User/example.rb:1
|
763
|
+
[PD] /Users/User/example.rb:1 in Object.<main>
|
720
764
|
> pd (true ||
|
721
765
|
false), source_line_count: 2
|
722
766
|
=> "true"
|
@@ -733,7 +777,7 @@ pd (true ||
|
|
733
777
|
Prints out:
|
734
778
|
|
735
779
|
```
|
736
|
-
[PD] /Users/User/example.rb:2
|
780
|
+
[PD] /Users/User/example.rb:2 in Object.<main>
|
737
781
|
> pd (true ||
|
738
782
|
false), source_line_count: 2
|
739
783
|
=> "true"
|
@@ -787,12 +831,14 @@ Prints out the following in standard out stream only (not in log files):
|
|
787
831
|
|
788
832
|
Print engine is similar to `printer`, except it is focused on the scope of formatting
|
789
833
|
the data object being printed (excluding metadata such as file name, line number,
|
790
|
-
and expression, which are handled by the `printer`).
|
834
|
+
invoked class method, and expression, which are handled by the `printer`).
|
791
835
|
As such, it is also a global method symbol or lambda expression.
|
792
836
|
Examples of global methods are `:p`, `:ap`, and `:pp`.
|
793
837
|
An example of a lambda expression is `lambda {|object| puts object.to_a.join(" | ")}`
|
794
838
|
|
795
|
-
Defaults to [awesome_print](https://github.com/awesome-print/awesome_print).
|
839
|
+
Defaults to [awesome_print](https://github.com/awesome-print/awesome_print). It does not load the library however until the first use of the `pd` command.
|
840
|
+
|
841
|
+
If you want to avoid loading [awesome_print](https://github.com/awesome-print/awesome_print) to use an alternative instead like [amazing_print](https://github.com/amazing-print/amazing_print), make sure to load [amazing_print](https://github.com/amazing-print/amazing_print) and call `PutsDebuggerer.print_engine = :ap` before the first `pd` call ([amazing_print](https://github.com/amazing-print/amazing_print) works through `ap` just like [awesome_print](https://github.com/awesome-print/awesome_print)).
|
796
842
|
|
797
843
|
Example:
|
798
844
|
|
@@ -806,7 +852,7 @@ pd array
|
|
806
852
|
Prints out:
|
807
853
|
|
808
854
|
```bash
|
809
|
-
[PD] /Users/User/example.rb:4
|
855
|
+
[PD] /Users/User/example.rb:4 in Object.<main>
|
810
856
|
> pd array
|
811
857
|
=> [1, [2, 3]]
|
812
858
|
```
|
@@ -827,7 +873,7 @@ Prints out:
|
|
827
873
|
|
828
874
|
```bash
|
829
875
|
*** PD ***
|
830
|
-
/Users/User/example.rb:2
|
876
|
+
/Users/User/example.rb:2 in Object.<main>
|
831
877
|
> pd x=1
|
832
878
|
=> "1"
|
833
879
|
```
|
@@ -837,15 +883,17 @@ Prints out:
|
|
837
883
|
|
838
884
|
Formatter used in every print out
|
839
885
|
Passed a data argument with the following keys:
|
840
|
-
*
|
841
|
-
*
|
842
|
-
*
|
843
|
-
*
|
844
|
-
*
|
845
|
-
*
|
846
|
-
*
|
847
|
-
*
|
848
|
-
*
|
886
|
+
* `:announcer` (`String`)
|
887
|
+
* `:caller` (`Array`)
|
888
|
+
* `:class` (`String`)
|
889
|
+
* `:file` (`String`)
|
890
|
+
* `:footer` (`String`)
|
891
|
+
* `:header` (`String`)
|
892
|
+
* `:line_number` (`String`)
|
893
|
+
* `:method` (`String`)
|
894
|
+
* `:pd_expression` (`String`)
|
895
|
+
* `:object` (`Object`)
|
896
|
+
* `:object_printer` (`Proc`)
|
849
897
|
|
850
898
|
NOTE: data for :object_printer is not a string, yet a proc that must
|
851
899
|
be called to output value. It is a proc as it automatically handles usage
|
@@ -860,6 +908,8 @@ PutsDebuggerer.formatter = -> (data) {
|
|
860
908
|
puts "HEADER: #{data[:header]}"
|
861
909
|
puts "FILE: #{data[:file]}"
|
862
910
|
puts "LINE: #{data[:line_number]}"
|
911
|
+
puts "CLASS: #{data[:class]}"
|
912
|
+
puts "METHOD: #{data[:method]}"
|
863
913
|
puts "EXPRESSION: #{data[:pd_expression]}"
|
864
914
|
print "PRINT OUT: "
|
865
915
|
data[:object_printer].call
|
@@ -873,9 +923,11 @@ Prints out:
|
|
873
923
|
|
874
924
|
```bash
|
875
925
|
-<[PD]>-
|
876
|
-
FILE: /Users/User/example.rb
|
877
926
|
HEADER: ********************************************************************************
|
927
|
+
FILE: /Users/User/example.rb
|
878
928
|
LINE: 9
|
929
|
+
CLASS: Example
|
930
|
+
METHOD: test
|
879
931
|
EXPRESSION: x=1
|
880
932
|
PRINT OUT: 1
|
881
933
|
CALLER: #/Users/User/master_examples.rb:83:in `block (3 levels) in <top (required)>'
|
@@ -895,15 +947,17 @@ Example:
|
|
895
947
|
|
896
948
|
```ruby
|
897
949
|
# File Name: /Users/User/sample_app/lib/sample.rb
|
898
|
-
|
950
|
+
class Sample
|
951
|
+
pd (x=1), caller: 3
|
952
|
+
end
|
899
953
|
```
|
900
954
|
|
901
955
|
Prints out (fictional):
|
902
956
|
|
903
957
|
```bash
|
904
|
-
[PD] /Users/User/sample_app/lib/sample.rb:
|
958
|
+
[PD] /Users/User/sample_app/lib/sample.rb:3 in Sample.<class:Sample>
|
905
959
|
> pd x=1, caller: 3
|
906
|
-
=>
|
960
|
+
=> 1
|
907
961
|
/Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
|
908
962
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
|
909
963
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\'
|
@@ -914,15 +968,17 @@ Shortcut Example:
|
|
914
968
|
|
915
969
|
```ruby
|
916
970
|
# File Name: /Users/User/sample_app/lib/sample.rb
|
917
|
-
|
971
|
+
class Sample
|
972
|
+
pd (x=1), c: 3
|
973
|
+
end
|
918
974
|
```
|
919
975
|
|
920
976
|
Prints out (fictional):
|
921
977
|
|
922
978
|
```bash
|
923
|
-
[PD] /Users/User/sample_app/lib/sample.rb:
|
979
|
+
[PD] /Users/User/sample_app/lib/sample.rb:3 in Sample.<class:Sample>
|
924
980
|
> pd x=1, caller: 3
|
925
|
-
=>
|
981
|
+
=> 1
|
926
982
|
/Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
|
927
983
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
|
928
984
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\'
|
@@ -934,23 +990,30 @@ Global Option Example:
|
|
934
990
|
```ruby
|
935
991
|
# File Name: /Users/User/sample_app/lib/sample.rb
|
936
992
|
PutsDebuggerer.caller = 3 # always print 3 lines only of the stack trace
|
937
|
-
|
938
|
-
|
993
|
+
class Sample
|
994
|
+
class << self
|
995
|
+
def test
|
996
|
+
pd (x=1)
|
997
|
+
pd (x=2)
|
998
|
+
end
|
999
|
+
end
|
1000
|
+
end
|
1001
|
+
Sample.test
|
939
1002
|
```
|
940
1003
|
|
941
1004
|
Prints out:
|
942
1005
|
|
943
1006
|
```bash
|
944
|
-
[PD] /Users/User/sample_app/lib/sample.rb:
|
1007
|
+
[PD] /Users/User/sample_app/lib/sample.rb:6 in Sample.test
|
945
1008
|
> pd (x=1)
|
946
|
-
=>
|
1009
|
+
=> 1
|
947
1010
|
/Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
|
948
1011
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
|
949
1012
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\'
|
950
1013
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/context.rb:381:in \`evaluate\'
|
951
|
-
[PD] /Users/User/sample_app/lib/sample.rb:
|
1014
|
+
[PD] /Users/User/sample_app/lib/sample.rb:7 in Sample.test
|
952
1015
|
> pd (x=2)
|
953
|
-
=>
|
1016
|
+
=> 2
|
954
1017
|
/Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
|
955
1018
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
|
956
1019
|
/Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\'
|
@@ -1122,4 +1185,4 @@ Note that it ignores the configured printer when printing exceptions as it relie
|
|
1122
1185
|
|
1123
1186
|
[MIT](LICENSE.txt)
|
1124
1187
|
|
1125
|
-
Copyright (c) 2017-
|
1188
|
+
Copyright (c) 2017-2024 - Andy Maleh.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/lib/pd.rb
CHANGED
@@ -143,6 +143,12 @@ module Kernel
|
|
143
143
|
caller[caller_depth] && caller[caller_depth][regex, 1]
|
144
144
|
end
|
145
145
|
|
146
|
+
# Provides caller method starting 1 level above caller of
|
147
|
+
# this method.
|
148
|
+
def __caller_method__(caller_depth=0)
|
149
|
+
regex = PutsDebuggerer::STACK_TRACE_CALL_METHOD_REGEX
|
150
|
+
caller[caller_depth] && caller[caller_depth][regex, 1]
|
151
|
+
end
|
146
152
|
|
147
153
|
# Provides caller source line starting 1 level above caller of
|
148
154
|
# this method.
|
@@ -189,6 +195,8 @@ module Kernel
|
|
189
195
|
pd_data = {
|
190
196
|
announcer: PutsDebuggerer.announcer,
|
191
197
|
file: __caller_file__(depth)&.sub(PutsDebuggerer.app_path.to_s, ''),
|
198
|
+
class: self.is_a?(Module) ? self : self.class,
|
199
|
+
method: __caller_method__(depth)&.sub(PutsDebuggerer.app_path.to_s, ''),
|
192
200
|
line_number: __caller_line_number__(depth),
|
193
201
|
pd_expression: __caller_pd_expression__(depth, source_line_count),
|
194
202
|
run_number: run_number,
|
data/lib/puts_debuggerer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(__dir__)) unless $LOAD_PATH.include?(File.expand_path(__dir__))
|
2
|
+
|
1
3
|
require 'puts_debuggerer/core_ext/kernel'
|
2
4
|
require 'puts_debuggerer/core_ext/logger'
|
3
5
|
require 'puts_debuggerer/core_ext/logging/logger'
|
@@ -52,7 +54,7 @@ module PutsDebuggerer
|
|
52
54
|
FORMATTER_DEFAULT = -> (data) {
|
53
55
|
puts data[:wrapper] if data[:wrapper]
|
54
56
|
puts data[:header] if data[:header]
|
55
|
-
print "#{data[:announcer]} #{data[:file]}#{':' if data[:line_number]}#{data[:line_number]}#{" (run:#{data[:run_number]})" if data[:run_number]}#{__format_pd_expression__(data[:pd_expression], data[:object])} "
|
57
|
+
print "#{data[:announcer]} #{data[:file]}#{':' if data[:line_number]}#{data[:line_number]} in #{[data[:class], data[:method]].compact.join('.')}#{" (run:#{data[:run_number]})" if data[:run_number]}#{__format_pd_expression__(data[:pd_expression], data[:object])} "
|
56
58
|
data[:object_printer].call
|
57
59
|
puts data[:caller].map {|l| ' ' + l} unless data[:caller].to_a.empty?
|
58
60
|
puts data[:footer] if data[:footer]
|
@@ -63,6 +65,7 @@ module PutsDebuggerer
|
|
63
65
|
STACK_TRACE_CALL_LINE_NUMBER_REGEX = /\:(\d+)\:in /
|
64
66
|
STACK_TRACE_CALL_SOURCE_FILE_REGEX = /[ ]*([^:]+)\:\d+\:in /
|
65
67
|
STACK_TRACE_CALL_SOURCE_FILE_REGEX_OPAL = /(http[^\)]+)/
|
68
|
+
STACK_TRACE_CALL_METHOD_REGEX = /`([^']+)'$/
|
66
69
|
OPTIONS = [:app_path, :source_line_count, :header, :h, :wrapper, :w, :footer, :f, :printer, :print_engine, :announcer, :formatter, :caller, :run_at]
|
67
70
|
OPTION_ALIASES = {
|
68
71
|
a: :announcer,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puts_debuggerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -94,48 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.1.4
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: coveralls
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.8.23
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.8.23
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: simplecov
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.16.1
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.16.1
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: simplecov-lcov
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 0.7.0
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.7.0
|
139
97
|
- !ruby/object:Gem::Dependency
|
140
98
|
name: logging
|
141
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,7 +124,7 @@ dependencies:
|
|
166
124
|
version: '0'
|
167
125
|
description: |
|
168
126
|
Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.
|
169
|
-
In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, code statements, and formats output nicely courtesy of awesome_print.
|
127
|
+
In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, and formats output nicely courtesy of awesome_print.
|
170
128
|
Partially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)
|
171
129
|
email: andy.am@gmail.com
|
172
130
|
executables: []
|
@@ -206,9 +164,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
164
|
- !ruby/object:Gem::Version
|
207
165
|
version: '0'
|
208
166
|
requirements: []
|
209
|
-
rubygems_version: 3.3
|
167
|
+
rubygems_version: 3.5.3
|
210
168
|
signing_key:
|
211
169
|
specification_version: 4
|
212
170
|
summary: Ruby library for improved puts debugging, automatically displaying bonus
|
213
|
-
useful information such as source line number
|
171
|
+
useful information such as source file name, line number, invoked class method,
|
172
|
+
and source code.
|
214
173
|
test_files: []
|