From c1fc54a0fe687e0400b2efff9246fc5713330684 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Wed, 6 Feb 2013 14:44:51 -0800 Subject: [PATCH] Handle a config-based app properly --- lib/puma/configuration.rb | 24 ++++++++++++------------ test/test_config.rb | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index e1f20b28..d12a5db8 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -71,22 +71,22 @@ module Puma # the rackup file, and set @app. # def app - if app = @options[:app] - return app - end + app = @options[:app] - path = @options[:rackup] || DefaultRackup + unless app + path = @options[:rackup] || DefaultRackup - unless File.exists?(path) - raise "Missing rackup file '#{path}'" - end + unless File.exists?(path) + raise "Missing rackup file '#{path}'" + end - app, options = Rack::Builder.parse_file path - @options.merge! options + app, options = Rack::Builder.parse_file path + @options.merge! options - options.each do |key,val| - if key.to_s[0,4] == "bind" - @options[:binds] << val + options.each do |key,val| + if key.to_s[0,4] == "bind" + @options[:binds] << val + end end end diff --git a/test/test_config.rb b/test/test_config.rb index 3cba3608..8da2722d 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -11,6 +11,6 @@ class TestConfigFile < Test::Unit::TestCase app = conf.app - assert_equal [200, {}, ["embedded app"]], app.call(nil) + assert_equal [200, {}, ["embedded app"]], app.call({}) end end