开发者

Ruby Debugging Open Source Libraries

开发者 https://www.devze.com 2023-01-10 10:03 出处:网络
I would like to debug and possibly contribute to some open source gems but am fairly new to Ruby and开发者_高级运维 Rails. What is the best way to go in and start setting breakpoints, etc?

I would like to debug and possibly contribute to some open source gems but am fairly new to Ruby and开发者_高级运维 Rails. What is the best way to go in and start setting breakpoints, etc?

Right now I just use ruby-debug for my own code and inspect variables mostly.


you need the ruby-debugger gem. Make sure you have have rubygems installed, then do

gem install ruby-debug

Then, add the line

require 'ruby-debug'

to your sourcecode to load the library, and add the keyword 'debugger' wherever you want to set a breakpoint. Now, whenever you call the code in question, it'll drop to the debugging console when it reaches the breakpoint - press h to see a list of options to see what you can do from there. Obviously, remember to remove your breakpoints and the require statement after you're done!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号