public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Add --debugger option to script/console.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1025 state:committed]
miloops (author)
Thu Sep 11 08:06:36 -0700 2008
NZKoz (committer)
Thu Sep 11 08:12:00 -0700 2008
commit  c98cb8ffc2f42bff565994951af9412e52fcdc58
tree    fcff77ec4ef21c087ade81c6b03a8eb75ea410c1
parent  1ddde91303883b47f2215779cf45d7008377bd0d
...
1
2
3
 
4
5
6
7
8
 
9
10
11
...
15
16
17
 
 
 
 
 
 
 
 
 
 
 
18
19
20
...
1
2
3
4
5
6
7
8
9
10
11
12
13
...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -1,11 +1,13 @@
0
 irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
0
 
0
 require 'optparse'
0
+
0
 options = { :sandbox => false, :irb => irb }
0
 OptionParser.new do |opt|
0
   opt.banner = "Usage: console [environment] [options]"
0
   opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
0
   opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
0
+  opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
0
   opt.parse!(ARGV)
0
 end
0
 
0
@@ -15,6 +17,17 @@ libs << " -r console_app"
0
 libs << " -r console_sandbox" if options[:sandbox]
0
 libs << " -r console_with_helpers"
0
 
0
+if options[:debugger]
0
+  begin
0
+    require 'ruby-debug'
0
+    libs << " -r ruby-debug"
0
+    puts "=> Debugger enabled"
0
+  rescue Exception
0
+    puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
0
+    exit
0
+  end
0
+end
0
+
0
 ENV['RAILS_ENV'] = case ARGV.first
0
   when "p"; "production"
0
   when "d"; "development"

Comments