puts_debuggerer 0.7.0 → 0.9.0
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 +5 -5
- data/CHANGELOG.md +63 -0
- data/LICENSE.txt +1 -1
- data/README.md +270 -62
- data/VERSION +1 -0
- data/lib/puts_debuggerer.rb +180 -60
- metadata +52 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f418876a84bf9553ec518205bad58db7b3abc120f1cd9fcff49e6edd49267247
|
4
|
+
data.tar.gz: 808081fdf435cd30c4d1bb1f6a4f6211068e2ae2d52c039e3f99bbbf77071744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e85ad239c06a374f8e8319649cca570af59aae4b828b64e2d4e9e1102af8a41123f8896da3ce8e2ec103d5300c4968493063419a258ed672ee82de05358e3f4
|
7
|
+
data.tar.gz: 2c56e41a7649d11ca7998d86b1682d2b16e59ecf70b94ef71c3672857c03693932d9ef797218fb65c9cfea7563c0df6428bf2e48a1ca4ac2366f38677b6bdfb8
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.9.0
|
4
|
+
|
5
|
+
- Provide partial support for Opal Ruby (missing display of file name, line number, and source code)
|
6
|
+
- `source_line_count` option
|
7
|
+
- `wraper` option for including both `header` and `footer`
|
8
|
+
- Special handling of exceptions (prints using full_message)
|
9
|
+
- Change :ap printer default to :p when unavailable
|
10
|
+
- Support varargs printing (example: `pd arg1, arg2, arg3`)
|
11
|
+
- Display `run_at` run number in printout
|
12
|
+
|
13
|
+
## 0.8.2
|
14
|
+
|
15
|
+
- require 'stringio' for projects that don't require automatically via other gems
|
16
|
+
|
17
|
+
## 0.8.1
|
18
|
+
|
19
|
+
- `printer` option support for Rails test environment
|
20
|
+
|
21
|
+
## 0.8.0
|
22
|
+
|
23
|
+
- `printer` option support
|
24
|
+
|
25
|
+
## 0.7.1
|
26
|
+
|
27
|
+
- default print engine to :ap (AwesomePrint)
|
28
|
+
|
29
|
+
## 0.7.0
|
30
|
+
|
31
|
+
- `run_at` option, global and piecemeal.
|
32
|
+
|
33
|
+
## 0.6.1
|
34
|
+
|
35
|
+
- updated README and broke apart specs
|
36
|
+
|
37
|
+
## 0.6.0
|
38
|
+
|
39
|
+
- unofficial erb support, returning evaluated object/expression, removed static syntax support (replaced with header support)
|
40
|
+
|
41
|
+
## 0.5.1
|
42
|
+
|
43
|
+
- support for print engine lambdas and smart defaults for leveraging Rails and AwesomePrint debuggers in Rails
|
44
|
+
|
45
|
+
## 0.5.0
|
46
|
+
|
47
|
+
- custom formatter, caller backtrace, per-puts piecemeal options, and multi-line support
|
48
|
+
|
49
|
+
## 0.4.0
|
50
|
+
|
51
|
+
- custom print engine (e.g. ap), custom announcer, and IRB support
|
52
|
+
|
53
|
+
## 0.3.0
|
54
|
+
|
55
|
+
- header/footer support, multi-line printout, improved format
|
56
|
+
|
57
|
+
## 0.2.0
|
58
|
+
|
59
|
+
- App path exclusion support, Rails root support, improved format
|
60
|
+
|
61
|
+
## 0.1.0
|
62
|
+
|
63
|
+
- File/line/expression print out
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,22 +1,127 @@
|
|
1
|
-
#
|
1
|
+
# Puts Debuggerer (debugger-less debugging FTW)
|
2
2
|
[](http://badge.fury.io/rb/puts_debuggerer)
|
3
3
|
[](https://travis-ci.org/AndyObtiva/puts_debuggerer)
|
4
4
|
[](https://coveralls.io/github/AndyObtiva/puts_debuggerer?branch=master)
|
5
5
|
|
6
|
-
|
7
|
-
statements like an umbrella in a stormy day.
|
8
|
-
Why not make it official and have puts debugging become its own perfectly
|
9
|
-
legitimate thing?!!
|
6
|
+
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.
|
10
7
|
|
11
|
-
Enter puts_debuggerer. A guilt-free puts
|
8
|
+
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.
|
12
9
|
|
13
|
-
|
10
|
+
Basic Example:
|
14
11
|
|
15
|
-
|
12
|
+
```ruby
|
13
|
+
# /Users/User/trivia_app.rb # line 1
|
14
|
+
require 'puts_debuggerer' # line 2
|
15
|
+
bug_or_band = 'beattle' # line 3
|
16
|
+
pd bug_or_band # line 4
|
17
|
+
```
|
18
|
+
|
19
|
+
Output:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
[PD] trivia_app.rb:4
|
23
|
+
> pd bug_or_band # line 4
|
24
|
+
=> "beattle"
|
25
|
+
```
|
26
|
+
|
27
|
+
## Background
|
28
|
+
|
29
|
+
For initial background, please read this blog post by Aaron Patterson (part of the inspiration for this gem):
|
16
30
|
https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html
|
17
|
-
(Credit to Tenderlove.)
|
18
31
|
|
19
|
-
|
32
|
+
It can be quite frustrating to lose puts statements in a large output or log file. One way to help find them is add a header (e.g. `puts "The Order Total"`) or an announcer (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.
|
33
|
+
|
34
|
+
puts_debuggerer automates that work via the short and simple `pd` command, automatically printing meaningful headers for output and accelerating problem solving work due to ease of typing.
|
35
|
+
|
36
|
+
Example without pd:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
puts order_total
|
40
|
+
```
|
41
|
+
|
42
|
+
Output:
|
43
|
+
```
|
44
|
+
195.50
|
45
|
+
```
|
46
|
+
|
47
|
+
Which gets lost in a logging stream such as:
|
48
|
+
|
49
|
+
```
|
50
|
+
(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)
|
51
|
+
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]]
|
52
|
+
(0.2ms) BEGIN
|
53
|
+
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]]
|
54
|
+
(0.3ms) COMMIT
|
55
|
+
195.50
|
56
|
+
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]]
|
57
|
+
(0.2ms) BEGIN
|
58
|
+
(0.2ms) COMMIT
|
59
|
+
```
|
60
|
+
|
61
|
+
Problem can be mitigated by adding a few more puts statements:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
puts "*"*40
|
65
|
+
puts "order_total"
|
66
|
+
puts order_total
|
67
|
+
```
|
68
|
+
|
69
|
+
But those add up pretty quickly when inspecting multiple variables:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
puts "*"*40
|
73
|
+
puts "order_total"
|
74
|
+
puts order_total
|
75
|
+
puts "*"*40
|
76
|
+
puts "order_summary"
|
77
|
+
puts order_summary
|
78
|
+
puts "*"*40
|
79
|
+
puts "order_details"
|
80
|
+
puts order_details
|
81
|
+
```
|
82
|
+
|
83
|
+
Here is a simple example using `pd` instead:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
pd order_total
|
87
|
+
```
|
88
|
+
|
89
|
+
Output:
|
90
|
+
|
91
|
+
```
|
92
|
+
[PD] /Users/User/ordering/order.rb:39
|
93
|
+
> pd order_total
|
94
|
+
=> 195.50
|
95
|
+
```
|
96
|
+
|
97
|
+
This is not only easy to locate in a logging stream such as the one below, but also includes the `order_total` variable for easy findability among other pd statements.
|
98
|
+
|
99
|
+
```
|
100
|
+
(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)
|
101
|
+
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]]
|
102
|
+
[PD] /Users/User/ordering/order.rb:39
|
103
|
+
> pd order_total
|
104
|
+
=> 195.50
|
105
|
+
(0.2ms) BEGIN
|
106
|
+
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]]
|
107
|
+
(0.3ms) COMMIT
|
108
|
+
[PD] /Users/User/ordering/order.rb:72
|
109
|
+
> pd order_subtotal
|
110
|
+
=> 181.00
|
111
|
+
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]]
|
112
|
+
(0.2ms) BEGIN
|
113
|
+
(0.2ms) COMMIT
|
114
|
+
```
|
115
|
+
|
116
|
+
And it is easy to search for using the `[PD]` announcer (customizable).
|
117
|
+
|
118
|
+
When inspecting multiple variables, debugging code is still a snap:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
pd order_total
|
122
|
+
pd order_summary
|
123
|
+
pd order_details
|
124
|
+
```
|
20
125
|
|
21
126
|
## Instructions
|
22
127
|
|
@@ -25,7 +130,7 @@ Love PD?! Why not promote with [merchandise](https://www.zazzle.com/i+heart+pd+g
|
|
25
130
|
Add the following to bundler's `Gemfile`.
|
26
131
|
|
27
132
|
```ruby
|
28
|
-
gem 'puts_debuggerer', '~> 0.
|
133
|
+
gem 'puts_debuggerer', '~> 0.9.0'
|
29
134
|
```
|
30
135
|
|
31
136
|
This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you may create an initializer under `config/initializers` named `puts_debuggerer_options.rb` to enable further customizations as per the [Options](#options) section below.
|
@@ -35,20 +140,29 @@ This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you m
|
|
35
140
|
Or manually install and require library.
|
36
141
|
|
37
142
|
```bash
|
38
|
-
gem install puts_debuggerer -v0.
|
143
|
+
gem install puts_debuggerer -v0.9.0
|
39
144
|
```
|
40
145
|
|
41
146
|
```ruby
|
42
147
|
require 'puts_debuggerer'
|
43
148
|
```
|
44
149
|
|
45
|
-
###
|
150
|
+
### Awesome Print
|
151
|
+
|
152
|
+
puts_debuggerer comes with [awesome_print](https://github.com/awesome-print/awesome_print).
|
153
|
+
|
154
|
+
You may disable when needed by not requiring in Ruby or by adding an explicit reference to awesome_print with `require: false` in bundler:
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
gem "awesome_print", require: false
|
158
|
+
gem "puts_debugger"
|
159
|
+
```
|
46
160
|
|
47
|
-
|
161
|
+
### Usage
|
48
162
|
|
49
|
-
|
163
|
+
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).
|
50
164
|
|
51
|
-
Example
|
165
|
+
Example:
|
52
166
|
|
53
167
|
```ruby
|
54
168
|
# /Users/User/finance_calculator_app/pd_test.rb # line 1
|
@@ -57,7 +171,7 @@ pd "Show me the source of the bug: #{bug}" # line 3
|
|
57
171
|
pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 4
|
58
172
|
```
|
59
173
|
|
60
|
-
|
174
|
+
Output:
|
61
175
|
|
62
176
|
```bash
|
63
177
|
[PD] /Users/User/finance_calculator_app/pd_test.rb:3
|
@@ -68,17 +182,18 @@ Example Printout:
|
|
68
182
|
=> "Show me the result of the calculation: 4.0"
|
69
183
|
```
|
70
184
|
|
71
|
-
|
185
|
+
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).
|
186
|
+
|
187
|
+
Second, quickly locate printed lines using the Find feature (e.g. CTRL+F) by looking for:
|
72
188
|
* [PD]
|
73
189
|
* file:line_number
|
74
190
|
* known ruby expression.
|
75
191
|
|
76
|
-
|
77
|
-
on once done debugging.
|
192
|
+
Third, easily remove your ` pd ` statements via the source code Find feature once done debugging.
|
78
193
|
|
79
194
|
Note that `pd` returns the passed in object or expression argument unchanged, permitting debugging with shorter syntax than tap, and supporting chaining of extra method invocations afterward.
|
80
195
|
|
81
|
-
Example
|
196
|
+
Example:
|
82
197
|
|
83
198
|
```ruby
|
84
199
|
# /Users/User/greeting_app/pd_test.rb # line 1
|
@@ -86,7 +201,7 @@ name = 'Robert' # line 2
|
|
86
201
|
greeting = "Hello #{pd(name)}" # line 3
|
87
202
|
```
|
88
203
|
|
89
|
-
|
204
|
+
Output:
|
90
205
|
|
91
206
|
```bash
|
92
207
|
[PD] /Users/User/greeting_app/pd_test.rb:3
|
@@ -216,20 +331,118 @@ Prints out:
|
|
216
331
|
********************************************************************************
|
217
332
|
```
|
218
333
|
|
334
|
+
#### `PutsDebuggerer.wrapper`
|
335
|
+
(default = `'*'*80`)
|
336
|
+
|
337
|
+
Wrapper to include at the top and bottom of every print out (both header and footer).
|
338
|
+
* Default value is `nil`
|
339
|
+
* Value `true` enables wrapper as `'*'*80`
|
340
|
+
* Value `false`, `nil`, or empty string disables wrapper
|
341
|
+
* Any other string value gets set as a custom wrapper
|
342
|
+
|
343
|
+
Example:
|
344
|
+
|
345
|
+
```ruby
|
346
|
+
PutsDebuggerer.wrapper = true
|
347
|
+
pd (x=1)
|
348
|
+
```
|
349
|
+
|
350
|
+
Prints out:
|
351
|
+
|
352
|
+
```bash
|
353
|
+
********************************************************************************
|
354
|
+
[PD] /Users/User/example.rb:2
|
355
|
+
> pd x=1
|
356
|
+
=> "1"
|
357
|
+
********************************************************************************
|
358
|
+
```
|
359
|
+
|
360
|
+
#### `PutsDebuggerer.source_line_count`
|
361
|
+
(default = `1`)
|
362
|
+
|
363
|
+
Example:
|
364
|
+
|
365
|
+
```ruby
|
366
|
+
pd (true ||
|
367
|
+
false), source_line_count: 2
|
368
|
+
```
|
369
|
+
|
370
|
+
Prints out:
|
371
|
+
|
372
|
+
```
|
373
|
+
[PD] /Users/User/example.rb:2
|
374
|
+
> pd (true ||
|
375
|
+
false), source_line_count: 2
|
376
|
+
=> "true"
|
377
|
+
```
|
378
|
+
|
379
|
+
Example:
|
380
|
+
|
381
|
+
```ruby
|
382
|
+
PutsDebuggerer.source_line_count = 2 # setting via global option
|
383
|
+
pd (true ||
|
384
|
+
false)
|
385
|
+
```
|
386
|
+
|
387
|
+
Prints out:
|
388
|
+
|
389
|
+
```
|
390
|
+
[PD] /Users/User/example.rb:2
|
391
|
+
> pd (true ||
|
392
|
+
false), source_line_count: 2
|
393
|
+
=> "true"
|
394
|
+
```
|
395
|
+
|
396
|
+
#### `PutsDebuggerer.printer`
|
397
|
+
(default = `:puts`)
|
398
|
+
|
399
|
+
Printer is a global method symbol or lambda expression to use in printing to the user.
|
400
|
+
Examples of global methods are `:puts` and `:print`.
|
401
|
+
An example of a lambda expression is `lambda {|output| Rails.logger.info(output)}`
|
402
|
+
|
403
|
+
Defaults to `:puts`
|
404
|
+
In Rails, it defaults to:
|
405
|
+
```ruby
|
406
|
+
lambda do |output|
|
407
|
+
puts output if Rails.env.test?
|
408
|
+
Rails.logger.debug(output)
|
409
|
+
end
|
410
|
+
```
|
411
|
+
|
412
|
+
Example:
|
413
|
+
|
414
|
+
```ruby
|
415
|
+
# File Name: /Users/User/example.rb
|
416
|
+
PutsDebuggerer.printer = lambda {|output| Rails.logger.error(output)}
|
417
|
+
str = "Hello"
|
418
|
+
pd str
|
419
|
+
```
|
420
|
+
|
421
|
+
Prints out in the Rails app log as error lines:
|
422
|
+
|
423
|
+
```bash
|
424
|
+
[PD] /Users/User/example.rb:5
|
425
|
+
> pd str
|
426
|
+
=> Hello
|
427
|
+
```
|
428
|
+
|
219
429
|
#### `PutsDebuggerer.print_engine`
|
220
|
-
(default = `:
|
430
|
+
(default = `:ap`)
|
221
431
|
|
222
|
-
Print engine is
|
432
|
+
Print engine is similar to `printer`, except it is focused on the scope of formatting
|
433
|
+
the data object being printed (excluding metadata such as file name, line number,
|
434
|
+
and expression, which are handled by the `printer`).
|
435
|
+
As such, it is also a global method symbol or lambda expression.
|
436
|
+
Examples of global methods are `:p`, `:ap`, and `:pp`.
|
437
|
+
An example of a lambda expression is `lambda {|object| puts object.to_a.join(" | ")}`
|
223
438
|
|
224
|
-
Defaults to
|
225
|
-
If it finds [awesome_print](https://github.com/awesome-print/awesome_print) loaded, it defaults to `ap` as `:ap` instead. Also, if it finds Rails loaded without ap, it relies on `lambda {|o| Rails.logger.debug(o)}` as the print engine. Otherwise if both Rails and [awesome_print](https://github.com/awesome-print/awesome_print) are loaded, then it relies on `lambda {|o| Rails.logger.ap(o)}` instead
|
439
|
+
Defaults to [awesome_print](https://github.com/awesome-print/awesome_print).
|
226
440
|
|
227
441
|
Example:
|
228
442
|
|
229
443
|
```ruby
|
230
444
|
# File Name: /Users/User/example.rb
|
231
|
-
|
232
|
-
PutsDebuggerer.print_engine = :ap
|
445
|
+
PutsDebuggerer.print_engine = :p
|
233
446
|
array = [1, [2, 3]]
|
234
447
|
pd array
|
235
448
|
```
|
@@ -239,13 +452,7 @@ Prints out:
|
|
239
452
|
```bash
|
240
453
|
[PD] /Users/User/example.rb:5
|
241
454
|
> pd array
|
242
|
-
=> [
|
243
|
-
[0] 1,
|
244
|
-
[1] [
|
245
|
-
[0] 2,
|
246
|
-
[1] 3
|
247
|
-
]
|
248
|
-
]
|
455
|
+
=> [1, [2, 3]]
|
249
456
|
```
|
250
457
|
|
251
458
|
#### `PutsDebuggerer.announcer`
|
@@ -366,6 +573,7 @@ the same exact `object` passed to `pd` for counting.
|
|
366
573
|
|
367
574
|
Examples (global):
|
368
575
|
|
576
|
+
```ruby
|
369
577
|
PutsDebuggerer.run_at = 1
|
370
578
|
pd (x=1) # prints standard PD output
|
371
579
|
pd (x=1) # prints nothing
|
@@ -401,13 +609,14 @@ Examples (global):
|
|
401
609
|
pd (x=1) # prints nothing
|
402
610
|
pd (x=1) # prints nothing
|
403
611
|
pd (x=1) # prints standard PD output
|
404
|
-
pd (x=1) ... continue printing indefinitely on all subsequent runs
|
612
|
+
pd (x=1) # ... continue printing indefinitely on all subsequent runs
|
405
613
|
|
406
614
|
PutsDebuggerer.run_at = 3...-1
|
407
615
|
pd (x=1) # prints nothing
|
408
616
|
pd (x=1) # prints nothing
|
409
617
|
pd (x=1) # prints standard PD output
|
410
|
-
pd (x=1) ... continue printing indefinitely on all subsequent runs
|
618
|
+
pd (x=1) # ... continue printing indefinitely on all subsequent runs
|
619
|
+
```
|
411
620
|
|
412
621
|
You may reset the run_at number counter via:
|
413
622
|
`PutsDebuggerer.reset_run_at_global_number` for global usage.
|
@@ -417,20 +626,9 @@ And:
|
|
417
626
|
`PutsDebuggerer.reset_run_at_numbers`
|
418
627
|
for piecemeal usage.
|
419
628
|
|
420
|
-
### Bonus
|
421
|
-
|
422
|
-
puts_debuggerer comes with a number of bonus goodies.
|
423
|
-
|
424
|
-
It comes with [awesome_print](https://github.com/awesome-print/awesome_print).
|
425
|
-
|
426
|
-
You may disable by not requiring in Ruby or by adding an explicit reference to awesome_print with `require: false` in bundler:
|
427
|
-
|
428
|
-
```ruby
|
429
|
-
gem "awesome_print", require: false
|
430
|
-
gem "puts_debugger"
|
431
|
-
```
|
629
|
+
### Bonus API
|
432
630
|
|
433
|
-
|
631
|
+
puts_debuggerer comes with the following bonus API methods:
|
434
632
|
|
435
633
|
#### `__caller_line_number__(caller_depth=0)`
|
436
634
|
|
@@ -472,17 +670,26 @@ puts __caller_source_line__
|
|
472
670
|
|
473
671
|
Prints out `puts __caller_source_line__`
|
474
672
|
|
475
|
-
##
|
673
|
+
## Compatibility
|
674
|
+
|
675
|
+
[puts_debuggerer](https://rubygems.org/gems/puts_debuggerer) is fully compatible with:
|
676
|
+
- [Ruby](https://www.ruby-lang.org/en/)
|
677
|
+
- [JRuby](https://www.jruby.org/)
|
678
|
+
- IRB
|
679
|
+
- Rails Console.
|
680
|
+
|
681
|
+
It has partial-compatibility with [Opal Ruby](https://opalrb.com/) with everything working except these features:
|
682
|
+
- File name display
|
683
|
+
- Line number display
|
684
|
+
- Source code call display
|
476
685
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
* v0.2.0: App path exclusion support, Rails root support, improved format
|
485
|
-
* v0.1.0: File/line/expression print out
|
686
|
+
## Change Log
|
687
|
+
|
688
|
+
[CHANGELOG.md](CHANGELOG.md)
|
689
|
+
|
690
|
+
## TODO
|
691
|
+
|
692
|
+
[TODO.md](TODO)
|
486
693
|
|
487
694
|
## Contributing
|
488
695
|
|
@@ -498,5 +705,6 @@ Prints out `puts __caller_source_line__`
|
|
498
705
|
|
499
706
|
## Copyright
|
500
707
|
|
501
|
-
|
502
|
-
|
708
|
+
[MIT](LICENSE.txt)
|
709
|
+
|
710
|
+
Copyright (c) 2017-2020 - Andy Maleh.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.9.0
|
data/lib/puts_debuggerer.rb
CHANGED
@@ -1,17 +1,28 @@
|
|
1
|
-
require '
|
1
|
+
require 'awesome_print' unless RUBY_PLATFORM == 'opal'
|
2
|
+
require 'stringio'
|
2
3
|
|
3
4
|
module PutsDebuggerer
|
5
|
+
SOURCE_LINE_COUNT_DEFAULT = 1
|
4
6
|
HEADER_DEFAULT = '*'*80
|
7
|
+
WRAPPER_DEFAULT = '*'*80
|
5
8
|
FOOTER_DEFAULT = '*'*80
|
6
|
-
|
7
|
-
|
9
|
+
PRINTER_DEFAULT = :puts
|
10
|
+
PRINTER_RAILS = lambda do |output|
|
11
|
+
puts output if Rails.env.test?
|
12
|
+
Rails.logger.debug(output)
|
13
|
+
end
|
14
|
+
PRINT_ENGINE_DEFAULT = :ap
|
15
|
+
PRINTER_MESSAGE_INVALID = 'printer must be a valid global method symbol (e.g. :puts) or lambda/proc receiving a text arg'
|
16
|
+
PRINT_ENGINE_MESSAGE_INVALID = 'print_engine must be a valid global method symbol (e.g. :p, :ap or :pp) or lambda/proc receiving an object arg'
|
8
17
|
ANNOUNCER_DEFAULT = '[PD]'
|
9
18
|
FORMATTER_DEFAULT = -> (data) {
|
19
|
+
puts data[:wrapper] if data[:wrapper]
|
10
20
|
puts data[:header] if data[:header]
|
11
|
-
print "#{data[:announcer]} #{data[:file]}:#{data[:line_number]}#{__format_pd_expression__(data[:pd_expression], data[:object])} "
|
21
|
+
print "#{data[:announcer]} #{data[:file]}:#{data[:line_number]}#{" (run:#{data[:run_number]})" if data[:run_number]}#{__format_pd_expression__(data[:pd_expression], data[:object])} "
|
12
22
|
data[:object_printer].call
|
13
23
|
puts data[:caller].map {|l| ' ' + l} unless data[:caller].to_a.empty?
|
14
24
|
puts data[:footer] if data[:footer]
|
25
|
+
puts data[:wrapper] if data[:wrapper]
|
15
26
|
}
|
16
27
|
CALLER_DEPTH_ZERO = 4 #depth includes pd + with_options method + nested block + build_pd_data method
|
17
28
|
OBJECT_RUN_AT = {}
|
@@ -38,6 +49,28 @@ module PutsDebuggerer
|
|
38
49
|
@app_path = (path || Rails.root.to_s) rescue nil
|
39
50
|
end
|
40
51
|
|
52
|
+
# Source Line Count.
|
53
|
+
# * Default value is `1`
|
54
|
+
#
|
55
|
+
# Example:
|
56
|
+
#
|
57
|
+
# PutsDebuggerer.source_line_count = 2
|
58
|
+
# pd (true ||
|
59
|
+
# false), source_line_count: 2
|
60
|
+
#
|
61
|
+
# Prints out:
|
62
|
+
#
|
63
|
+
# ********************************************************************************
|
64
|
+
# [PD] /Users/User/example.rb:2
|
65
|
+
# > pd (true ||
|
66
|
+
# false), source_line_count: 2
|
67
|
+
# => "true"
|
68
|
+
attr_reader :source_line_count
|
69
|
+
|
70
|
+
def source_line_count=(value)
|
71
|
+
@source_line_count = value || SOURCE_LINE_COUNT_DEFAULT
|
72
|
+
end
|
73
|
+
|
41
74
|
# Header to include at the top of every print out.
|
42
75
|
# * Default value is `nil`
|
43
76
|
# * Value `true` enables header as `'*'*80`
|
@@ -71,6 +104,39 @@ module PutsDebuggerer
|
|
71
104
|
!!@header
|
72
105
|
end
|
73
106
|
|
107
|
+
# Wrapper to include at the top and bottom of every print out (both header and footer).
|
108
|
+
# * Default value is `nil`
|
109
|
+
# * Value `true` enables wrapper as `'*'*80`
|
110
|
+
# * Value `false`, `nil`, or empty string disables wrapper
|
111
|
+
# * Any other string value gets set as a custom wrapper
|
112
|
+
#
|
113
|
+
# Example:
|
114
|
+
#
|
115
|
+
# PutsDebuggerer.wrapper = true
|
116
|
+
# pd (x=1)
|
117
|
+
#
|
118
|
+
# Prints out:
|
119
|
+
#
|
120
|
+
# [PD] /Users/User/example.rb:2
|
121
|
+
# > pd x=1
|
122
|
+
# => "1"
|
123
|
+
# ********************************************************************************
|
124
|
+
attr_reader :wrapper
|
125
|
+
|
126
|
+
def wrapper=(value)
|
127
|
+
if value.equal?(true)
|
128
|
+
@wrapper = WRAPPER_DEFAULT
|
129
|
+
elsif value == ''
|
130
|
+
@wrapper = nil
|
131
|
+
else
|
132
|
+
@wrapper = value
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def wrapper?
|
137
|
+
!!@wrapper
|
138
|
+
end
|
139
|
+
|
74
140
|
# Footer to include at the bottom of every print out.
|
75
141
|
# * Default value is `nil`
|
76
142
|
# * Value `true` enables footer as `'*'*80`
|
@@ -104,17 +170,55 @@ module PutsDebuggerer
|
|
104
170
|
!!@footer
|
105
171
|
end
|
106
172
|
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
173
|
+
# Printer is a global method symbol or lambda expression to use in printing to the user.
|
174
|
+
# Examples of global methods are `:puts` and `:print`.
|
175
|
+
# An example of a lambda expression is `lambda {|output| Rails.logger.ap(output)}`
|
176
|
+
#
|
177
|
+
# Defaults to `:puts`
|
178
|
+
# In Rails, it defaults to: `lambda {|output| Rails.logger.ap(output)}`
|
179
|
+
#
|
180
|
+
# Example:
|
181
|
+
#
|
182
|
+
# # File Name: /Users/User/example.rb
|
183
|
+
# PutsDebuggerer.printer = lambda {|output| Rails.logger.error(output)}
|
184
|
+
# str = "Hello"
|
185
|
+
# pd str
|
186
|
+
#
|
187
|
+
# Prints out in the Rails app log as error lines:
|
188
|
+
#
|
189
|
+
# [PD] /Users/User/example.rb:5
|
190
|
+
# > pd str
|
191
|
+
# => Hello
|
192
|
+
attr_reader :printer
|
193
|
+
|
194
|
+
def printer=(printer)
|
195
|
+
if printer.nil?
|
196
|
+
if Object.const_defined?(:Rails)
|
197
|
+
@printer = PRINTER_RAILS
|
198
|
+
else
|
199
|
+
@printer = PRINTER_DEFAULT
|
200
|
+
end
|
201
|
+
elsif printer.is_a?(Proc)
|
202
|
+
@printer = printer
|
203
|
+
else
|
204
|
+
@printer = method(printer).name rescue raise(PRINTER_MESSAGE_INVALID)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# Print engine is similar to `printer`, except it is focused on the scope of formatting
|
209
|
+
# the data object being printed (excluding metadata such as file name, line number,
|
210
|
+
# and expression, which are handled by the `printer`).
|
211
|
+
# As such, it is also a global method symbol or lambda expression.
|
212
|
+
# Examples of global methods are `:p`, `:ap`, and `:pp`.
|
213
|
+
# An example of a lambda expression is `lambda {|object| puts object.to_a.join(" | ")}`
|
214
|
+
#
|
215
|
+
# Defaults to [awesome_print](https://github.com/awesome-print/awesome_print).
|
112
216
|
#
|
113
217
|
# Example:
|
114
218
|
#
|
115
219
|
# # File Name: /Users/User/example.rb
|
116
220
|
# require 'awesome_print'
|
117
|
-
# PutsDebuggerer.print_engine = :
|
221
|
+
# PutsDebuggerer.print_engine = :p
|
118
222
|
# array = [1, [2, 3]]
|
119
223
|
# pd array
|
120
224
|
#
|
@@ -122,28 +226,15 @@ module PutsDebuggerer
|
|
122
226
|
#
|
123
227
|
# [PD] /Users/User/example.rb:5
|
124
228
|
# > pd array
|
125
|
-
# => [
|
126
|
-
# [0] 1,
|
127
|
-
# [1] [
|
128
|
-
# [0] 2,
|
129
|
-
# [1] 3
|
130
|
-
# ]
|
229
|
+
# => [1, [2, 3]]
|
131
230
|
# ]
|
132
231
|
attr_reader :print_engine
|
133
232
|
|
134
233
|
def print_engine=(engine)
|
135
234
|
if engine.nil?
|
136
|
-
|
137
|
-
if Object.respond_to?(:ap, 'Hello')
|
138
|
-
@print_engine = lambda {|object| Rails.logger.ap(object)}
|
139
|
-
else
|
140
|
-
@print_engine = lambda {|object| Rails.logger.debug(object)}
|
141
|
-
end
|
142
|
-
else
|
143
|
-
@print_engine = method(:ap).name rescue PRINT_ENGINE_DEFAULT
|
144
|
-
end
|
235
|
+
@print_engine = Object.const_defined?(:AwesomePrint) ? PRINT_ENGINE_DEFAULT : :p
|
145
236
|
elsif engine.is_a?(Proc)
|
146
|
-
@print_engine = engine
|
237
|
+
@print_engine = engine
|
147
238
|
else
|
148
239
|
@print_engine = method(engine).name rescue raise(PRINT_ENGINE_MESSAGE_INVALID)
|
149
240
|
end
|
@@ -173,12 +264,14 @@ module PutsDebuggerer
|
|
173
264
|
# * :announcer (string)
|
174
265
|
# * :caller (array)
|
175
266
|
# * :file (string)
|
267
|
+
# * :wrapper (string)
|
176
268
|
# * :footer (string)
|
177
269
|
# * :header (string)
|
178
270
|
# * :line_number (string)
|
179
271
|
# * :pd_expression (string)
|
180
272
|
# * :object (object)
|
181
273
|
# * :object_printer (proc)
|
274
|
+
# * :source_line_count (integer)
|
182
275
|
#
|
183
276
|
# NOTE: data for :object_printer is not a string, yet a proc that must
|
184
277
|
# be called to output value. It is a proc as it automatically handles usage
|
@@ -256,8 +349,11 @@ module PutsDebuggerer
|
|
256
349
|
def options
|
257
350
|
{
|
258
351
|
header: header,
|
352
|
+
wrapper: wrapper,
|
259
353
|
footer: footer,
|
354
|
+
printer: printer,
|
260
355
|
print_engine: print_engine,
|
356
|
+
source_line_count: source_line_count,
|
261
357
|
app_path: app_path,
|
262
358
|
announcer: announcer,
|
263
359
|
formatter: formatter,
|
@@ -340,15 +436,15 @@ module PutsDebuggerer
|
|
340
436
|
@run_at_global_number = value
|
341
437
|
end
|
342
438
|
|
343
|
-
def init_run_at_global_number
|
439
|
+
def init_run_at_global_number
|
344
440
|
@run_at_global_number = 1
|
345
441
|
end
|
346
442
|
|
347
|
-
def increment_run_at_global_number
|
443
|
+
def increment_run_at_global_number
|
348
444
|
@run_at_global_number += 1
|
349
445
|
end
|
350
446
|
|
351
|
-
def reset_run_at_global_number
|
447
|
+
def reset_run_at_global_number
|
352
448
|
@run_at_global_number = nil
|
353
449
|
end
|
354
450
|
|
@@ -375,12 +471,15 @@ module PutsDebuggerer
|
|
375
471
|
end
|
376
472
|
end
|
377
473
|
|
378
|
-
|
379
|
-
PutsDebuggerer.
|
380
|
-
PutsDebuggerer.
|
474
|
+
# setting values to nil defaults them properly
|
475
|
+
PutsDebuggerer.printer = nil
|
476
|
+
PutsDebuggerer.print_engine = nil
|
477
|
+
PutsDebuggerer.announcer = nil
|
478
|
+
PutsDebuggerer.formatter = nil
|
381
479
|
PutsDebuggerer.app_path = nil
|
382
480
|
PutsDebuggerer.caller = nil
|
383
481
|
PutsDebuggerer.run_at = nil
|
482
|
+
PutsDebuggerer.source_line_count = nil
|
384
483
|
|
385
484
|
# Prints object with bonus info such as file name, line number and source
|
386
485
|
# expression. Optionally prints out header and footer.
|
@@ -411,13 +510,24 @@ PutsDebuggerer.run_at = nil
|
|
411
510
|
# > pd "Show me the source of the bug: #{bug}"
|
412
511
|
# => "Show me the source of the bug: beattle"
|
413
512
|
# [PD] /Users/User/finance_calculator_app/pd_test.rb:4 "What line number am I?"
|
414
|
-
def pd(
|
513
|
+
def pd(*objects)
|
514
|
+
options = objects.delete_at(-1) if objects.size > 1 && objects.last.is_a?(Hash)
|
515
|
+
object = objects.compact.size > 1 ? objects : objects.first
|
415
516
|
run_at = ((options && options[:run_at]) || PutsDebuggerer.run_at)
|
416
517
|
|
417
518
|
if __run_pd__(object, run_at)
|
418
519
|
__with_pd_options__(options) do |print_engine_options|
|
419
|
-
|
520
|
+
run_number = PutsDebuggerer.run_at_global_number || PutsDebuggerer.run_at_number(object, run_at)
|
521
|
+
formatter_pd_data = __build_pd_data__(object, print_engine_options, PutsDebuggerer.source_line_count, run_number) #depth adds build method
|
522
|
+
stdout = $stdout
|
523
|
+
$stdout = sio = StringIO.new
|
420
524
|
PutsDebuggerer.formatter.call(formatter_pd_data)
|
525
|
+
$stdout = stdout
|
526
|
+
if PutsDebuggerer.printer.is_a?(Proc)
|
527
|
+
PutsDebuggerer.printer.call(sio.string)
|
528
|
+
else
|
529
|
+
send(PutsDebuggerer.send(:printer), sio.string)
|
530
|
+
end
|
421
531
|
end
|
422
532
|
end
|
423
533
|
|
@@ -429,20 +539,20 @@ def __run_pd__(object, run_at)
|
|
429
539
|
if run_at.nil?
|
430
540
|
run_pd = true
|
431
541
|
else
|
432
|
-
if PutsDebuggerer.
|
433
|
-
if PutsDebuggerer.run_at_number(object, run_at).nil?
|
434
|
-
PutsDebuggerer.init_run_at_number(object, run_at)
|
435
|
-
else
|
436
|
-
PutsDebuggerer.increment_run_at_number(object, run_at)
|
437
|
-
end
|
438
|
-
run_number = PutsDebuggerer.run_at_number(object, run_at)
|
439
|
-
else
|
542
|
+
if PutsDebuggerer.run_at?
|
440
543
|
if PutsDebuggerer.run_at_global_number.nil?
|
441
544
|
PutsDebuggerer.init_run_at_global_number
|
442
545
|
else
|
443
546
|
PutsDebuggerer.increment_run_at_global_number
|
444
547
|
end
|
445
548
|
run_number = PutsDebuggerer.run_at_global_number
|
549
|
+
else
|
550
|
+
if PutsDebuggerer.run_at_number(object, run_at).nil?
|
551
|
+
PutsDebuggerer.init_run_at_number(object, run_at)
|
552
|
+
else
|
553
|
+
PutsDebuggerer.increment_run_at_number(object, run_at)
|
554
|
+
end
|
555
|
+
run_number = PutsDebuggerer.run_at_number(object, run_at)
|
446
556
|
end
|
447
557
|
if run_at.is_a?(Integer)
|
448
558
|
run_pd = true if run_at == run_number
|
@@ -466,7 +576,7 @@ end
|
|
466
576
|
#
|
467
577
|
# prints out `3`
|
468
578
|
def __caller_line_number__(caller_depth=0)
|
469
|
-
caller[caller_depth][PutsDebuggerer::STACK_TRACE_CALL_LINE_NUMBER_REGEX, 1].to_i
|
579
|
+
caller[caller_depth] && caller[caller_depth][PutsDebuggerer::STACK_TRACE_CALL_LINE_NUMBER_REGEX, 1].to_i
|
470
580
|
end
|
471
581
|
|
472
582
|
# Provides caller file starting 1 level above caller of
|
@@ -479,7 +589,7 @@ end
|
|
479
589
|
#
|
480
590
|
# prints out `lib/example.rb`
|
481
591
|
def __caller_file__(caller_depth=0)
|
482
|
-
caller[caller_depth][PutsDebuggerer::STACK_TRACE_CALL_SOURCE_FILE_REGEX, 1]
|
592
|
+
caller[caller_depth] && caller[caller_depth][PutsDebuggerer::STACK_TRACE_CALL_SOURCE_FILE_REGEX, 1]
|
483
593
|
end
|
484
594
|
|
485
595
|
|
@@ -491,22 +601,28 @@ end
|
|
491
601
|
# puts __caller_source_line__
|
492
602
|
#
|
493
603
|
# prints out `puts __caller_source_line__`
|
494
|
-
def __caller_source_line__(caller_depth=0, source_file=nil, source_line_number=nil)
|
604
|
+
def __caller_source_line__(caller_depth=0, source_line_count=nil, source_file=nil, source_line_number=nil)
|
495
605
|
source_line_number ||= __caller_line_number__(caller_depth+1)
|
496
606
|
source_file ||= __caller_file__(caller_depth+1)
|
497
|
-
source_line =
|
607
|
+
source_line = ''
|
498
608
|
if source_file == '(irb)'
|
499
609
|
source_line = conf.io.line(source_line_number)
|
500
610
|
else
|
501
611
|
f = File.new(source_file)
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
612
|
+
if f.respond_to?(:readline) # Opal Ruby Compatibility
|
613
|
+
source_lines = []
|
614
|
+
begin
|
615
|
+
while f.lineno < source_line_number + source_line_count
|
616
|
+
file_line_number = f.lineno + 1
|
617
|
+
file_line = f.readline
|
618
|
+
if file_line_number >= source_line_number && file_line_number < source_line_number + source_line_count
|
619
|
+
source_lines << file_line
|
620
|
+
end
|
621
|
+
end
|
622
|
+
rescue EOFError
|
623
|
+
# Done
|
509
624
|
end
|
625
|
+
source_line = source_lines.join(' '*5)
|
510
626
|
end
|
511
627
|
end
|
512
628
|
source_line
|
@@ -523,16 +639,19 @@ def __with_pd_options__(options=nil)
|
|
523
639
|
PutsDebuggerer.options = permanent_options
|
524
640
|
end
|
525
641
|
|
526
|
-
def __build_pd_data__(object, print_engine_options=nil)
|
642
|
+
def __build_pd_data__(object, print_engine_options=nil, source_line_count=nil, run_number=nil)
|
527
643
|
depth = PutsDebuggerer::CALLER_DEPTH_ZERO
|
528
644
|
pd_data = {
|
529
645
|
announcer: PutsDebuggerer.announcer,
|
530
|
-
file: __caller_file__(depth)
|
646
|
+
file: __caller_file__(depth)&.sub(PutsDebuggerer.app_path.to_s, ''),
|
531
647
|
line_number: __caller_line_number__(depth),
|
532
|
-
pd_expression: __caller_pd_expression__(depth),
|
648
|
+
pd_expression: __caller_pd_expression__(depth, source_line_count),
|
649
|
+
run_number: run_number,
|
533
650
|
object: object,
|
534
651
|
object_printer: lambda do
|
535
|
-
if
|
652
|
+
if object.is_a?(Exception) && object.respond_to?(:full_message)
|
653
|
+
puts object.full_message
|
654
|
+
elsif PutsDebuggerer.print_engine.is_a?(Proc)
|
536
655
|
PutsDebuggerer.print_engine.call(object)
|
537
656
|
else
|
538
657
|
if print_engine_options.to_h.empty?
|
@@ -549,6 +668,7 @@ def __build_pd_data__(object, print_engine_options=nil)
|
|
549
668
|
pd_data[:caller] = caller[start_depth..caller_depth].to_a
|
550
669
|
end
|
551
670
|
pd_data[:header] = PutsDebuggerer.header if PutsDebuggerer.header?
|
671
|
+
pd_data[:wrapper] = PutsDebuggerer.wrapper if PutsDebuggerer.wrapper?
|
552
672
|
pd_data[:footer] = PutsDebuggerer.footer if PutsDebuggerer.footer?
|
553
673
|
pd_data
|
554
674
|
end
|
@@ -557,9 +677,9 @@ def __format_pd_expression__(expression, object)
|
|
557
677
|
"\n > #{expression}\n =>"
|
558
678
|
end
|
559
679
|
|
560
|
-
def __caller_pd_expression__(depth=0)
|
680
|
+
def __caller_pd_expression__(depth=0, source_line_count=nil)
|
561
681
|
# Caller Source Line Depth 2 = 1 to pd method + 1 to caller
|
562
|
-
source_line = __caller_source_line__(depth+1)
|
682
|
+
source_line = __caller_source_line__(depth+1, source_line_count)
|
563
683
|
source_line = __extract_pd_expression__(source_line)
|
564
684
|
source_line = source_line.gsub(/(^'|'$)/, '"') if source_line.start_with?("'") && source_line.end_with?("'")
|
565
685
|
source_line = source_line.gsub(/(^\(|\)$)/, '') if source_line.start_with?("(") && source_line.end_with?(")")
|
@@ -574,5 +694,5 @@ end
|
|
574
694
|
#
|
575
695
|
# outputs `(x=1)`
|
576
696
|
def __extract_pd_expression__(source_line)
|
577
|
-
source_line.strip
|
697
|
+
source_line.to_s.strip
|
578
698
|
end
|
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: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,86 +67,111 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: jeweler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.3.9
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.3.9
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.
|
89
|
+
version: 2.1.4
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.
|
96
|
+
version: 2.1.4
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: coveralls
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.8.
|
103
|
+
version: 0.8.23
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.8.
|
110
|
+
version: 0.8.23
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
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
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: undercover
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.3.4
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
152
|
+
version: 0.3.4
|
125
153
|
description: |
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
In other words, puts_debuggerer is a Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.
|
131
|
-
|
132
|
-
Partially inspired (only partially ;) by this blog post:
|
133
|
-
https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html
|
134
|
-
(Credit to Tenderlove.)
|
154
|
+
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.
|
155
|
+
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.
|
156
|
+
Partially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)
|
135
157
|
email: andy.am@gmail.com
|
136
158
|
executables: []
|
137
159
|
extensions: []
|
138
160
|
extra_rdoc_files:
|
161
|
+
- CHANGELOG.md
|
139
162
|
- LICENSE.txt
|
140
163
|
- README.md
|
141
164
|
files:
|
165
|
+
- CHANGELOG.md
|
142
166
|
- LICENSE.txt
|
143
167
|
- README.md
|
168
|
+
- VERSION
|
144
169
|
- lib/puts_debuggerer.rb
|
145
170
|
homepage: http://github.com/AndyObtiva/puts_debuggerer
|
146
171
|
licenses:
|
147
172
|
- MIT
|
148
173
|
metadata: {}
|
149
|
-
post_install_message:
|
174
|
+
post_install_message:
|
150
175
|
rdoc_options: []
|
151
176
|
require_paths:
|
152
177
|
- lib
|
@@ -161,9 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
186
|
- !ruby/object:Gem::Version
|
162
187
|
version: '0'
|
163
188
|
requirements: []
|
164
|
-
|
165
|
-
|
166
|
-
signing_key:
|
189
|
+
rubygems_version: 3.1.2
|
190
|
+
signing_key:
|
167
191
|
specification_version: 4
|
168
192
|
summary: Ruby library for improved puts debugging, automatically displaying bonus
|
169
193
|
useful information such as source line number and source code.
|