diff --git a/ext/jasmine-webkit-specrunner/Runner.cpp b/ext/jasmine-webkit-specrunner/Runner.cpp index 66943a5..fb455ef 100644 --- a/ext/jasmine-webkit-specrunner/Runner.cpp +++ b/ext/jasmine-webkit-specrunner/Runner.cpp @@ -66,7 +66,8 @@ void Runner::loadSpec() QVectorIterator iterator(reportFiles); while (iterator.hasNext()) { - QFile *outputFile = new QFile(iterator.next()); + QString fileName = iterator.next(); + QFile *outputFile = new QFile(fileName); outputFile->open(QIODevice::WriteOnly); outputFiles.enqueue(outputFile); } @@ -157,6 +158,14 @@ void Runner::print(const QString &fh, const QString &content) { } } +void Runner::printFile(const QString &fileName, const QString &content) { + QFile *outputFile = new QFile(fileName); + outputFile->open(QIODevice::WriteOnly); + QTextStream ts(outputFile); + ts << qPrintable(content); + ts.flush(); +} + void Runner::finishSuite() { isFinished = true; runs = 0; diff --git a/ext/jasmine-webkit-specrunner/Runner.h b/ext/jasmine-webkit-specrunner/Runner.h index 3f1f01b..024e362 100644 --- a/ext/jasmine-webkit-specrunner/Runner.h +++ b/ext/jasmine-webkit-specrunner/Runner.h @@ -40,6 +40,7 @@ class Runner: public QObject { QString getSeed(); void print(const QString &fh, const QString &content); + void printFile(const QString &fileName, const QString &content); void finishSuite(); void ping(); diff --git a/lib/jasmine/headless.rb b/lib/jasmine/headless.rb index 0a60efa..4503e8e 100644 --- a/lib/jasmine/headless.rb +++ b/lib/jasmine/headless.rb @@ -24,6 +24,7 @@ module Jasmine autoload :CoffeeTemplate, 'jasmine/headless/coffee_template' autoload :JSTemplate, 'jasmine/headless/js_template' + autoload :JSTTemplateCache, 'jasmine/headless/jst_template_cache' autoload :JSTTemplate, 'jasmine/headless/jst_template' autoload :CSSTemplate, 'jasmine/headless/css_template' autoload :NilTemplate, 'jasmine/headless/nil_template' @@ -58,4 +59,3 @@ module Jasmine end require 'jasmine/headless/errors' - diff --git a/lib/jasmine/headless/jst_template.rb b/lib/jasmine/headless/jst_template.rb index b6d8f1c..9ef20b2 100644 --- a/lib/jasmine/headless/jst_template.rb +++ b/lib/jasmine/headless/jst_template.rb @@ -8,7 +8,21 @@ module Jasmine::Headless alert_bad_format(file) return '' end - %{} + begin + data = super + cache = Jasmine::Headless::JSTTemplateCache.new(file, data) + + source = cache.handle + if cache.cached? + %{ + } + else + %{} + end + rescue StandardError => e + puts "[%s] Error in compiling file: %s" % [ 'jst'.color(:red), file.color(:yellow) ] + raise e + end end end end diff --git a/lib/jasmine/headless/jst_template_cache.rb b/lib/jasmine/headless/jst_template_cache.rb new file mode 100644 index 0000000..ff7dcdc --- /dev/null +++ b/lib/jasmine/headless/jst_template_cache.rb @@ -0,0 +1,26 @@ +require 'sprockets/jst_processor' +require 'digest/sha1' +require 'fileutils' + +module Jasmine + module Headless + class JSTTemplateCache < CacheableAction + + def initialize(file, data) + @file = file + @data = data + end + + class << self + def cache_type + "jst_template" + end + end + + def action + @data + end + end + end +end + diff --git a/lib/jasmine/headless/template_writer.rb b/lib/jasmine/headless/template_writer.rb index 81562a5..487b613 100644 --- a/lib/jasmine/headless/template_writer.rb +++ b/lib/jasmine/headless/template_writer.rb @@ -49,7 +49,8 @@ module Jasmine::Headless end def jhw_reporters - reporters.collect do |reporter, output| + reporters.collect do |reporter, report, output| + output = output || "spec/reports" %{jasmine.getEnv().addReporter(new jasmine.HeadlessReporter.#{reporter}("#{output}"));} end.join("\n") end diff --git a/skel/template.html.erb b/skel/template.html.erb index 644dde9..7525bc1 100644 --- a/skel/template.html.erb +++ b/skel/template.html.erb @@ -68,7 +68,6 @@ checker(); }); } - jasmine.getEnv().execute(); }