<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,11 @@
 namespace :rewrite do
   
+  desc &quot;ensure there is a target directory for rewriting&quot;
+  task :init =&gt; :environment do
+    rewritten_folder = File.expand_path(RewriteRails.cache_folder_name())
+    File.makedirs(rewritten_folder)
+  end
+  
   desc &quot;rewrite all .rr files to .rb files&quot;
   task :all =&gt; :environment do
     `find #{RAILS_ROOT} -name &quot;*.rr&quot;`.each do |rr_path|
@@ -7,19 +13,26 @@ namespace :rewrite do
     end
   end
   
-  desc &quot;clear all cached .rb files&quot;
+  desc &quot;clear all cached .rb files and sub-folders&quot;
   task :clear =&gt; :environment do
     rewritten_folder = File.expand_path(RewriteRails.cache_folder_name())
     if rewritten_folder != File.expand_path(RAILS_ROOT)
+      # delete .rb files
       `find #{rewritten_folder} -name &quot;*.rb&quot;`.each do |rb_path|
         File.delete(rb_path.strip)
       end
+      # then subfolders
+      `find #{rewritten_folder} -name &quot;*&quot;`.map(&amp;:strip).reverse.select do |path|
+        File.directory?(path) &amp;&amp; Dir.entries(path).size == 2
+      end.reject do |path|
+        File.expand_path(path) == rewritten_folder
+      end.each { |path| Dir.rmdir(path) }
     else
       raise &quot;You cannot clear cached files if you are rewriting to the rails root: you will delete all .rb files as well&quot;
     end
   end
   
   desc &quot;prepare for deployment by rewriting all .rr files to .rb files&quot;
-  task :prepare =&gt; [:clear, :all]
+  task :prepare =&gt; [:init, :clear, :all]
   
 end
\ No newline at end of file</diff>
      <filename>tasks/rewrite.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f5fd01653bb4b11222b8f3603cc9af22ad9c1752</id>
    </parent>
  </parents>
  <author>
    <name>Reginald Braithwaite</name>
    <email>raganwald@gmail.com</email>
  </author>
  <url>http://github.com/raganwald/rewrite_rails/commit/f9d1f710c18676d23081dd5c62ceffd4ace55706</url>
  <id>f9d1f710c18676d23081dd5c62ceffd4ace55706</id>
  <committed-date>2008-12-29T04:56:08-08:00</committed-date>
  <authored-date>2008-12-29T04:55:13-08:00</authored-date>
  <message>cleans up dangling folders</message>
  <tree>44dbbfe228e2b602b0b71610858a2c09067f4c65</tree>
  <committer>
    <name>Reginald Braithwaite</name>
    <email>raganwald@gmail.com</email>
  </committer>
</commit>
