Using a gem named pry you can easily inspect the state of your web application while it's running with the
Let's see how.
Let's start by adding pry to your Gemfile.
(Don't forget to
bundle install afterwards)
Then in your config.ru you just need to require pry-remote.
Next let's go to our Sinatra app, and put
binding.remote_pry wherever it is you want to start your pry session.
get '/' do
# some really complicated and convoluted code that makes your head hurt
Now just hit the
/ route on your application.
You will notice that the browser will hang without rendering the page, that's because a pry-remote session was started.
To access it go to your command line and type:
From: /Users/locks/repo/api.rb @ line 15 self.GET /:
11: get '/' do
12: # some really complicated and convoluted code that makes your head hurt
=> 15: binding.remote_pry
And now you're ready to have fun!
pry-debugger - full-blown debugger inside your pry session.
pry-rescue - starts a pry session whenever an exception is thrown.