From 6aea9f804e1c01b7b9f5f4038f70c4cd2f27e6f3 Mon Sep 17 00:00:00 2001 From: Trevor Bramble Date: Sat, 12 Sep 2015 21:13:54 -0700 Subject: [PATCH] Raise Rack version requirement to 2.x --- .travis.yml | 5 ----- Gemfile | 17 ++++------------- lib/sinatra/base.rb | 2 +- lib/sinatra/show_exceptions.rb | 4 ++-- sinatra.gemspec | 2 +- test/helper.rb | 9 +++------ 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b394cc2..b87d786e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,12 +12,7 @@ rvm: sudo: false matrix: - include: - - { rvm: 2.2, env: rack=master } - - { rvm: 2.2, env: tilt=master } allow_failures: - - env: rack=master - - env: tilt=master - rvm: ruby-head - rvm: jruby-head - rvm: rbx-2 diff --git a/Gemfile b/Gemfile index e14834b9..2e79ead2 100644 --- a/Gemfile +++ b/Gemfile @@ -11,22 +11,10 @@ source 'https://rubygems.org' unless ENV['QUICK'] gemspec gem 'rake' +gem 'rack', github: 'rack/rack' gem 'rack-test', '>= 0.6.2' gem "minitest", "~> 5.0" -# Allows stuff like `tilt=1.2.2 bundle install` or `tilt=master ...`. -# Used by the CI. -repos = {'tilt' => "rtomayko/tilt", 'rack' => "rack/rack"} - -%w[tilt rack].each do |lib| - dep = case ENV[lib] - when 'stable', nil then nil - when /(\d+\.)+\d+/ then "~> " + ENV[lib].sub("#{lib}-", '') - else {:github => repos[lib], :branch => dep} - end - gem lib, dep -end - if RUBY_ENGINE == 'jruby' gem 'nokogiri', '!= 1.5.0' gem 'jruby-openssl' @@ -42,6 +30,9 @@ if RUBY_ENGINE == "ruby" gem 'rdiscount' gem 'RedCloth' gem 'puma' + #TODO: remove explicit require once net-http-server does it + #(apparently it was shipped w/ stdlib in Rubies < 2.2.2) + gem 'gserver' gem 'net-http-server' gem 'yajl-ruby' gem 'nokogiri' diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 12b9ae79..0e3501a7 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -150,7 +150,7 @@ module Sinatra if calculate_content_length? # if some other code has already set Content-Length, don't muck with it # currently, this would be the static file-handler - headers["Content-Length"] = body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s + headers["Content-Length"] = body.inject(0) { |l, p| l + p.bytesize }.to_s end [status.to_i, headers, result] diff --git a/lib/sinatra/show_exceptions.rb b/lib/sinatra/show_exceptions.rb index 6a39c5be..9aca060c 100644 --- a/lib/sinatra/show_exceptions.rb +++ b/lib/sinatra/show_exceptions.rb @@ -1,4 +1,4 @@ -require 'rack/showexceptions' +require 'rack/show_exceptions' module Sinatra # Sinatra::ShowExceptions catches all exceptions raised from the app it @@ -40,7 +40,7 @@ module Sinatra 500, { "Content-Type" => content_type, - "Content-Length" => Rack::Utils.bytesize(body.join).to_s + "Content-Length" => body.join.bytesize.to_s }, body ] diff --git a/sinatra.gemspec b/sinatra.gemspec index e5459f98..c6eaed7d 100644 --- a/sinatra.gemspec +++ b/sinatra.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new 'sinatra', Sinatra::VERSION do |s| s.required_ruby_version = '>= 2.2.0' - s.add_dependency 'rack', '>= 1.6' + s.add_dependency 'rack', '~> 2.0.0.alpha' s.add_dependency 'tilt', '~> 2.0' s.add_dependency 'rack-protection', '~> 1.5' end diff --git a/test/helper.rb b/test/helper.rb index 1e1e665b..49ce119a 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -3,12 +3,9 @@ Encoding.default_external = "UTF-8" if defined? Encoding RUBY_ENGINE = 'ruby' unless defined? RUBY_ENGINE -begin - require 'rack' -rescue LoadError - require 'rubygems' - require 'rack' -end +require 'bundler' +require 'bundler/setup' +require 'rack' testdir = File.dirname(__FILE__) $LOAD_PATH.unshift testdir unless $LOAD_PATH.include?(testdir)