From 4e2b7f444214595a33258ac548d60a4fe3b14136 Mon Sep 17 00:00:00 2001 From: Clemens Kofler Date: Fri, 26 May 2017 15:42:12 +0200 Subject: [PATCH] Update all gems --- lib/dashing/app.rb | 21 ++++++++------------- smashing.gemspec | 31 ++++++++++++++++--------------- templates/project/config.ru | 4 ++++ test/app_test.rb | 4 ++++ 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/lib/dashing/app.rb b/lib/dashing/app.rb index 53ee0dc..d5d58ab 100644 --- a/lib/dashing/app.rb +++ b/lib/dashing/app.rb @@ -41,6 +41,7 @@ def authenticated?(token) set :views, File.join(settings.root, 'dashboards') set :default_dashboard, nil set :auth_token, nil +set :template_languages, %i[html erb] if File.exists?(settings.history_file) set :history, YAML.load_file(settings.history_file) @@ -84,9 +85,9 @@ def authenticated?(token) get '/:dashboard' do protected! - tilt_html_engines.each do |suffix, _| - file = File.join(settings.views, "#{params[:dashboard]}.#{suffix}") - return render(suffix.to_sym, params[:dashboard].to_sym) if File.exist? file + settings.template_languages.each do |language| + file = File.join(settings.views, "#{params[:dashboard]}.#{language}") + return render(language, params[:dashboard].to_sym) if File.exist?(file) end halt 404 @@ -119,10 +120,11 @@ def authenticated?(token) get '/views/:widget?.html' do protected! - tilt_html_engines.each do |suffix, engines| - file = File.join(settings.root, "widgets", params[:widget], "#{params[:widget]}.#{suffix}") - return engines.first.new(file).render if File.exist? file + settings.template_languages.each do |language| + file = File.join(settings.root, "widgets", params[:widget], "#{params[:widget]}.#{language}") + return Tilt[language].new(file).render if File.exist?(file) end + "Drats! Unable to find a widget file named: #{params[:widget]} to render." end @@ -162,13 +164,6 @@ def first_dashboard files.sort.first end -def tilt_html_engines - Tilt.mappings.select do |_, engines| - default_mime_type = engines.first.default_mime_type - default_mime_type.nil? || default_mime_type == 'text/html' - end -end - def require_glob(relative_glob) Dir[File.join(settings.root, relative_glob)].each do |file| require file diff --git a/smashing.gemspec b/smashing.gemspec index 4f1fbd6..66ef54e 100644 --- a/smashing.gemspec +++ b/smashing.gemspec @@ -15,21 +15,22 @@ Gem::Specification.new do |s| s.files = Dir['README.md', 'javascripts/**/*', 'templates/**/*','templates/**/.[a-z]*', 'lib/**/*'] - s.add_dependency('sass', '~> 3.2.12') - s.add_dependency('coffee-script', '~> 2.2.0') - s.add_dependency('execjs', '~> 2.0.2') - s.add_dependency('sinatra', '~> 1.4.4') - s.add_dependency('sinatra-contrib', '~> 1.4.2') - s.add_dependency('thin', '~> 1.6.1') - s.add_dependency('rufus-scheduler', '~> 3.2.0') - s.add_dependency('thor', '~> 0.19') - s.add_dependency('sprockets', '~> 2.10.1') - s.add_dependency('rack', '~> 1.5.4') + s.add_dependency('sass', '~> 3.4.24') + s.add_dependency('coffee-script', '~> 2.4.1') + s.add_dependency('execjs', '~> 2.7.0') + s.add_dependency('sinatra', '~> 2.0.0') + s.add_dependency('sinatra-contrib', '~> 2.0.0') + s.add_dependency('thin', '~> 1.7.0') + s.add_dependency('rufus-scheduler', '~> 3.4.2') + s.add_dependency('thor', '~> 0.19.4') + s.add_dependency('sprockets', '~> 3.7.1') + s.add_dependency('rack', '~> 2.0.0') - s.add_development_dependency('rake', '~> 10.1.0') - s.add_development_dependency('haml', '~> 4.0.4') - s.add_development_dependency('minitest', '~> 5.2.0') - s.add_development_dependency('mocha', '~> 0.14.0') + s.add_development_dependency('rake', '~> 12.0.0') + s.add_development_dependency('haml', '~> 5.0.1') + s.add_development_dependency('rack-test', '~> 0.6.3') + s.add_development_dependency('minitest', '~> 5.10.2') + s.add_development_dependency('mocha', '~> 1.2.1') s.add_development_dependency('fakeweb', '~> 1.3.0') - s.add_development_dependency('simplecov', '~> 0.8.2') + s.add_development_dependency('simplecov', '~> 0.14.1') end diff --git a/templates/project/config.ru b/templates/project/config.ru index 624244e..eecd5e0 100644 --- a/templates/project/config.ru +++ b/templates/project/config.ru @@ -3,6 +3,10 @@ require 'dashing' configure do set :auth_token, 'YOUR_AUTH_TOKEN' + # See http://www.sinatrarb.com/intro.html > Available Template Languages on + # how to add additional template languages. + set :template_languages, %i[html erb] + helpers do def protected! # Put any authentication code you want in here. diff --git a/test/app_test.rb b/test/app_test.rb index 0eb6f3a..ee38232 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -104,6 +104,8 @@ def test_page_title_set_correctly end def test_get_haml_dashboard + app.template_languages << :haml + with_generated_project do |dir| File.write(File.join(dir, 'dashboards/hamltest.haml'), '.gridster') get '/hamltest' @@ -113,6 +115,8 @@ def test_get_haml_dashboard end def test_get_haml_widget + app.template_languages << :haml + with_generated_project do |dir| File.write(File.join(dir, 'widgets/clock/clock.haml'), '%h1 haml') File.unlink(File.join(dir, 'widgets/clock/clock.html'))