puts_debuggerer 0.5.1 → 0.6.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 +4 -4
- data/README.md +42 -30
- data/lib/puts_debuggerer.rb +4 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69b66965c2e8e736c45656acefa919c9acc29ff0
|
4
|
+
data.tar.gz: ee73731c57f102f7df59f35b7a015b7066f5d2f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d79dc41961f12555fa1cb3ca9661f513561657bb7079165dd1c4ebd9a4cd777431bc4eedf8a6f046dc35e832711a536b0d443273fa6164b4581bf2f4bc46941
|
7
|
+
data.tar.gz: c816c82429a147a538b43d19fbc3d0fb7c00b0e7cc812421b74c7b49ea3175358b6f52575ab183fd117e58eeeb05d39d90b160e9cc1f01b3523e7216b3170d9a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# puts_debuggerer v0.
|
1
|
+
# puts_debuggerer v0.6.0
|
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)
|
@@ -10,7 +10,7 @@ legitimate thing?!!
|
|
10
10
|
|
11
11
|
Enter puts_debuggerer. A guilt-free puts debugger Ruby gem FTW!
|
12
12
|
|
13
|
-
In other words, puts_debuggerer is a Ruby library
|
13
|
+
In other words, puts_debuggerer is a Ruby library that provides improved puts debugging, automatically displaying bonus useful information such as source line numbers and source code, among many other goodies (mentioned in the README.)
|
14
14
|
|
15
15
|
Partially inspired (only partially ;) by this blog post:
|
16
16
|
https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html
|
@@ -25,7 +25,7 @@ Love PD?! Why not promote with [merchandise](https://www.zazzle.com/i+heart+pd+g
|
|
25
25
|
Add the following to bundler's `Gemfile`.
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem 'puts_debuggerer', '~> 0.
|
28
|
+
gem 'puts_debuggerer', '~> 0.6.0'
|
29
29
|
```
|
30
30
|
|
31
31
|
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,7 +35,7 @@ This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you m
|
|
35
35
|
Or manually install and require library.
|
36
36
|
|
37
37
|
```bash
|
38
|
-
gem install puts_debuggerer -v0.
|
38
|
+
gem install puts_debuggerer -v0.6.0
|
39
39
|
```
|
40
40
|
|
41
41
|
```ruby
|
@@ -44,46 +44,58 @@ require 'puts_debuggerer'
|
|
44
44
|
|
45
45
|
### Usage
|
46
46
|
|
47
|
-
Simply invoke global `pd` method anywhere
|
48
|
-
number, and source code in addition to output (works even in IRB).
|
49
|
-
If the argument is a literal value with no interpolation, the print out is
|
50
|
-
simplified by not showing source code matching output.
|
47
|
+
Simply invoke global `pd` method anywhere in your code passing an object or an expression argument.
|
51
48
|
|
52
|
-
|
53
|
-
* [PD]
|
54
|
-
* file:line_number
|
55
|
-
* ruby expression.
|
56
|
-
|
57
|
-
This gives you the added benefit of easily removing your `pd` statements later
|
58
|
-
on.
|
59
|
-
|
60
|
-
This can easily be augmented with a print engine like [awesome_print](https://github.com/awesome-print/awesome_print) and
|
61
|
-
customized to format output differently as per options below.
|
62
|
-
|
63
|
-
Happy puts_debuggerering!
|
49
|
+
It will then provide helpful debugging information by printing the source file, line number, and source code in addition to output (works even in IRB).
|
64
50
|
|
65
51
|
Example Code:
|
66
52
|
|
67
53
|
```ruby
|
68
54
|
# /Users/User/finance_calculator_app/pd_test.rb # line 1
|
69
55
|
bug = 'beattle' # line 2
|
70
|
-
pd
|
71
|
-
pd "Show me the
|
72
|
-
pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 5
|
56
|
+
pd "Show me the source of the bug: #{bug}" # line 3
|
57
|
+
pd "Show me the result of the calculation: #{(12.0/3.0)}" # line 4
|
73
58
|
```
|
74
59
|
|
75
60
|
Example Printout:
|
76
61
|
|
77
62
|
```bash
|
78
|
-
[PD] /Users/User/finance_calculator_app/pd_test.rb:3
|
79
|
-
[PD] /Users/User/finance_calculator_app/pd_test.rb:4
|
63
|
+
[PD] /Users/User/finance_calculator_app/pd_test.rb:3
|
80
64
|
> pd "Show me the source of the bug: #{bug}"
|
81
65
|
=> "Show me the source of the bug: beattle"
|
82
|
-
[PD] /Users/User/finance_calculator_app/pd_test.rb:
|
66
|
+
[PD] /Users/User/finance_calculator_app/pd_test.rb:4
|
83
67
|
> pd "Show me the result of the calculation: #{(12.0/3.0)}"
|
84
68
|
=> "Show me the result of the calculation: 4.0"
|
85
69
|
```
|
86
70
|
|
71
|
+
Quickly locate printed lines using Find feature (e.g. CTRL+F) by looking for:
|
72
|
+
* [PD]
|
73
|
+
* file:line_number
|
74
|
+
* known ruby expression.
|
75
|
+
|
76
|
+
This gives you the added benefit of easily removing your `pd` statements later
|
77
|
+
on once done debugging.
|
78
|
+
|
79
|
+
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
|
+
|
81
|
+
Example Code:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
# /Users/User/greeting_app/pd_test.rb # line 1
|
85
|
+
name = 'Robert' # line 2
|
86
|
+
greeting = "Hello #{pd(name)}" # line 3
|
87
|
+
```
|
88
|
+
|
89
|
+
Example Printout:
|
90
|
+
|
91
|
+
```bash
|
92
|
+
[PD] /Users/User/greeting_app/pd_test.rb:3
|
93
|
+
> greeting = "Hello #{pd(name)}"
|
94
|
+
=> "Hello Robert"
|
95
|
+
```
|
96
|
+
|
97
|
+
Happy puts_debuggerering!
|
98
|
+
|
87
99
|
### Options
|
88
100
|
|
89
101
|
Options enable more data to be displayed with puts_debuggerer, such as the caller
|
@@ -144,16 +156,14 @@ If [Rails](rubyonrails.org) was detected, it is automatically defaulted to `Rail
|
|
144
156
|
PutsDebuggerer.app_path = File.join('/Users', 'User', 'finance_calculator_app') # line 2
|
145
157
|
bug = 'beattle' # line 3
|
146
158
|
pd "Show me the source of the bug: #{bug}" # line 4
|
147
|
-
pd 'What line number am I?' # line 5
|
148
159
|
```
|
149
160
|
|
150
161
|
Example Printout:
|
151
162
|
|
152
163
|
```bash
|
153
|
-
[PD] pd_test.rb:4
|
164
|
+
[PD] /pd_test.rb:4
|
154
165
|
> pd "Show me the source of the bug: #{bug}"
|
155
166
|
=> "Show me the source of the bug: beattle"
|
156
|
-
[PD] pd_test.rb:5 "What line number am I?"
|
157
167
|
```
|
158
168
|
|
159
169
|
#### `PutsDebuggerer.header`
|
@@ -395,7 +405,9 @@ Prints out `puts __caller_source_line__`
|
|
395
405
|
|
396
406
|
## Release Notes
|
397
407
|
|
398
|
-
* v0.
|
408
|
+
* v0.6.0: unofficial erb support, returning evaluated object/expression, removed static syntax support (replaced with header support)
|
409
|
+
* v0.5.1: support for print engine lambdas and smart defaults for leveraging Rails and AwesomePrint debuggers in Rails
|
410
|
+
* v0.5.0: custom formatter, caller backtrace, per-puts piecemeal options, and multi-line support
|
399
411
|
* v0.4.0: custom print engine (e.g. ap), custom announcer, and IRB support
|
400
412
|
* v0.3.0: header/footer support, multi-line printout, improved format
|
401
413
|
* v0.2.0: App path exclusion support, Rails root support, improved format
|
data/lib/puts_debuggerer.rb
CHANGED
@@ -311,7 +311,7 @@ def pd(object, options=nil)
|
|
311
311
|
formatter_pd_data = __build_pd_data__(object, print_engine_options) #depth adds build method
|
312
312
|
PutsDebuggerer.formatter.call(formatter_pd_data)
|
313
313
|
end
|
314
|
-
|
314
|
+
object
|
315
315
|
end
|
316
316
|
|
317
317
|
|
@@ -367,7 +367,7 @@ def __caller_source_line__(caller_depth=0, source_file=nil, source_line_number=n
|
|
367
367
|
f.each_line do |line|
|
368
368
|
if !done && f.lineno == source_line_number
|
369
369
|
source_line << line
|
370
|
-
done = true if Ripper.sexp_raw(source_line)
|
370
|
+
done = true if Ripper.sexp_raw(source_line) || source_line.include?('%>') #the last condition is for erb support (unofficial)
|
371
371
|
source_line_number+=1
|
372
372
|
end
|
373
373
|
end
|
@@ -417,8 +417,7 @@ def __build_pd_data__(object, print_engine_options=nil)
|
|
417
417
|
end
|
418
418
|
|
419
419
|
def __format_pd_expression__(expression, object)
|
420
|
-
#
|
421
|
-
expression == object.inspect.sub("\n$", '') ? "" : "\n > pd #{expression}\n =>"
|
420
|
+
"\n > #{expression}\n =>"
|
422
421
|
end
|
423
422
|
|
424
423
|
def __caller_pd_expression__(depth=0)
|
@@ -438,5 +437,5 @@ end
|
|
438
437
|
#
|
439
438
|
# outputs `(x=1)`
|
440
439
|
def __extract_pd_expression__(source_line)
|
441
|
-
source_line.strip
|
440
|
+
source_line.strip
|
442
441
|
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.6.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: 2017-07-
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|