Skip to content
This repository
Browse code

Clean up the act of commands

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2412 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit d219d54930a68a9c5de3705d05d5d464e5e51b54 1 parent 0a0ac86
David Heinemeier Hansson authored September 29, 2005
8  railties/lib/commands.rb
... ...
@@ -1,5 +1,7 @@
1  
-if %w( console perform process runner server ).include?(ARGV.first)
2  
-  require "#{File.dirname(__FILE__)}/process/#{ARGV.shift}"
  1
+commands = Dir["#{File.dirname(__FILE__)}/commands/*.rb"].collect { |file_path| File.basename(file_path).split(".").first }
  2
+
  3
+if commands.include?(ARGV.first)
  4
+  require "#{File.dirname(__FILE__)}/commands/#{ARGV.shift}"
3 5
 else
4  
-  puts "Choose: console perform process runner server"
  6
+  puts "Choose: #{commands.join(", ")}"
5 7
 end
3  railties/lib/commands/breakpointer
... ...
@@ -1,3 +0,0 @@
1  
-#!/usr/local/bin/ruby
2  
-$LOAD_PATH << File.dirname(__FILE__) + '/../vendor/railties/lib'
3  
-require 'breakpoint_client'
1  railties/lib/commands/breakpointer.rb
... ...
@@ -0,0 +1 @@
  1
+require 'breakpoint_client'
2  railties/lib/commands/console.rb
@@ -9,7 +9,7 @@
9 9
 end
10 10
 
11 11
 libs =  " -r irb/completion"
12  
-libs << " -r #{File.dirname(__FILE__)}/../config/environment"
  12
+libs << " -r #{RAILS_ROOT}/config/environment"
13 13
 libs << " -r console_sandbox" if options[:sandbox]
14 14
 
15 15
 ENV['RAILS_ENV'] = ARGV.first || 'development'
3  railties/lib/commands/destroy → railties/lib/commands/destroy.rb
... ...
@@ -1,5 +1,4 @@
1  
-#!/usr/local/bin/ruby
2  
-require File.dirname(__FILE__) + '/../config/environment'
  1
+require "#{RAILS_ROOT}/config/environment"
3 2
 require 'rails_generator'
4 3
 require 'rails_generator/scripts/destroy'
5 4
 
3  railties/lib/commands/generate → railties/lib/commands/generate.rb
... ...
@@ -1,5 +1,4 @@
1  
-#!/usr/local/bin/ruby
2  
-require File.dirname(__FILE__) + '/../config/environment'
  1
+require "#{RAILS_ROOT}/config/environment"
3 2
 require 'rails_generator'
4 3
 require 'rails_generator/scripts/generate'
5 4
 
4  railties/lib/commands/server.rb
@@ -5,7 +5,7 @@
5 5
   :port            => 3000,
6 6
   :ip              => "0.0.0.0",
7 7
   :environment     => "development",
8  
-  :server_root     => File.expand_path(File.dirname(__FILE__) + "/../public/"),
  8
+  :server_root     => File.expand_path(RAILS_ROOT + "/public/"),
9 9
   :server_type     => WEBrick::SimpleServer,
10 10
   :charset         => "UTF-8",
11 11
   :mime_types      => WEBrick::HTTPUtils::DefaultMimeTypes
@@ -47,7 +47,7 @@
47 47
 end
48 48
 
49 49
 ENV["RAILS_ENV"] = OPTIONS[:environment]
50  
-require File.dirname(__FILE__) + "/../config/environment"
  50
+require RAILS_ROOT + "/config/environment"
51 51
 require 'webrick_server'
52 52
 
53 53
 OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT)
3  railties/lib/commands/update → railties/lib/commands/update.rb
... ...
@@ -1,5 +1,4 @@
1  
-#!/usr/local/bin/ruby
2  
-require File.dirname(__FILE__) + '/../config/environment'
  1
+require "#{RAILS_ROOT}/config/environment"
3 2
 require 'rails_generator'
4 3
 require 'rails_generator/scripts/update'
5 4
 Rails::Generator::Scripts::Update.new.run(ARGV)

0 notes on commit d219d54

Please sign in to comment.
Something went wrong with that request. Please try again.