aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/commands
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/commands')
-rw-r--r--railties/lib/commands/console.rb13
-rw-r--r--railties/lib/commands/dbconsole.rb2
-rw-r--r--railties/lib/commands/plugin.rb18
-rw-r--r--railties/lib/commands/process/spawner.rb4
4 files changed, 25 insertions, 12 deletions
diff --git a/railties/lib/commands/console.rb b/railties/lib/commands/console.rb
index 2b9d92f647..63df834639 100644
--- a/railties/lib/commands/console.rb
+++ b/railties/lib/commands/console.rb
@@ -1,11 +1,13 @@
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
require 'optparse'
+
options = { :sandbox => false, :irb => irb }
OptionParser.new do |opt|
opt.banner = "Usage: console [environment] [options]"
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
+ opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
opt.parse!(ARGV)
end
@@ -15,6 +17,17 @@ libs << " -r console_app"
libs << " -r console_sandbox" if options[:sandbox]
libs << " -r console_with_helpers"
+if options[:debugger]
+ begin
+ require 'ruby-debug'
+ libs << " -r ruby-debug"
+ puts "=> Debugger enabled"
+ rescue Exception
+ puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
+ exit
+ end
+end
+
ENV['RAILS_ENV'] = case ARGV.first
when "p"; "production"
when "d"; "development"
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb
index 5be3b5dd8e..6ff895aa30 100644
--- a/railties/lib/commands/dbconsole.rb
+++ b/railties/lib/commands/dbconsole.rb
@@ -6,7 +6,7 @@ include_password = false
OptionParser.new do |opt|
opt.banner = "Usage: dbconsole [options] [environment]"
- opt.on("-p", "--include-password", "Automatically provide the database from database.yml") do |v|
+ opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
include_password = true
end
opt.parse!(ARGV)
diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb
index 980244a71b..9ff4739562 100644
--- a/railties/lib/commands/plugin.rb
+++ b/railties/lib/commands/plugin.rb
@@ -461,11 +461,11 @@ module Commands
o.on("-r", "--root=DIR", String,
"Set an explicit rails app directory.",
- "Default: #{@rails_root}") { |@rails_root| self.environment = RailsEnvironment.new(@rails_root) }
+ "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
o.on("-s", "--source=URL1,URL2", Array,
- "Use the specified plugin repositories instead of the defaults.") { |@sources|}
+ "Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources}
- o.on("-v", "--verbose", "Turn on verbose output.") { |$verbose| }
+ o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
o.on("-h", "--help", "Show this help message.") { puts o; exit }
o.separator ""
@@ -552,12 +552,12 @@ module Commands
o.separator "Options:"
o.separator ""
o.on( "-s", "--source=URL1,URL2", Array,
- "Use the specified plugin repositories.") {|@sources|}
+ "Use the specified plugin repositories.") {|sources| @sources = sources}
o.on( "--local",
- "List locally installed plugins.") {|@local| @remote = false}
+ "List locally installed plugins.") {|local| @local, @remote = local, false}
o.on( "--remote",
"List remotely available plugins. This is the default behavior",
- "unless --local is provided.") {|@remote|}
+ "unless --local is provided.") {|remote| @remote = remote}
end
end
@@ -598,7 +598,7 @@ module Commands
o.separator "Options:"
o.separator ""
o.on( "-c", "--check",
- "Report status of repository.") { |@sources|}
+ "Report status of repository.") { |sources| @sources = sources}
end
end
@@ -689,7 +689,7 @@ module Commands
o.separator "Options:"
o.separator ""
o.on( "-l", "--list",
- "List but don't prompt or add discovered repositories.") { |@list| @prompt = !@list }
+ "List but don't prompt or add discovered repositories.") { |list| @list, @prompt = list, !@list }
o.on( "-n", "--no-prompt",
"Add all new repositories without prompting.") { |v| @prompt = !v }
end
@@ -901,7 +901,7 @@ class RecursiveHTTPFetcher
def initialize(urls_to_fetch, level = 1, cwd = ".")
@level = level
@cwd = cwd
- @urls_to_fetch = urls_to_fetch.to_a
+ @urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
@quiet = false
end
diff --git a/railties/lib/commands/process/spawner.rb b/railties/lib/commands/process/spawner.rb
index dc0008698a..8bf47abb75 100644
--- a/railties/lib/commands/process/spawner.rb
+++ b/railties/lib/commands/process/spawner.rb
@@ -181,10 +181,10 @@ ARGV.options do |opts|
opts.on(" Options:")
- opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| }
+ opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v }
if spawner_class.can_bind_to_custom_address?
- opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |OPTIONS[:address]| }
+ opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |v| OPTIONS[:address] = v }
end
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v }