<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,7 @@
 Gem::Specification.new do |s|
   s.name     = &quot;goodies&quot;
-  s.version  = &quot;0.2&quot;
-  s.date     = &quot;2008-01-03&quot;
+  s.version  = &quot;0.3&quot;
+  s.date     = &quot;2009-02-28&quot;
   s.summary  = &quot;Ruby's swiss army knife&quot;
   s.email    = &quot;david@axiombox.com&quot;
   s.homepage = &quot;http://github.com/damog/goodies&quot;
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
 		&quot;lib/goodies.rb&quot;,
 		&quot;lib/goodies/array.rb&quot;,
 		&quot;lib/goodies/html.rb&quot;,
-		&quot;lib/goodies/lwr.rb&quot;
+		&quot;lib/goodies/lwr-simple.rb&quot;
 	]
   s.rdoc_options = [&quot;--main&quot;, &quot;README&quot;]
   s.extra_rdoc_files = [&quot;README&quot;]</diff>
      <filename>goodies.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 # Little tribute to LWP::Simple
 require &quot;open-uri&quot;
+require &quot;tempfile&quot;
 
 module LWR
   class LWR::Simple
@@ -119,14 +120,28 @@ module Kernel
 	end
 
 	def mirror(uri, file)
-		res = nil
-		file = File.open(file, &quot;w&quot;) if file.is_a? String
-		raise ArgumentError, &quot;File object expected!&quot; unless file.is_a? File
-
 		url = LWR::Simple.normalize(uri)
 		req = Net::HTTP::Get.new(url.path)
 
-		if File.exists? file
+		case file
+			when String
+				if File.exists? file
+					file_exists = true
+				else
+					file_exists = false
+				end
+				file = File.open(file, &quot;w&quot;)
+			when File
+				if File.exists? file.path
+					file_exists = true
+				else
+					file_exists = false
+				end
+			else
+				raise ArgumentError, &quot;Failed arguments&quot;
+		end
+
+		if file_exists
 			req.add_field(&quot;If-Modified-Since&quot;, file.mtime.httpdate)
 		end
 
@@ -136,29 +151,25 @@ module Kernel
 
 		case res
 			when Net::HTTPSuccess
-				tmpfile = Tempfile.new(&quot;lwr-simple-mirror&quot;)
-				tmpfile.open do |f|
-					f.puts res.body
-				end
-				if res[&quot;content-length&quot;] and tmpfile.size &lt; res[&quot;content-length&quot;]
-					tmpfile.unlink
+				tmpfile = Tempfile.new(&quot;lwr&quot;)
+				tmpfile.print res.body
+				
+				if res[&quot;content-length&quot;] and tmpfile.size &lt; res[&quot;content-length&quot;].to_i
 					raise Exception, &quot;Transfer truncated, only #{tmpfile.size} of #{res[&quot;content-length&quot;]} bytes received&quot;
-				elsif res[&quot;content-length&quot;] and tmpfile.size &gt; res[&quot;content-length&quot;]
-					tmpfile.unlink
+					File.unlink(tmpfile.path)
+				elsif res[&quot;content-length&quot;] and tmpfile.size &gt; res[&quot;content-length&quot;].to_i
 					raise Exception, &quot;Content-length mismatch, expected #{res[&quot;content-length&quot;]} bytes, got #{tmpfile.size}&quot;
+					File.unlink(tmpfile.path)
 				else # OK
+					File.unlink(file.path) if File.exists? file.path
+					File.rename(tmpfile.path, file.path)
 
 				end
 
-
-			when Net::HTTPRedirection
-				# not supported yet
 			else
 		end
 
-
-
-		end
+		res
 
 	end
 		</diff>
      <filename>lib/goodies/lwr-simple.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>966afbb1a1cf000cd327646cff8dbd0103863519</id>
    </parent>
  </parents>
  <author>
    <name>David Moreno</name>
    <email>david@axiombox.com</email>
  </author>
  <url>http://github.com/damog/goodies/commit/b2414cd1131de50330e88c92fbc9359733689e23</url>
  <id>b2414cd1131de50330e88c92fbc9359733689e23</id>
  <committed-date>2009-02-28T12:29:19-08:00</committed-date>
  <authored-date>2009-02-28T12:29:19-08:00</authored-date>
  <message>next gem generation</message>
  <tree>b08c532f0736e4d81fdcfbdbdebaeb6b63107a1b</tree>
  <committer>
    <name>David Moreno</name>
    <email>david@axiombox.com</email>
  </committer>
</commit>
