puts_debuggerer 0.13.2 → 0.13.5
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 +14 -0
- data/README.md +30 -12
- data/VERSION +1 -1
- data/lib/puts_debuggerer/core_ext/kernel.rb +15 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cef89b14f7e9ae764d7231ddaa5ab880ccaacd5366cdde5db8cebf6096ef6ddc
|
4
|
+
data.tar.gz: 0ce08e74da428ede072d3d343e983a499f78939ddd5134ed262ca8505fb824d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f473268d3f34d3e12ce51152a9eb4e2295448a623c087705072101d15603da5792abc7d02d2eeb272fba4369727c273d9cc9cf5845cd3d36869bdbc7971b0da5
|
7
|
+
data.tar.gz: d91edb075e81269b9f3a7589cd2f84b0126ff0b9c66633d51cdca3829e25119051a00270fb194fe17c2a7a430c7c7b65d63696cf422162a944aeaf367c5d1d5f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.13.5
|
4
|
+
|
5
|
+
- Fix not printing source line in Rails app w/ Pry
|
6
|
+
- Note that Pry's compatibility (inside Pry) is experimental and fragile because Pry's API is not reliable
|
7
|
+
|
8
|
+
## 0.13.4
|
9
|
+
|
10
|
+
- Reverted change to default `printer` behavior from 0.13.3 to avoid causing a double-print to stdout as it turns out `puts` is not always needed since Rails redirects to standard out by default in `Rails.logger.debug` calls
|
11
|
+
|
12
|
+
## 0.13.3
|
13
|
+
|
14
|
+
- Update default `printer` behavior for Rails to always output via `puts` (not just in tests) in addition to `Rails.logger.debug`
|
15
|
+
- Update custom implementation of `caller` for Opal to accept args (optional `start` and `length` or alternatively `range`) just like the Ruby API
|
16
|
+
|
3
17
|
## 0.13.2
|
4
18
|
|
5
19
|
- Fix issue caused by MiniTest Rails having `IRB` constant declared despite being outside of IRB
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Puts Debuggerer (debugger-less debugging FTW)
|
2
|
+
## [Featured in State of the Art Rails 2021 Edition](https://github.com/DanielVartanov/state-of-the-art-rails/tree/3d538fc6ba5287ce6c1ed15ced598ce19bbe81b5)
|
2
3
|
[](http://badge.fury.io/rb/puts_debuggerer)
|
3
4
|
[](https://travis-ci.org/AndyObtiva/puts_debuggerer)
|
4
5
|
[](https://coveralls.io/github/AndyObtiva/puts_debuggerer?branch=master)
|
@@ -317,20 +318,28 @@ There are many more options and features in [puts_debuggerer](https://rubygems.o
|
|
317
318
|
|
318
319
|
### Option 1: Bundler
|
319
320
|
|
321
|
+
This is the recommended way for installing in [Rails](rubyonrails.org) apps in addition to configuring the [`app_path` option](#putsdebuggererapp_path).
|
322
|
+
|
320
323
|
Add the following to bundler's `Gemfile`.
|
321
324
|
|
322
325
|
```ruby
|
323
|
-
gem 'puts_debuggerer', '~> 0.13.
|
326
|
+
gem 'puts_debuggerer', '~> 0.13.5'
|
324
327
|
```
|
325
328
|
|
326
|
-
|
329
|
+
Run:
|
330
|
+
|
331
|
+
```
|
332
|
+
bundle
|
333
|
+
```
|
334
|
+
|
335
|
+
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.
|
327
336
|
|
328
337
|
### Option 2: Manual
|
329
338
|
|
330
339
|
Or manually install and require library.
|
331
340
|
|
332
341
|
```bash
|
333
|
-
gem install puts_debuggerer -v0.13.
|
342
|
+
gem install puts_debuggerer -v0.13.5
|
334
343
|
```
|
335
344
|
|
336
345
|
```ruby
|
@@ -388,7 +397,7 @@ Output:
|
|
388
397
|
=> "Show me the result of the calculation: 4.0"
|
389
398
|
```
|
390
399
|
|
391
|
-
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
|
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).
|
392
401
|
|
393
402
|
Second, quickly locate printed lines using the Find feature (e.g. CTRL+F) by looking for:
|
394
403
|
* [PD]
|
@@ -483,8 +492,15 @@ Details about all the available options are included below.
|
|
483
492
|
#### `PutsDebuggerer.app_path`
|
484
493
|
(default = `nil`)
|
485
494
|
|
486
|
-
Sets absolute application path. Makes `pd` file output relative to it.
|
487
|
-
|
495
|
+
Sets absolute application path. Makes `pd` file path output relative to it.
|
496
|
+
|
497
|
+
In [Rails](rubyonrails.org), you can add the following code to a `config/initializers/puts_debuggerer_options.rb` file to make all output relative to [Rails](rubyonrails.org) application path:
|
498
|
+
|
499
|
+
```ruby
|
500
|
+
PutsDebuggerer.app_path = Rails.root.to_s
|
501
|
+
```
|
502
|
+
|
503
|
+
Example:
|
488
504
|
|
489
505
|
```ruby
|
490
506
|
# /Users/User/finance_calculator_app/pd_test.rb # line 1
|
@@ -747,19 +763,21 @@ lambda do |output|
|
|
747
763
|
end
|
748
764
|
```
|
749
765
|
|
750
|
-
Example
|
766
|
+
Example of adding the following code to `config/initializers/puts_debuggerer_options.rb`:
|
751
767
|
|
752
768
|
```ruby
|
753
|
-
# File Name: /Users/
|
754
|
-
PutsDebuggerer.printer = lambda
|
769
|
+
# File Name: /Users/user/railsapp/config/initializers/puts_debuggerer_options.rb
|
770
|
+
PutsDebuggerer.printer = lambda do |output|
|
771
|
+
puts output
|
772
|
+
end
|
755
773
|
str = "Hello"
|
756
774
|
pd str
|
757
775
|
```
|
758
776
|
|
759
|
-
Prints out in
|
777
|
+
Prints out the following in standard out stream only (not in log files):
|
760
778
|
|
761
779
|
```bash
|
762
|
-
[PD] /Users/
|
780
|
+
[PD] /Users/user/railsapp/config/initializers/puts_debuggerer_options.rb:6
|
763
781
|
> pd str
|
764
782
|
=> Hello
|
765
783
|
```
|
@@ -1060,7 +1078,7 @@ Prints out `puts __caller_source_line__`
|
|
1060
1078
|
- [Ruby](https://www.ruby-lang.org/en/)
|
1061
1079
|
- [JRuby](https://www.jruby.org/)
|
1062
1080
|
- IRB (including Rails Console)
|
1063
|
-
- Pry
|
1081
|
+
- Pry (experimental and fragile because Pry's API is not reliable)
|
1064
1082
|
|
1065
1083
|
### Opal Ruby
|
1066
1084
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.13.
|
1
|
+
0.13.5
|
@@ -88,11 +88,23 @@ module Kernel
|
|
88
88
|
|
89
89
|
# Implement caller backtrace method in Opal since it returns an empty array in Opal v1
|
90
90
|
if RUBY_ENGINE == 'opal'
|
91
|
-
def caller
|
91
|
+
def caller(*args)
|
92
|
+
dup_args = args.dup
|
93
|
+
start = args.shift if args.first.is_a?(Integer)
|
94
|
+
length = args.shift if args.first.is_a?(Integer)
|
95
|
+
range = args.shift if args.first.is_a?(Range)
|
96
|
+
if range
|
97
|
+
start = range.begin
|
98
|
+
length = range.end - start
|
99
|
+
end
|
92
100
|
begin
|
93
101
|
raise 'error'
|
94
102
|
rescue => e
|
95
|
-
e.backtrace
|
103
|
+
the_backtrace = e.backtrace
|
104
|
+
start ||= 0
|
105
|
+
start = 2 + start
|
106
|
+
length ||= the_backtrace.size - start
|
107
|
+
the_backtrace[start, length]
|
96
108
|
end
|
97
109
|
end
|
98
110
|
end
|
@@ -144,7 +156,7 @@ module Kernel
|
|
144
156
|
source_line_number ||= __caller_line_number__(caller_depth+1)
|
145
157
|
source_file ||= __caller_file__(caller_depth+1)
|
146
158
|
source_line = ''
|
147
|
-
if defined?(Pry)
|
159
|
+
if defined?(Pry) && source_file.include?('(pry)')
|
148
160
|
@pry_instance ||= Pry.new
|
149
161
|
source_line = Pry::Command::Hist.new(pry_instance: @pry_instance).call.instance_variable_get(:@buffer).split("\n")[source_line_number - 1] # TODO handle multi-lines in source_line_count
|
150
162
|
elsif defined?(IRB) && TOPLEVEL_BINDING.receiver.respond_to?(:conf)
|
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.13.
|
4
|
+
version: 0.13.5
|
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: 2022-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.5
|
33
|
+
version: '3.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.5
|
40
|
+
version: '3.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec-mocks
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.5
|
47
|
+
version: '3.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.5
|
54
|
+
version: '3.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
209
|
+
rubygems_version: 3.3.1
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: Ruby library for improved puts debugging, automatically displaying bonus
|