don't do things twice, it wastes time

This commit is contained in:
John Bintz 2011-06-10 11:35:54 -04:00
parent 5e1520a732
commit 26675216ad

View File

@ -15,6 +15,8 @@ module Jasmine
@files = DEFAULT_FILES.dup @files = DEFAULT_FILES.dup
@filtered_files = @files.dup @filtered_files = @files.dup
use_config! if config? use_config! if config?
@code_for_file = {}
end end
def use_spec?(file) def use_spec?(file)
@ -36,7 +38,9 @@ module Jasmine
private private
def to_html(files) def to_html(files)
files.collect { |file| files.collect { |file|
case File.extname(file) next @code_for_file[file] if @code_for_file[file]
@code_for_file[file] = (case File.extname(file)
when '.js' when '.js'
%{<script type="text/javascript" src="#{file}"></script>} %{<script type="text/javascript" src="#{file}"></script>}
when '.coffee' when '.coffee'
@ -50,7 +54,7 @@ module Jasmine
end end
when '.css' when '.css'
%{<link rel="stylesheet" href="#{file}" type="text/css" />} %{<link rel="stylesheet" href="#{file}" type="text/css" />}
end end)
} }
end end