From 38327e6a95e6dad18c4a861d3019547d4732856d Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 22 Nov 2011 12:14:00 -0500 Subject: [PATCH] more cleanups for things i found that are broken --- lib/jasmine/headless.rb | 1 + lib/jasmine/headless/coffee_template.rb | 8 +++----- lib/jasmine/headless/command_line.rb | 2 ++ lib/jasmine/headless/files_list.rb | 4 +++- lib/jasmine/headless/js_template.rb | 6 +++++- lib/jasmine/headless/jst_template.rb | 10 ++++++++++ 6 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 lib/jasmine/headless/jst_template.rb diff --git a/lib/jasmine/headless.rb b/lib/jasmine/headless.rb index 05076ac..76d96ea 100644 --- a/lib/jasmine/headless.rb +++ b/lib/jasmine/headless.rb @@ -16,6 +16,7 @@ module Jasmine::Headless autoload :CoffeeTemplate, 'jasmine/headless/coffee_template' autoload :JSTemplate, 'jasmine/headless/js_template' + autoload :JSTTemplate, 'jasmine/headless/jst_template' autoload :CSSTemplate, 'jasmine/headless/css_template' autoload :Report, 'jasmine/headless/report' diff --git a/lib/jasmine/headless/coffee_template.rb b/lib/jasmine/headless/coffee_template.rb index 0cc7d95..b6764e6 100644 --- a/lib/jasmine/headless/coffee_template.rb +++ b/lib/jasmine/headless/coffee_template.rb @@ -11,12 +11,10 @@ module Jasmine::Headless cache = Jasmine::Headless::CoffeeScriptCache.new(file) source = cache.handle if cache.cached? - %{ - } + %{ + } else - %{} + %{} end rescue CoffeeScript::CompilationError => ne puts "[%s] %s: %s" % [ 'coffeescript'.color(:red), file.color(:yellow), "#{ne.message}".color(:white) ] diff --git a/lib/jasmine/headless/command_line.rb b/lib/jasmine/headless/command_line.rb index a746247..f1181a9 100644 --- a/lib/jasmine/headless/command_line.rb +++ b/lib/jasmine/headless/command_line.rb @@ -10,6 +10,8 @@ module Jasmine::Headless runner = Runner.new(options) if options[:do_list] + FilesList.reset! + files_list = FilesList.new(:config => runner.jasmine_config) files_list.files.each { |file| puts file } else diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index f34fb38..37bc782 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -44,6 +44,7 @@ module Jasmine::Headless register_engine '.coffee', Jasmine::Headless::CoffeeTemplate register_engine '.js', Jasmine::Headless::JSTemplate register_engine '.css', Jasmine::Headless::CSSTemplate + register_engine '.jst', Jasmine::Headless::JSTTemplate end end @@ -102,6 +103,7 @@ module Jasmine::Headless @sprockets_environment.append_path(path) end + @sprockets_environment.unregister_postprocessor('application/javascript', Sprockets::SafetyColons) @sprockets_environment end @@ -157,7 +159,7 @@ module Jasmine::Headless alert_time = nil end - sprockets_environment.find_asset(file, :bundle => false).to_s + sprockets_environment.find_asset(file, :bundle => false).body end.flatten.compact.reject(&:empty?) end diff --git a/lib/jasmine/headless/js_template.rb b/lib/jasmine/headless/js_template.rb index 81a2fb9..e4a134f 100644 --- a/lib/jasmine/headless/js_template.rb +++ b/lib/jasmine/headless/js_template.rb @@ -7,7 +7,11 @@ module Jasmine::Headless def prepare ; end def evaluate(scope, locals, &block) - file ? %{} : data + if data['from="jhw"'] + data + else + file ? %{} : data + end end end end diff --git a/lib/jasmine/headless/jst_template.rb b/lib/jasmine/headless/jst_template.rb new file mode 100644 index 0000000..f350686 --- /dev/null +++ b/lib/jasmine/headless/jst_template.rb @@ -0,0 +1,10 @@ +require 'sprockets/jst_processor' + +module Jasmine::Headless + class JSTTemplate < Sprockets::JstProcessor + def evaluate(*args) + %{} + end + end +end +