Updates to support Rails 5, Rack 3 and Sinatra 2 (beta) (#1984)

* Updates to support Rails 5, Rack 3 and Sinatra 2 (beta).

- Bump upper boundary of version for Rack dependency from 2.0 to 3 (exclusive).
- Version bump sinatra for CI testing to >= 2.0.0.beta2.
- Also replaces use of String#hash in middleman-core/features/asset_host.feature
to ensure sufficiently random variables are returned.

Closes middleman/middleman#1983.

* Testing revert of the version requirements...

To confirm my changes don't cause a regression for any of:
- Rails < 5
- Sinatra < 2
- Rack < 2

* Revert "Testing revert of the version requirements..."

This reverts commit 5cf4c2a07c0814eefa573358b1bc9b0eeb62f9c1.
This commit is contained in:
Mike Vastola 2016-09-13 04:25:17 -04:00 committed by Thomas Reynolds
parent 197093b36c
commit 7c968b9572
6 changed files with 15 additions and 8 deletions

View file

@ -18,7 +18,7 @@ gem 'kramdown', '~> 1.2', require: false
gem 'slim', '>= 2.0', require: false gem 'slim', '>= 2.0', require: false
gem 'liquid', '>= 2.6', require: false gem 'liquid', '>= 2.6', require: false
gem 'stylus', '>= 1.0', require: false gem 'stylus', '>= 1.0', require: false
gem 'sinatra', '>= 1.4', require: false gem 'sinatra', '>= 2.0.0.beta2', require: false
gem 'redcarpet', '>= 3.1', require: false gem 'redcarpet', '>= 3.1', require: false
# Dns server to test preview server # Dns server to test preview server

View file

@ -25,7 +25,8 @@ Feature: Alternate between multiple asset hosts
And a file named "config.rb" with: And a file named "config.rb" with:
""" """
activate :asset_host, host: Proc.new { |asset| activate :asset_host, host: Proc.new { |asset|
"http://assets%d.example.com" % (asset.hash % 4) hash = Digest::MD5.digest(asset).bytes.map!(&:ord).reduce(&:+)
"http://assets%d.example.com" % (hash % 4)
} }
""" """
And the Server is running And the Server is running

View file

@ -72,7 +72,7 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
end end
if minified if minified
headers['Content-Length'] = ::Rack::Utils.bytesize(minified).to_s headers['Content-Length'] = minified.bytesize.to_s
response = [minified] response = [minified]
end end

View file

@ -64,7 +64,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
end end
if minified if minified
headers['Content-Length'] = ::Rack::Utils.bytesize(minified).to_s headers['Content-Length'] = minified.bytesize.to_s
response = [minified] response = [minified]
end end

View file

@ -133,9 +133,15 @@ module Middleman
# Immediately send static file # Immediately send static file
def send_file(resource, env) def send_file(resource, env)
file = ::Rack::File.new nil file = ::Rack::File.new nil
file.path = resource.file_descriptor[:full_path] path = resource.file_descriptor[:full_path]
response = file.serving(env) if !file.respond_to?(:path=)
request = ::Rack::Request.new(env)
response = file.serving(request, path)
else
file.path = path
response = file.serving(env)
end
status = response[0] status = response[0]
response[1]['Content-Encoding'] = 'gzip' if %w(.svgz .gz).include?(resource.ext) response[1]['Content-Encoding'] = 'gzip' if %w(.svgz .gz).include?(resource.ext)
# Do not set Content-Type if status is 1xx, 204, 205 or 304, otherwise # Do not set Content-Type if status is 1xx, 204, 205 or 304, otherwise

View file

@ -20,7 +20,7 @@ Gem::Specification.new do |s|
# Core # Core
s.add_dependency('bundler', ['~> 1.1']) s.add_dependency('bundler', ['~> 1.1'])
s.add_dependency('rack', ['>= 1.4.5', '< 2.0']) s.add_dependency('rack', ['>= 1.4.5', '< 3'])
s.add_dependency('tilt', ['~> 2.0']) s.add_dependency('tilt', ['~> 2.0'])
s.add_dependency('erubis') s.add_dependency('erubis')
s.add_dependency('fast_blank') s.add_dependency('fast_blank')