Vim-ruby-debugger breakpoints with Pry in Vim

Right now, when I want a breakpoint in vim or Sublime Text, I throw the following line into the code:

binding.pry if Rails.env.test? 

Pry (and its related plugins ) provide a nice environment for doing Ruby interactive debugging from the command line.

However, adding the actual code to my projects to create each breakpoint (and remembering to delete that code when committing) can be cumbersome.

I like that vim-ruby-debugger does this in terms of removing the visual breakpoint in the editor without actually changing the source code of the project, I had some problems making it work in the context of my specifications (and I would rather just use the dots breakpoint Pry) first).

So, the question is whether it is possible to drop the binding.pry link into the file, so that an editor such as Vim (or Sublime Text, etc.) will pick it up and react accordingly while debugging without the actual line being included in the source the code?

+7
source share
4 answers

You can use Git Hooks to prevent bad commit, for example leaving binding.pry in your code.

This article explains how to do this http://www.launchacademy.com/blog/posts/automatically-prevent-some-bad-git-commits

Here you are another good post about this http://www.ryanmcg.com/2013/8/12/another-forgotten-binding-pry/

I also totally agree that PRY is an exceptional Gem.

+3
source

http://www.vim.org/scripts/script.php?script_id=4451 seems to solve what you want. I have not tried this personally, but I am going to :).

0
source

First off, PRY is an amazing tool, and I'm glad you found it.

Is it possible to remove the binding.pry link to a file ... without actually linking the line in the source code?

You need to drop the binding.pry file directly in the source code so that it gets into the queue for testing and playback. FYI, if you put the binding.pry file in your specification file, it will open pry in the specification file that it does not reference.

You can try better_erros with binding_of_caller, and when you start the fail-safe rails server, a) it gives you a better sense of error and gives you a direct link to the error.

0
source

I do not use pry when debugging, I just use a regular debugger if necessary. However, here is my vim workflow.

  • I have a vim macro saved by "@d" that inserts the following code under any line I am in; a "debugger" is required; debugger 0 This is very convenient to insert.

  • To avoid executing debugger lines, I set the git hook (pre-commit), which checks if commit includes these lines (grep)

http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes

0
source

All Articles