From 48a4e2cd0b89835d82c690d49ecaea38a981a0cc Mon Sep 17 00:00:00 2001 From: Hugh Bien Date: Wed, 13 Jan 2016 21:18:08 -0800 Subject: [PATCH 1/2] Update to Tilt ~> 2.0 --- lib/stasis.rb | 18 +++++++++++++----- lib/stasis/plugins/render.rb | 2 +- stasis.gemspec | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/stasis.rb b/lib/stasis.rb index 151d21a..5d2787d 100644 --- a/lib/stasis.rb +++ b/lib/stasis.rb @@ -18,7 +18,10 @@ # Activate the [Tilt][ti] gem. -gem "tilt", "1.3.3" +gem "tilt", "~> 2.0" + +# Tilt introduces a plain HTML no-op template that breaks Stasis behavior with HTML files. +Tilt.default_mapping.lazy_map.delete('html') # Add the project directory to the load paths. @@ -180,10 +183,8 @@ def render(*only) @action = Action.new(self, :params => render_options[:params]) # Set the extension if the `@path` extension is supported by [Tilt][ti]. - ext = - Tilt.mappings.keys.detect do |ext| - File.extname(@path)[1..-1] == ext - end + ext = File.extname(@path)[1..-1] + ext = nil if !tilt_registered?(ext) # Change current working directory. Dir.chdir(File.dirname(@path)) @@ -313,6 +314,13 @@ def trigger(type) end end + # Checks if extension has been registered with Tilt AND at least one template engine loaded. + def tilt_registered?(ext) + !!Tilt[ext] + rescue LoadError + false + end + private # Iterate through plugin priority integers (sorted) and yield each to a block. diff --git a/lib/stasis/plugins/render.rb b/lib/stasis/plugins/render.rb index 795275b..934ce47 100644 --- a/lib/stasis/plugins/render.rb +++ b/lib/stasis/plugins/render.rb @@ -41,7 +41,7 @@ def render(path_or_options={}, options={}, &block) end output = - if Tilt.mappings.keys.include?(ext) + if @stasis.tilt_registered?(ext) scope = options[:scope] ||= @stasis.action tilt = Tilt.new(path, nil, template_options) if block_given? diff --git a/stasis.gemspec b/stasis.gemspec index 4932a40..9455ec5 100644 --- a/stasis.gemspec +++ b/stasis.gemspec @@ -30,5 +30,5 @@ Gem::Specification.new do |s| s.add_dependency "directory_watcher", "1.4.1" s.add_dependency "slop", "3.3.2" - s.add_dependency "tilt", "1.3.3" + s.add_dependency "tilt", "~> 2.0" end From 358cd8f8134688340b6fdb8b0b9bb4a6ea006e26 Mon Sep 17 00:00:00 2001 From: Hugh Bien Date: Wed, 13 Jan 2016 21:19:19 -0800 Subject: [PATCH 2/2] Drop Ruby 1.9.x, adds 2.x --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6cac1b1..ada0b3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: ruby rvm: - - 1.9.2 - - 1.9.3 \ No newline at end of file + - 2.1.8 + - 2.2.4 + - 2.3.0