<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,11 +2,11 @@
 
 Gem::Specification.new do |s|
   s.name = %q{annotate}
-  s.version = &quot;2.2.3&quot;
+  s.version = &quot;2.2.5&quot;
 
   s.required_rubygems_version = Gem::Requirement.new(&quot;&gt;= 0&quot;) if s.respond_to? :required_rubygems_version=
   s.authors = [&quot;Marcos Piccinini&quot;]
-  s.date = %q{2008-12-26}
+  s.date = %q{2008-12-28}
   s.default_executable = %q{annotate}
   s.description = %q{Annotates Rails Models and Routes}
   s.email = [&quot;x@nofxx.com&quot;]
@@ -26,14 +26,14 @@ Gem::Specification.new do |s|
     s.specification_version = 2
 
     if Gem::Version.new(Gem::RubyGemsVersion) &gt;= Gem::Version.new('1.2.0') then
-      s.add_development_dependency(%q&lt;newgem&gt;, [&quot;&gt;= 1.2.1&quot;])
+      s.add_development_dependency(%q&lt;newgem&gt;, [&quot;&gt;= 1.2.2&quot;])
       s.add_development_dependency(%q&lt;hoe&gt;, [&quot;&gt;= 1.8.0&quot;])
     else
-      s.add_dependency(%q&lt;newgem&gt;, [&quot;&gt;= 1.2.1&quot;])
+      s.add_dependency(%q&lt;newgem&gt;, [&quot;&gt;= 1.2.2&quot;])
       s.add_dependency(%q&lt;hoe&gt;, [&quot;&gt;= 1.8.0&quot;])
     end
   else
-    s.add_dependency(%q&lt;newgem&gt;, [&quot;&gt;= 1.2.1&quot;])
+    s.add_dependency(%q&lt;newgem&gt;, [&quot;&gt;= 1.2.2&quot;])
     s.add_dependency(%q&lt;hoe&gt;, [&quot;&gt;= 1.8.0&quot;])
   end
 end</diff>
      <filename>annotate.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,7 @@ end.parse!
 
 begin
   Rake::Task[task].invoke
+  #TODO: rescue only rake error
 rescue NameError =&gt; e
   puts &quot;Can`t find Rake. Are we in a Rails folder?&quot;
 end</diff>
      <filename>bin/annotate</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
   $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
 
 module Annotate
-  VERSION = '2.2.3'
+  VERSION = '2.2.5'
 end
 
 begin</diff>
      <filename>lib/annotate.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,21 +17,22 @@
 # Released under the same license as Ruby. No Support. No Warranty.module AnnotateRoutes
 #
 module AnnotateRoutes 
-  PREFIX = &quot;#== Route Info&quot;
+  PREFIX = &quot;#== Route Map&quot;
   
   def self.do_annotate 
     routes_rb = File.join(&quot;config&quot;, &quot;routes.rb&quot;)
-    header = PREFIX + &quot;\n# Generated on #{Time.now}\n#&quot;
+    header = PREFIX + &quot;\n# Generated on #{Time.now.strftime(&quot;%d %b %Y %H:%M&quot;)}\n#&quot;
     if File.exists? routes_rb
       routes_map = `rake routes`
       routes_map = routes_map.split(&quot;\n&quot;)
       routes_map.shift # remove the first line of rake routes which is just a file path
       routes_map = routes_map.inject(header){|sum, line| sum&lt;&lt;&quot;\n# &quot;&lt;&lt;line}
       content = File.read(routes_rb)
-      content = content.split(/^#== Route Info.*?\n/)#, '')
+      content, old = content.split(/^#== Route .*?\n/)
       File.open(routes_rb, &quot;wb&quot;) do |f| 
-        f.puts content[0] + &quot;\n\n&quot; + routes_map 
+        f.puts content.sub!(/\n?\z/, &quot;\n&quot;) + routes_map 
       end
+      puts &quot;Route file annotated.&quot;
     else
       puts &quot;Can`t find routes.rb&quot;
     end</diff>
      <filename>lib/annotate/annotate_routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,24 +7,41 @@ describe AnnotateRoutes do
     @mock_file ||= mock(File, stubs)
   end
 
