diff --git a/lib/flowerbox/delivery.rb b/lib/flowerbox/delivery.rb index 2e5076f..999d33c 100644 --- a/lib/flowerbox/delivery.rb +++ b/lib/flowerbox/delivery.rb @@ -1,11 +1,8 @@ module Flowerbox module Delivery autoload :Server, 'flowerbox/delivery/server' - autoload :TemplateRenderer, 'flowerbox/delivery/template_renderer' autoload :SprocketsHandler, 'flowerbox/delivery/sprockets_handler' autoload :UniqueAssetList, 'flowerbox/delivery/unique_asset_list' - - autoload :Tilt, 'flowerbox/delivery/tilt' end end diff --git a/lib/flowerbox/delivery/template_renderer.rb b/lib/flowerbox/delivery/template_renderer.rb deleted file mode 100644 index 2638512..0000000 --- a/lib/flowerbox/delivery/template_renderer.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'erb' - -module Flowerbox::Delivery - class TemplateRenderer - class FileTypeError < StandardError ; end - - attr_reader :options - - def initialize(options) - @options = options - end - - def render - ERB.new(template).result(binding) - end - - def template - File.read(options[:template]) - end - - def resource_tags - options[:files].collect do |file| - case File.extname(file) - when '.js' - %{} - when '.css' - %{} - else - raise FileTypeError.new("Unknown file type: #{File.extname(file)} for #{file}") - end - end.join - end - end -end - diff --git a/lib/flowerbox/delivery/tilt.rb b/lib/flowerbox/delivery/tilt.rb deleted file mode 100644 index bc74ef6..0000000 --- a/lib/flowerbox/delivery/tilt.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'sprockets' - -module Flowerbox::Delivery::Tilt - autoload :JSTemplate, 'flowerbox/delivery/tilt/js_template' - autoload :JSTTemplate, 'flowerbox/delivery/tilt/jst_template' - autoload :CSSTemplate, 'flowerbox/delivery/tilt/css_template' - - autoload :TemplateThatSaves, 'flowerbox/delivery/tilt/template_that_saves' - - autoload :EnsureSavedFile, 'flowerbox/delivery/tilt/ensure_saved_file' -end - diff --git a/lib/flowerbox/delivery/tilt/css_template.rb b/lib/flowerbox/delivery/tilt/css_template.rb deleted file mode 100644 index 85e1b63..0000000 --- a/lib/flowerbox/delivery/tilt/css_template.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'tilt' - -class Flowerbox::Delivery::Tilt::CSSTemplate < Tilt::Template - self.default_mime_type = "text/css" - - EXTENSION = "css" - - include Flowerbox::Delivery::Tilt::TemplateThatSaves - -end - diff --git a/lib/flowerbox/delivery/tilt/ensure_saved_file.rb b/lib/flowerbox/delivery/tilt/ensure_saved_file.rb deleted file mode 100644 index b4de1b8..0000000 --- a/lib/flowerbox/delivery/tilt/ensure_saved_file.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'tilt' - -module Flowerbox::Delivery::Tilt - class EnsureSavedFile < Tilt::Template - include TemplateThatSaves - - def handle_evaluate - output = if File.file?(data) - data - else - save - end - - output - end - - def extension - "js" - end - end -end - diff --git a/lib/flowerbox/delivery/tilt/js_template.rb b/lib/flowerbox/delivery/tilt/js_template.rb deleted file mode 100644 index 6d26129..0000000 --- a/lib/flowerbox/delivery/tilt/js_template.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'tilt' - -class Flowerbox::Delivery::Tilt::JSTemplate < Tilt::Template - self.default_mime_type = "application/javascript" - - EXTENSION = "js" - - include Flowerbox::Delivery::Tilt::TemplateThatSaves - - def evaluate(scope, locals, &block) - handle_evaluate - end -end - diff --git a/lib/flowerbox/delivery/tilt/jst_template.rb b/lib/flowerbox/delivery/tilt/jst_template.rb deleted file mode 100644 index 25d96da..0000000 --- a/lib/flowerbox/delivery/tilt/jst_template.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'tilt' - -class Flowerbox::Delivery::Tilt::JSTTemplate < Sprockets::JstProcessor - EXTENSION = "jst" - - include Flowerbox::Delivery::Tilt::TemplateThatSaves - - def evaluate(scope, locals, &block) - @data = super - - p @data - - handle_evaluate - end - - def data_to_save - @data || data - end -end - diff --git a/lib/flowerbox/delivery/tilt/template_that_saves.rb b/lib/flowerbox/delivery/tilt/template_that_saves.rb deleted file mode 100644 index 4efc845..0000000 --- a/lib/flowerbox/delivery/tilt/template_that_saves.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Flowerbox::Delivery::Tilt::TemplateThatSaves - def prepare ; end - - def handle_evaluate - case File.extname(file) - when '.js' - file - else - save - end - end - - def save - FileUtils.mkdir_p File.dirname(temp_file) - File.open(temp_file, 'wb') { |fh| fh.print data_to_save } - - temp_file - end - - def data_to_save - data - end - - def temp_file - File.join(Dir.pwd, ".tmp/sprockets", file.gsub(%r{(\.#{extension})(.*)$}, '\1')) - end - - def extension - self.class::EXTENSION - end - - def evaluate(scope, locals, &block) - handle_evaluate - end -end -