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 1 commit
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
Next Next commit
Remove outdated code for Tilt 1.x versions support
I found out that Sinatra codebase still contains code for handling
both versions of Tilt (1.x and 2.x), however starting from Sinatra 2.0
the minimally required version of Tilt is 2.0 as well.

This commit removes old code and cleans up a bit how tests for
different markdown engines are generated.
  • Loading branch information
304 committed Apr 28, 2019
commit 1d19193653b0c2c0bde044ca2279b30b64bf7316
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
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