aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-12-26 17:18:06 +0000
committerPratik Naik <pratiknaik@gmail.com>2008-12-26 17:18:06 +0000
commit73e9f4e9096515e9f4d97baaa914320c42159985 (patch)
treedb8fc9b9c07ca9a523a764ad76ce3b75254c73b3 /railties
parent2cd8d3b4c5b2a90da52bfe2e92455fdecfb89ac2 (diff)
parent07298fd0929ae1c6dd6d1b41bf320112d6bfc6a0 (diff)
downloadrails-73e9f4e9096515e9f4d97baaa914320c42159985.tar.gz
rails-73e9f4e9096515e9f4d97baaa914320c42159985.tar.bz2
rails-73e9f4e9096515e9f4d97baaa914320c42159985.zip
Merge commit 'mainstream/master'
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/commands/dbconsole.rb2
-rw-r--r--railties/lib/rails/rack/cascade.rb31
-rw-r--r--railties/lib/rails/rack/metal.rb35
-rw-r--r--railties/lib/tasks/tmp.rake4
4 files changed, 25 insertions, 47 deletions
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb
index 6ff895aa30..06848d3c91 100644
--- a/railties/lib/commands/dbconsole.rb
+++ b/railties/lib/commands/dbconsole.rb
@@ -41,7 +41,7 @@ when "mysql"
if config['password'] && include_password
args << "--password=#{config['password']}"
- elsif config['password'] && !config['password'].empty?
+ elsif config['password'] && !config['password'].to_s.empty?
args << "-p"
end
diff --git a/railties/lib/rails/rack/cascade.rb b/railties/lib/rails/rack/cascade.rb
deleted file mode 100644
index d5af7fc77e..0000000000
--- a/railties/lib/rails/rack/cascade.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'active_support/ordered_hash'
-
-module Rails
- module Rack
- # Try a request on several apps; return the first non-404 response.
- class Cascade
- attr_reader :apps
-
- def initialize(apps)
- @apps = ActiveSupport::OrderedHash.new
- apps.each { |app| add app }
- end
-
- def call(env)
- @apps.keys.each do |app|
- result = app.call(env)
- return result unless result[0].to_i == 404
- end
- Metal::NotFoundResponse
- end
-
- def add(app)
- @apps[app] = true
- end
-
- def include?(app)
- @apps.include?(app)
- end
- end
- end
-end
diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb
index 1df31a1594..b185227234 100644
--- a/railties/lib/rails/rack/metal.rb
+++ b/railties/lib/rails/rack/metal.rb
@@ -1,26 +1,35 @@
-require 'rails/rack/cascade'
+require 'active_support/ordered_hash'
module Rails
module Rack
- module Metal
+ class Metal
NotFoundResponse = [404, {}, []].freeze
NotFound = lambda { NotFoundResponse }
- class << self
- def new(app)
- Cascade.new(builtins + [app])
+ def self.metals
+ base = "#{Rails.root}/app/metal"
+ matcher = /\A#{Regexp.escape(base)}\/(.*)\.rb\Z/
+
+ Dir["#{base}/**/*.rb"].sort.map do |file|
+ file.sub!(matcher, '\1')
+ require file
+ file.classify.constantize
end
+ end
- def builtins
- base = "#{Rails.root}/app/metal"
- matcher = /\A#{Regexp.escape(base)}\/(.*)\.rb\Z/
+ def initialize(app)
+ @app = app
+ @metals = ActiveSupport::OrderedHash.new
+ self.class.metals.each { |app| @metals[app] = true }
+ freeze
+ end
- Dir["#{base}/**/*.rb"].sort.map do |file|
- file.sub!(matcher, '\1')
- require file
- file.classify.constantize
- end
+ def call(env)
+ @metals.keys.each do |app|
+ result = app.call(env)
+ return result unless result[0].to_i == 404
end
+ @app.call(env)
end
end
end
diff --git a/railties/lib/tasks/tmp.rake b/railties/lib/tasks/tmp.rake
index b191039d63..fea15058bb 100644
--- a/railties/lib/tasks/tmp.rake
+++ b/railties/lib/tasks/tmp.rake
@@ -2,7 +2,7 @@ namespace :tmp do
desc "Clear session, cache, and socket files from tmp/"
task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
- desc "Creates tmp directories for sessions, cache, and sockets"
+ desc "Creates tmp directories for sessions, cache, sockets, and pids"
task :create do
FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids ))
end
@@ -34,4 +34,4 @@ namespace :tmp do
FileUtils.rm(Dir['tmp/pids/[^.]*'])
end
end
-end \ No newline at end of file
+end