timhwang21.gitbook.io
Github
Search…
timhwang21.gitbook.io
Intro
Blog
2022
2021
2020
2019
CLI
Git
Shell
Vim
Tools
Programming
React
Typescript
Ruby
Pry
RSpec
Rails
Databases
Personal
Uses
Github
Medium
LinkedIn
Photography
Powered By
GitBook
Pry
Pry tricks
binding.pry
in external code
Simply monkey patch the method that you are interested in debugging:
1
def
SomeGem
::
method
2
require
'pry'
3
binding
.
pry
4
super
5
end
Copied!
You can even do this automatically for a list of methods you are interested in:
1
[
:foo
,
:bar
,
:baz
].
each
do
|
cb
|
2
define_method
cb
do
3
require
'pry'
4
binding
.
pry
5
super
6
end
7
end
Copied!
Get filtered stack trace
1
# at breakpoint
2
caller
.
select
{
|
line
|
line
.
starts_with
?
'/your-app-dir'
}
Copied!
Programming - Previous
Ruby
Next
RSpec
Last modified
7mo ago
Copy link
Contents
binding.pry in external code
Get filtered stack trace