aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-11-25 14:48:09 -0600
committerJoshua Peek <josh@joshpeek.com>2008-11-25 15:05:07 -0600
commitc80fe1093deeb57eee8df11d3c4120158634cb81 (patch)
tree05e234c2eb291d72d453a7df8b27bb15fe79bac9 /railties
parent07abc5efe1bc71902b0c517ef97dcb36564f2336 (diff)
downloadrails-c80fe1093deeb57eee8df11d3c4120158634cb81.tar.gz
rails-c80fe1093deeb57eee8df11d3c4120158634cb81.tar.bz2
rails-c80fe1093deeb57eee8df11d3c4120158634cb81.zip
Move debugger into middleware
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/commands/server.rb13
-rw-r--r--railties/lib/rails/rack.rb1
-rw-r--r--railties/lib/rails/rack/debugger.rb21
3 files changed, 23 insertions, 12 deletions
diff --git a/railties/lib/commands/server.rb b/railties/lib/commands/server.rb
index f61c48567f..a4bb52592f 100644
--- a/railties/lib/commands/server.rb
+++ b/railties/lib/commands/server.rb
@@ -83,22 +83,11 @@ else
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 }
diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb
index b4f32c2d95..90535674e9 100644
--- a/railties/lib/rails/rack.rb
+++ b/railties/lib/rails/rack.rb
@@ -1,5 +1,6 @@
module Rails
module Rack
+ autoload :Debugger, "rails/rack/debugger"
autoload :Logger, "rails/rack/logger"
autoload :Static, "rails/rack/static"
end
diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb
new file mode 100644
index 0000000000..aa2711c616
--- /dev/null
+++ b/railties/lib/rails/rack/debugger.rb
@@ -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