lib/deas/sinatra_runner.rb in deas-0.33.0 vs lib/deas/sinatra_runner.rb in deas-0.34.0

- old
+ new

@@ -18,19 +18,11 @@ def redirect(*args) @sinatra_call.redirect(*args) end def content_type(*args) - return @sinatra_call.content_type if args.empty? - - opts, value = [ - args.last.kind_of?(::Hash) ? args.pop : {}, - args.first - ] - @sinatra_call.content_type(value, { - :charset => @sinatra_call.settings.deas_default_charset - }.merge(opts || {})) + @sinatra_call.content_type(*args) end def status(*args) @sinatra_call.status(*args) end @@ -38,21 +30,26 @@ def headers(*args) @sinatra_call.headers(*args) end def source_render(source, template_name, locals = nil) - self.content_type(get_content_type(template_name)) if self.content_type.nil? + if self.content_type.nil? + self.content_type(get_content_type_ext(template_name) || 'html') + end super end - def send_file(*args, &block) - @sinatra_call.send_file(*args, &block) + def send_file(file_path, opts = nil, &block) + if self.content_type.nil? + self.content_type(get_content_type_ext(file_path)) + end + @sinatra_call.send_file(file_path, opts || {}, &block) end private - def get_content_type(template_name) - File.extname(template_name)[1..-1] || 'html' + def get_content_type_ext(file_path) + File.extname(file_path)[1..-1] end end end