puts_debuggerer 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +33 -9
- data/VERSION +1 -1
- data/lib/puts_debuggerer.rb +9 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd0277b6264431cf1d1e83db01166e95107cbbc6dc45b0eff9adac444650372
|
4
|
+
data.tar.gz: 31276c4cb27085ccd264897fa7305e7fe1740d8f6a4a0901c73e1e2ec179c458
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96cb360a70d4118c0fc63a17b0d5d1b883f40177a8765efe2a9e135afe872686ee4090ba5e8bb5c456077545225b6a92737d2de1c315e0b3ce6184ee53ef9ac1
|
7
|
+
data.tar.gz: 751582b302545b1f4bea4fb7704125e0eb3e95057c4d0a3435042b3b2cddf2d13026f60318ef0da777c72f6b004479e8f64d0fc78f374b19ad9a8db9a78ed494
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Basic Example:
|
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
# /Users/User/trivia_app.rb # line 1
|
21
|
-
require '
|
21
|
+
require 'pd' # line 2
|
22
22
|
bug_or_band = 'beattle' # line 3
|
23
23
|
pd bug_or_band # line 4
|
24
24
|
```
|
@@ -302,7 +302,7 @@ There are many more options and powerful features in [puts_debuggerer](https://r
|
|
302
302
|
Add the following to bundler's `Gemfile`.
|
303
303
|
|
304
304
|
```ruby
|
305
|
-
gem 'puts_debuggerer', '~> 0.10.
|
305
|
+
gem 'puts_debuggerer', '~> 0.10.1'
|
306
306
|
```
|
307
307
|
|
308
308
|
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.
|
@@ -312,18 +312,35 @@ This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you m
|
|
312
312
|
Or manually install and require library.
|
313
313
|
|
314
314
|
```bash
|
315
|
-
gem install puts_debuggerer -v0.10.
|
315
|
+
gem install puts_debuggerer -v0.10.1
|
316
316
|
```
|
317
317
|
|
318
318
|
```ruby
|
319
319
|
require 'puts_debuggerer'
|
320
320
|
```
|
321
321
|
|
322
|
+
Or the shorter form (often helpful to quickly troubleshoot an app):
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
require 'pd'
|
326
|
+
```
|
327
|
+
|
328
|
+
|
322
329
|
### Awesome Print
|
323
330
|
|
324
|
-
puts_debuggerer comes with [awesome_print](https://github.com/awesome-print/awesome_print).
|
331
|
+
[puts_debuggerer](https://rubygems.org/gems/puts_debuggerer) comes with [awesome_print](https://github.com/awesome-print/awesome_print).
|
332
|
+
|
333
|
+
It is the default `PutsDebuggerer.print_engine`
|
334
|
+
|
335
|
+
Still, if you do not need it, you may disable by setting `PutsDebuggerer.print_engine` to another value. Example:
|
336
|
+
|
337
|
+
```ruby
|
338
|
+
PutsDebuggerer.print_engine = :puts
|
339
|
+
```
|
325
340
|
|
326
|
-
|
341
|
+
If you also avoid requiring 'awesome_print', PutsDebuggerer won't require it either if it sees that you have a different `print_engine`
|
342
|
+
|
343
|
+
You may also avoid requiring in Bundler `Gemfile` with `require: false`:
|
327
344
|
|
328
345
|
```ruby
|
329
346
|
gem "awesome_print", require: false
|
@@ -381,11 +398,18 @@ Output:
|
|
381
398
|
=> "Hello Robert"
|
382
399
|
```
|
383
400
|
|
384
|
-
Alternatively, you may want to use `object.pd_inspect` (or alias `obj.pdi`) to
|
385
|
-
return formatted string without printing.
|
386
|
-
|
387
401
|
Happy puts_debuggerering!
|
388
402
|
|
403
|
+
#### `pd_inspect` kernel method
|
404
|
+
|
405
|
+
You may want to just return the string produced by the `pd` method without printing it.
|
406
|
+
|
407
|
+
In that case, you may use the `pd` alternative to `object.inspect`:
|
408
|
+
- `object.pd_inspect`
|
409
|
+
- `obj.pdi` (shorter alias)
|
410
|
+
|
411
|
+
This returns the `pd` formatted string without printing to the terminal or log files.
|
412
|
+
|
389
413
|
#### Ruby Logger and Logging::Logger
|
390
414
|
|
391
415
|
Ruby Logger and Logging::Logger (from [logging gem](https://github.com/TwP/logging)) are supported as [printers](#putsdebuggererprinter) (learn more under [PutsDebuggerer#printer](#putsdebuggererprinter)).
|
@@ -957,7 +981,7 @@ Prints out `puts __caller_source_line__`
|
|
957
981
|
- IRB
|
958
982
|
- Rails Console.
|
959
983
|
|
960
|
-
It provides partial-compatibility for [Opal Ruby](https://opalrb.com/), with everything working except these features:
|
984
|
+
It provides partial-compatibility for [Opal Ruby](https://opalrb.com/) by excluding AwesomePrint (opting for `:p` printer instead), with everything working except these features:
|
961
985
|
- File name display
|
962
986
|
- Line number display
|
963
987
|
- Source code call display
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.1
|
data/lib/puts_debuggerer.rb
CHANGED
@@ -262,19 +262,23 @@ module PutsDebuggerer
|
|
262
262
|
# > pd array
|
263
263
|
# => [1, [2, 3]]
|
264
264
|
# ]
|
265
|
-
|
265
|
+
def print_engine
|
266
|
+
if @print_engine.nil?
|
267
|
+
require 'awesome_print' if RUBY_PLATFORM != 'opal'
|
268
|
+
@print_engine = print_engine_default
|
269
|
+
end
|
270
|
+
@print_engine
|
271
|
+
end
|
266
272
|
|
267
273
|
def print_engine=(engine)
|
268
|
-
if engine.nil?
|
269
|
-
@print_engine = print_engine_default
|
270
|
-
elsif engine.is_a?(Proc)
|
274
|
+
if engine.is_a?(Proc) || engine.nil?
|
271
275
|
@print_engine = engine
|
272
276
|
else
|
273
277
|
@print_engine = method(engine).name rescue raise(PRINT_ENGINE_MESSAGE_INVALID)
|
274
278
|
end
|
275
279
|
end
|
276
280
|
|
277
|
-
def print_engine_default
|
281
|
+
def print_engine_default
|
278
282
|
Object.const_defined?(:AwesomePrint) ? PRINT_ENGINE_DEFAULT : :p
|
279
283
|
end
|
280
284
|
|
@@ -530,7 +534,6 @@ PutsDebuggerer.source_line_count = nil
|
|
530
534
|
# => "Show me the source of the bug: beattle"
|
531
535
|
# [PD] /Users/User/finance_calculator_app/pd_test.rb:4 "What line number am I?"
|
532
536
|
def pd(*objects)
|
533
|
-
require 'awesome_print' if ['awesome_print', 'ap'].include?(PutsDebuggerer.print_engine.to_s) && RUBY_PLATFORM != 'opal'
|
534
537
|
options = PutsDebuggerer.determine_options(objects) || {}
|
535
538
|
object = PutsDebuggerer.determine_object(objects)
|
536
539
|
run_at = PutsDebuggerer.determine_run_at(options)
|
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.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|