-  it &quot;should check if routes.rb exists&quot; do
-    File.should_receive(:join).with(&quot;config&quot;, &quot;routes.rb&quot;).and_return(mock_file)
-    File.should_receive(:exists?).with(@mock_file).and_return(false)
-    AnnotateRoutes.should_receive(:puts).with(&quot;Can`t find routes.rb&quot;)
+  describe &quot;Annotate Job&quot; do
 
-    AnnotateRoutes.do_annotate
-  end
+    before(:each) do
+      File.should_receive(:join).with(&quot;config&quot;, &quot;routes.rb&quot;).and_return(&quot;config/routes.rb&quot;)
+    end
 
-  it &quot;should annotate!&quot; do
-    File.should_receive(:join).with(&quot;config&quot;, &quot;routes.rb&quot;).and_return(&quot;config/routes.rb&quot;)
-    File.should_receive(:exists?).with(&quot;config/routes.rb&quot;).and_return(true)
-    AnnotateRoutes.should_receive(:`).with(&quot;rake routes&quot;).and_return(&quot;bad line\ngood line&quot;)
-    File.should_receive(:read).with(&quot;config/routes.rb&quot;).and_return(&quot;bla&quot;)
-    File.should_receive(:open).with(&quot;config/routes.rb&quot;, &quot;wb&quot;).and_yield(mock_file)
-    @mock_file.should_receive(:puts).with(/bla\n\n#== Route Info\n# Generated on .*\n#\n# good line/)
+    it &quot;should check if routes.rb exists&quot; do
+      File.should_receive(:exists?).with(&quot;config/routes.rb&quot;).and_return(false)
+      AnnotateRoutes.should_receive(:puts).with(&quot;Can`t find routes.rb&quot;)
+      AnnotateRoutes.do_annotate
+    end
 
-    AnnotateRoutes.do_annotate
-  end
+    describe &quot;When Annotating&quot; do
+
+      before(:each) do
+        File.should_receive(:exists?).with(&quot;config/routes.rb&quot;).and_return(true)
+        AnnotateRoutes.should_receive(:`).with(&quot;rake routes&quot;).and_return(&quot;bad line\ngood line&quot;)
+        File.should_receive(:open).with(&quot;config/routes.rb&quot;, &quot;wb&quot;).and_yield(mock_file)
+        AnnotateRoutes.should_receive(:puts).with(&quot;Route map annotated.&quot;)
+      end
+
+      it &quot;should annotate and add a newline!&quot; do
+        File.should_receive(:read).with(&quot;config/routes.rb&quot;).and_return(&quot;ActionController::Routing...\nfoo&quot;)
+        @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n#== Route Map\n# Generated on .*\n#\n# good line/)
+        AnnotateRoutes.do_annotate
+      end
 
+      it &quot;should not add a newline if there are empty lines&quot; do
+        File.should_receive(:read).with(&quot;config/routes.rb&quot;).and_return(&quot;ActionController::Routing...\nfoo\n&quot;)
+        @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n#== Route Map\n# Generated on .*\n#\n# good line/)
+        AnnotateRoutes.do_annotate
+      end
+
+    end
+
+  end
 
 end</diff>
      <filename>spec/annotate/annotate_routes_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>63467863eb5e4a45027cdcc2105eca48ca88a428</id>
    </parent>
  </parents>
  <author>
    <name>Marcos Augusto</name>
    <email>x@nofxx.com</email>
  </author>
  <url>http://github.com/nclark/annotate_models/commit/ed05a78ef537d9be1d0efeb39de810420a4f7178</url>
  <id>ed05a78ef537d9be1d0efeb39de810420a4f7178</id>
  <committed-date>2008-12-27T18:49:07-08:00</committed-date>
  <authored-date>2008-12-27T18:49:07-08:00</authored-date>
  <message>dont add whitespace on routes, and some minor stuff</message>
  <tree>2c47af6fe5407fbdb763aaa5cc7b4b6aecc20eab</tree>
  <committer>
    <name>Marcos Augusto</name>
    <email>x@nofxx.com</email>
  </committer>
</commit>
