From b69adb635e1d0d2185cc980111d66a98b3e0788e Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 18 Oct 2015 11:26:00 -0400 Subject: [PATCH] Refactor app.rb --- lib/app.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/app.rb b/lib/app.rb index d80537cd..19977b6e 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -4,6 +4,7 @@ Bundler.require :app class App < Sinatra::Application Bundler.require environment require 'sinatra/cookies' + require 'tilt/erubis' Rack::Mime::MIME_TYPES['.webapp'] = 'application/x-web-app-manifest+json' @@ -94,15 +95,17 @@ class App < Sinatra::Application @browser ||= Browser.new ua: request.user_agent end + UNSUPPORTED_IE_VERSIONS = %w(6 7 8 9).freeze + def unsupported_browser? - browser.ie? && %w(6 7 8 9).include?(browser.version) + browser.ie? && UNSUPPORTED_IE_VERSIONS.include?(browser.version) end def docs @docs ||= begin cookie = cookies[:docs] - docs = if cookie.nil? || cookie.empty? + if cookie.nil? || cookie.empty? settings.default_docs else cookie.split('/') @@ -111,11 +114,10 @@ class App < Sinatra::Application end def doc_index_urls - docs.inject [] do |result, slug| + docs.each_with_object [] do |slug, result| if doc = settings.docs[slug] result << File.join('', settings.docs_prefix, doc['index_path']) + "?#{doc['mtime']}" end - result end end