Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

be smarter about servers

  • Loading branch information...
commit 6ec52345175362399a9250c613f5145af73a33f1 1 parent 5a8080a
@rkh rkh authored
Showing with 29 additions and 4 deletions.
  1. +2 −0  Gemfile
  2. +13 −1 lib/sinatra/base.rb
  3. +14 −3 test/settings_test.rb
View
2  Gemfile
@@ -72,6 +72,8 @@ if RUBY_ENGINE != 'jruby' or not ENV['TRAVIS']
#gem 'bluecloth'
end
+gem 'net-http-server'
+
platforms :ruby_18, :jruby do
gem 'json' unless RUBY_VERSION > '1.9' # is there a jruby but 1.8 only selector?
end
View
14 lib/sinatra/base.rb
@@ -1609,10 +1609,22 @@ class << self
set :run, false # start server via at-exit hook?
set :running, false # is the built-in server running now?
- set :server, %w[thin puma mongrel webrick]
+ set :server, %w[http webrick]
set :bind, '0.0.0.0'
set :port, 4567
+ ruby_engine = defined?(RUBY_ENGINE) && RUBY_ENGINE
+
+ if ruby_engine == 'macruby'
+ server.unshift 'controll_tower'
+ else
+ server.unshift 'mongrel' if ruby_engine.nil?
+ server.unshift 'puma' if ruby_engine != 'rbx'
+ server.unshift 'thin' if ruby_engine != 'jruby'
+ server.unshift 'puma' if ruby_engine == 'rbx'
+ server.unshift 'trinidat' if ruby_engine =='jruby'
+ end
+
set :absolute_redirects, true
set :prefixed_redirects, false
set :empty_path_info, nil
View
17 test/settings_test.rb
@@ -422,9 +422,20 @@ def pub; end
end
describe 'server' do
- it 'is one of thin, puma, mongrel, webrick' do
- assert_equal %w[thin puma mongrel webrick], @base.server
- assert_equal %w[thin puma mongrel webrick], @application.server
+ it 'includes webrick' do
+ assert @base.server.include?('webrick')
+ assert @application.server.include?('webrick')
+ end
+
+ it 'includes puma' do
+ assert @base.server.include?('puma')
+ assert @application.server.include?('puma')
+ end
+
+ it 'includes thin' do
+ next if RUBY_ENGINE == 'jruby'
+ assert @base.server.include?('thin')
+ assert @application.server.include?('thin')
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.