about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-02 02:56:54 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-02 02:59:39 -0700
commitb11f1901e30955bd4154f715db1522374842912e (patch)
tree9aa3b50ab3f42af4503689f27d8fa39bbe75a790
parent5b1606270052ca374cdabc920166f64d38376f15 (diff)
downloadunicorn-b11f1901e30955bd4154f715db1522374842912e.tar.gz
There were some unnecessary lambdas in there
along with some repeated checks.
-rwxr-xr-xbin/unicorn_rails49
1 files changed, 19 insertions, 30 deletions
diff --git a/bin/unicorn_rails b/bin/unicorn_rails
index fa0a9b7..b3c3631 100755
--- a/bin/unicorn_rails
+++ b/bin/unicorn_rails
@@ -121,10 +121,6 @@ require 'pp' if $DEBUG
 rails_loader = lambda do ||
   begin
     require 'config/boot'
-    defined?(::RAILS_ROOT) or abort "RAILS_ROOT not defined by config/boot"
-    defined?(::RAILS_ENV) or abort "RAILS_ENV not defined by config/boot"
-    defined?(::Rails::VERSION::STRING) or
-      abort "Rails::VERSION::STRING not defined by config/boot"
   rescue LoadError => err
     abort "#$0 must be run inside RAILS_ROOT: #{err.inspect}"
   end
@@ -135,43 +131,36 @@ rails_loader = lambda do ||
 
   case config
   when nil
-    lambda do ||
-      require 'config/environment'
-
-      # it seems Rails >=2.2 support Rack, but only >=2.3 requires it
-      old_rails = case ::Rails::VERSION::MAJOR
-      when 0, 1 then true
-      when 2 then Rails::VERSION::MINOR < 3 ? true : false
-      else
-        false
-      end
+    require 'config/environment'
 
-      if old_rails
-        require 'rack'
-        require 'unicorn/app/old_rails'
-        Unicorn::App::OldRails.new
-      else
-        ActionController::Dispatcher.new
-      end
+    # it seems Rails >=2.2 support Rack, but only >=2.3 requires it
+    old_rails = case ::Rails::VERSION::MAJOR
+    when 0, 1 then true
+    when 2 then Rails::VERSION::MINOR < 3 ? true : false
+    else
+      false
+    end
+
+    if old_rails
+      require 'rack'
+      require 'unicorn/app/old_rails'
+      Unicorn::App::OldRails.new
+    else
+      ActionController::Dispatcher.new
     end
   when /\.ru$/
     raw = File.open(config, "rb") { |fp| fp.sysread(fp.stat.size) }
-    lambda { || eval("Rack::Builder.new {(#{raw}\n)}.to_app", nil, config) }
+    eval("Rack::Builder.new {(#{raw}\n)}.to_app", nil, config)
   else
-    lambda do ||
-      require config
-      Object.const_get(File.basename(config, '.rb').capitalize)
-    end
+    require config
+    Object.const_get(File.basename(config, '.rb').capitalize)
   end
 end
 
 # this won't run until after forking if preload_app is false
 app = lambda do ||
-  inner_app = rails_loader.call
-  require 'active_support'
-  require 'action_controller'
   map_path ||= '/'
-  inner_app = inner_app.call
+  inner_app = rails_loader.call
   Rack::Builder.new do
     if inner_app.class.to_s == "Unicorn::App::OldRails"
       if map_path != '/'