From 985d08885e0ae84fffe5b2cc0da4aeb34197eaea Mon Sep 17 00:00:00 2001 From: Christian Williams & Kim Eric Mittler Date: Wed, 26 Aug 2009 10:54:16 -0700 Subject: [PATCH] Add Jasmine.cachebust. --- contrib/ruby/jasmine_runner.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/ruby/jasmine_runner.rb b/contrib/ruby/jasmine_runner.rb index 0f0eb4f0..d3810f36 100644 --- a/contrib/ruby/jasmine_runner.rb +++ b/contrib/ruby/jasmine_runner.rb @@ -43,6 +43,18 @@ module Jasmine Process.kill signal, -process_group_id # negative pid means kill process group. (see man 2 kill) end + def self.cachebust(files, root_dir="", replace=nil, replace_with=nil) + files.collect do |file_name| + real_file_name = replace && replace_with ? file_name.sub(replace, replace_with) : file_name + begin + digest = Digest::MD5.hexdigest(File.read("#{root_dir}#{real_file_name}")) + rescue + digest = "MISSING-FILE" + end + "#{file_name}?cachebust=#{digest}" + end + end + class RunAdapter def initialize(spec_files_or_proc) @spec_files_or_proc = spec_files_or_proc