Permalink
Browse files

Move debugger into middleware

  • Loading branch information...
1 parent 07abc5e commit c80fe1093deeb57eee8df11d3c4120158634cb81 @josh josh committed Nov 25, 2008
Showing with 23 additions and 12 deletions.
  1. +1 −12 railties/lib/commands/server.rb
  2. +1 −0 railties/lib/rails/rack.rb
  3. +21 −0 railties/lib/rails/rack/debugger.rb
@@ -83,22 +83,11 @@
app = Rack::Builder.new {
use Rails::Rack::Logger
use Rails::Rack::Static
+ use Rails::Rack::Debugger if options[:debugger]
run ActionController::Dispatcher.new
}.to_app
end
-if options[:debugger]
- begin
- require_library_or_gem 'ruby-debug'
- Debugger.start
- Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
- puts "=> Debugger enabled"
- rescue Exception
- puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
- exit
- end
-end
-
puts "=> Call with -d to detach"
trap(:INT) { exit }
@@ -1,5 +1,6 @@
module Rails
module Rack
+ autoload :Debugger, "rails/rack/debugger"
autoload :Logger, "rails/rack/logger"
autoload :Static, "rails/rack/static"
end
@@ -0,0 +1,21 @@
+module Rails
+ module Rack
+ class Debugger
+ def initialize(app)
+ @app = app
+
+ require_library_or_gem 'ruby-debug'
+ ::Debugger.start
+ ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
+ puts "=> Debugger enabled"
+ rescue Exception
+ puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
+ exit
+ end
+
+ def call(env)
+ @app.call(env)
+ end
+ end
+ end
+end

1 comment on commit c80fe10

elecnix commented on c80fe10 Mar 8, 2010

I don't liike this "rescue Exception" which hides any other problem with loading ruby-debug. For example, ruby-debug-0.10.3/cli/ruby-debug/interface.rb fails because of "uninitialized constant Debugger::LocalInterface::Readline" and the message printed is "You need to install ruby-debug" although it is installed.

Please sign in to comment.