<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -45,7 +45,7 @@ module Html
         if status != 'Valid'
           # Reference in the stylesheets
           response.body.sub!(%r{@import &quot;./base.css&quot;}, %Q{@import &quot;#{File.dirname(w3c_url)}/base.css&quot;})
-          response_file = File.join(tmp_dir, &quot;w3c_last_response.html&quot;)
+          response_file = find_unique_path(File.join(tmp_dir, &quot;w3c_response.html&quot;))
           open(response_file, &quot;w&quot;) { |f| f.puts(response.body) }
           &quot;W3C status #{status}. Response from W3C was written to the file #{response_file}&quot;
         else
@@ -81,6 +81,20 @@ module Html
       end
       
       private
+      def self.find_unique_path(path)
+        filename = File.basename(path)
+        ext = File.extname(filename)
+        size_no_ext = filename.size - ext.size
+        filename_no_ext = filename[0, size_no_ext]
+        counter = 2
+        while File.exists?(path)
+          new_filename = [filename_no_ext, &quot;-&quot;, counter, ext].join
+          path = File.join(File.dirname(path), new_filename)
+          counter += 1
+        end
+        path
+      end
+      
       def self.create_tmp_file(name, contents = &quot;&quot;)
         tmp_file = Tempfile.new(name)
         tmp_file.puts(contents)</diff>
      <filename>lib/validator.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6cce4f3bf7d195bf0aa826d5dadf2db4cc1b697f</id>
    </parent>
  </parents>
  <author>
    <name>Peter Marklund</name>
    <email>peter_marklund@fastmail.fm</email>
  </author>
  <url>http://github.com/peter/html_test/commit/b1587795d3ac7731374ae7963de2d5178e724593</url>
  <id>b1587795d3ac7731374ae7963de2d5178e724593</id>
  <committed-date>2009-05-20T17:24:51-07:00</committed-date>
  <authored-date>2009-05-20T17:24:51-07:00</authored-date>
  <message>Write all W3c validation responses to file, not just the last one</message>
  <tree>0d5dad0795effa42d69db0ab1c78dad061c81243</tree>
  <committer>
    <name>Peter Marklund</name>
    <email>peter_marklund@fastmail.fm</email>
  </committer>
</commit>
