Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated code for Tilt 1.x versions #1532

Merged
merged 4 commits into from
Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if RUBY_ENGINE == "ruby"
gem 'sass'
gem 'reel-rack'
gem 'celluloid', '~> 0.16.0'
gem 'commonmarker', '~> 0.20.0'
gem 'simplecov', require: false
end

Expand Down
11 changes: 2 additions & 9 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -786,15 +786,8 @@ def rabl(template, options = {}, locals = {})
def find_template(views, name, engine)
yield ::File.join(views, "#{name}.#{@preferred_extension}")

if Tilt.respond_to?(:mappings)
Tilt.mappings.each do |ext, engines|
next unless ext != @preferred_extension and engines.include? engine
yield ::File.join(views, "#{name}.#{ext}")
end
else
Tilt.default_mapping.extensions_for(engine).each do |ext|
yield ::File.join(views, "#{name}.#{ext}") unless ext == @preferred_extension
end
Tilt.default_mapping.extensions_for(engine).each do |ext|
yield ::File.join(views, "#{name}.#{ext}") unless ext == @preferred_extension
end
end

Expand Down
14 changes: 5 additions & 9 deletions sinatra-contrib/lib/sinatra/respond_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,12 @@ def template_for(name, exts)
settings.template_engines[ext].each { |e| possible << [e, name] }
end
possible.each do |engine, template|
# not exactly like Tilt[engine], but does not trigger a require
if Tilt.respond_to?(:mappings)
klass = Tilt.mappings[Tilt.normalize(engine)].first
else
begin
klass = Tilt[engine]
rescue LoadError
next
end
begin
klass = Tilt[engine]
rescue LoadError
next
end

find_template(settings.views, template, klass) do |file|
next unless File.exist? file
return settings.rendering_method(engine) << template.to_sym
Expand Down
2 changes: 1 addition & 1 deletion sinatra-contrib/sinatra-contrib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EOF
s.add_dependency "sinatra", version
s.add_dependency "mustermann", "~> 1.0"
s.add_dependency "backports", ">= 2.8.2"
s.add_dependency "tilt", ">= 1.3", "< 3"
s.add_dependency "tilt", "~> 2.0"
s.add_dependency "rack-protection", version
s.add_dependency "multi_json"

Expand Down
15 changes: 8 additions & 7 deletions test/markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ def setup
end

# Will generate RDiscountTest, KramdownTest, etc.
map = Tilt.respond_to?(:lazy_map) ? Tilt.lazy_map['md'].map(&:first) : Tilt.mappings['md']
markdown_templates = Tilt.lazy_map['md'].map { |klass, _require_path| klass }

map.each do |t|
markdown_templates.each do |template_name|
begin
t = eval(t) if t.is_a? String
t.new { "" }
klass = Class.new(Minitest::Test) { define_method(:engine) { t }}
template = Object.const_get(template_name)

klass = Class.new(Minitest::Test) { define_method(:engine) { template } }
klass.class_eval(&MarkdownTest)
name = t.name[/[^:]+$/].sub(/Template$/, '') << "Test"

name = template_name.split('::').last.sub(/Template$/, 'Test')
Object.const_set name, klass
rescue LoadError, NameError
warn "#{$!}: skipping markdown tests with #{t}"
warn "#{$!}: skipping markdown tests with #{template_name}"
end
end
4 changes: 2 additions & 2 deletions test/static_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def assert_valid_range(http_range, range, path, file)
it 'sets cache control headers on static files if set' do
@app.set :static_cache_control, :public
env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
status, headers, body = @app.call(env)
_, headers, _ = @app.call(env)
assert headers.has_key?('Cache-Control')
assert_equal headers['Cache-Control'], 'public'

Expand All @@ -207,7 +207,7 @@ def assert_valid_range(http_range, range, path, file)
[:public, :must_revalidate, {:max_age => 300}]
)
env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
status, headers, body = @app.call(env)
_, headers, _ = @app.call(env)
assert headers.has_key?('Cache-Control')
assert_equal(
headers['Cache-Control'],
Expand Down