jkaihsu
5/8/2013 - 5:34 AM

debugger.md

#Debugger Gem


Documentation:
https://github.com/cldwalker/debugger

###Environment Requirements gem install debugger

Add to environment:
require 'debugger'
gem 'debugger'

###Commands

set autoeval
shotgun -d


list
s - step into
n - next
c - continue

###Example

(rdb:1) set autoeval
autoeval is on
(rdb:1) list
[4, 13] in /Users/apprentice/Desktop/twitter_oauth/app/controllers/index.rb
   4  
   5  get '/sign_in' do
   6    # the `request_token` method is defined in `app/helpers/oauth.rb`
   7    puts "this is the key"
   8    debugger
=> 9    puts ENV['TWITTER_KEY']
   10    puts ENV['TWITTER_SECRET']
   11    redirect request_token.authorize_url
   12  end
   13  
(rdb:1) n
RekHFqVzXeKmKWH91l37g
/Users/apprentice/Desktop/twitter_oauth/app/controllers/index.rb:10
puts ENV['TWITTER_SECRET']
(rdb:1) list
[5, 14] in /Users/apprentice/Desktop/twitter_oauth/app/controllers/index.rb
   5  get '/sign_in' do
   6    # the `request_token` method is defined in `app/helpers/oauth.rb`
   7    puts "this is the key"
   8    debugger
   9    puts ENV['TWITTER_KEY']
=> 10    puts ENV['TWITTER_SECRET']
   11    redirect request_token.authorize_url
   12  end
   13  
   14  get '/sign_out' do
(rdb:1) n
CsIiPfgppgU8dASIxG5ePDCZMKUq87xj9DTC1BS5w
/Users/apprentice/Desktop/twitter_oauth/app/controllers/index.rb:11
redirect request_token.authorize_url
(rdb:1) list
[6, 15] in /Users/apprentice/Desktop/twitter_oauth/app/controllers/index.rb
   6    # the `request_token` method is defined in `app/helpers/oauth.rb`
   7    puts "this is the key"
   8    debugger
   9    puts ENV['TWITTER_KEY']
   10    puts ENV['TWITTER_SECRET']
=> 11    redirect request_token.authorize_url
   12  end
   13  
   14  get '/sign_out' do
   15    session.clear
(rdb:1) s
/Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb:11
if not session[:request_token]
(rdb:1) list
[6, 15] in /Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb
   6      :site => "https://api.twitter.com/oauth/authorize"
   7    )
   8  end
   9  
   10  def request_token
=> 11    if not session[:request_token]
   12      # this 'host_and_port' logic allows our app to work both locally and on Heroku
   13      host_and_port = request.host
   14      host_and_port << ":9393" if request.host == "localhost"
   15  
(rdb:1) session[:request_token]
nil
(rdb:1) n
/Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb:13
host_and_port = request.host
(rdb:1) list
[8, 17] in /Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb
   8  end
   9  
   10  def request_token
   11    if not session[:request_token]
   12      # this 'host_and_port' logic allows our app to work both locally and on Heroku
=> 13      host_and_port = request.host
   14      host_and_port << ":9393" if request.host == "localhost"
   15  
   16      # the `oauth_consumer` method is defined above
   17      session[:request_token] = oauth_consumer.get_request_token(:oauth_callback => "http://#{host_and_port}/auth")
(rdb:1) host_and_port
nil
(rdb:1) n
/Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb:14
host_and_port << ":9393" if request.host == "localhost"
(rdb:1) host_and_port
"localhost"
(rdb:1) n
/Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb:17
session[:request_token] = oauth_consumer.get_request_token(:oauth_callback => "http://#{host_and_port}/auth")
(rdb:1) list
[12, 21] in /Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb
   12      # this 'host_and_port' logic allows our app to work both locally and on Heroku
   13      host_and_port = request.host
   14      host_and_port << ":9393" if request.host == "localhost"
   15  
   16      # the `oauth_consumer` method is defined above
=> 17      session[:request_token] = oauth_consumer.get_request_token(:oauth_callback => "http://#{host_and_port}/auth")
   18    end
   19    session[:request_token]
   20  end
(rdb:1) host_and_port
"localhost:9393"
(rdb:1) list
[12, 21] in /Users/apprentice/Desktop/twitter_oauth/app/helpers/oauth.rb
   12      # this 'host_and_port' logic allows our app to work both locally and on Heroku
   13      host_and_port = request.host
   14      host_and_port << ":9393" if request.host == "localhost"
   15  
   16      # the `oauth_consumer` method is defined above
=> 17      session[:request_token] = oauth_consumer.get_request_token(:oauth_callback => "http://#{host_and_port}/auth")
   18    end
   19    session[:request_token]
   20  end
(rdb:1) oauth_consumer
#<OAuth::Consumer:0x007fd26a9d0a28 @key="RekHFqVzXeKmKWH91l37g", @secret="CsIiPfgppgU8dASIxG5ePDCZMKUq87xj9DTC1BS5w", @options={:signature_method=>"HMAC-SHA1", :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authorize", :access_token_path=>"/oauth/access_token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>"https://api.twitter.com/oauth/authorize"}>
(rdb:1) oauth_consumer.get_request_token