<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,6 +20,11 @@ Rake::TestTask.new(:test) do |t|
   t.verbose = true
 end
 
+desc &quot;Clean the docs directory&quot;
+task :clean_docs do
+  `rm -rf doc/`
+end
+
 desc 'Generate documentation for the squirrel plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'doc'
@@ -28,3 +33,9 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_files.include('README')
   rdoc.rdoc_files.include('lib/**/*.rb')
 end
+
+desc 'Update documentation on website'
+task :sync_docs =&gt; [:clean_docs, :rdoc] do
+  `rsync -ave ssh doc/ dev@dev.thoughtbot.com:/home/dev/www/dev.thoughtbot.com/squirrel`
+end
+</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,51 @@
 module Squirrel
+  # The WillPagination module emulates the results that the will_paginate plugin returns
+  # from its #paginate methods. When it is used to extend a result set from Squirrel, it
+  # automtically pulls the result from the pagination that Squirrel performs. The methods
+  # added to that result set make it duck-equivalent to the WillPaginate::Collection
+  # class.
+  module WillPagination
+    def self.extended base
+      base.current_page  = base.pages.current || 1
+      base.per_page      = base.pages.per_page
+      base.total_entries = base.pages.total_results
+    end
+
+    attr_accessor :current_page, :per_page, :total_entries
+
+    # Returns the current_page + 1, or nil if there are no more.
+    def next_page
+      current_page &lt; page_count ? (current_page + 1) : nil
+    end
+
+    # Returns the offset of the current page that is suitable for inserting into SQL.
+    def offset
+      (current_page - 1) * per_page
+    end
+
+    # Returns true if the current_page is greater than the total number of pages.
+    # Useful in case someone manually modifies the URL to put their own page number in.
+    def out_of_bounds?
+      current_page &gt; page_count
+    end
+
+    # The number of pages in the result set.
+    def page_count
+      pages.last
+    end
+
+    # Returns the current_page - 1, or nil if this is the first page.
+    def previous_page
+      current_page &gt; 1 ? (current_page - 1) : nil
+    end
+
+    # Sets the number of pages and entries.
+    def total_entries= total
+      @total_entries = total.to_i
+      @total_pages   = (@total_entries / per_page.to_f).ceil
+    end
+  end
+
   # The Page class holds information about the current page of results.
   class Page
     attr_reader :offset, :limit, :page, :per_page</diff>
      <filename>lib/paginator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -119,6 +119,7 @@ module Squirrel
                                                :limit =&gt; limit, 
                                                :offset =&gt; offset) )
       set.instance_variable_set(&quot;@total_results&quot;, total_results)
+      set.extend( Squirrel::WillPagination )
     end
     
     # ConditionGroups are groups of Conditions, oddly enough. They most closely map to models</diff>
      <filename>lib/squirrel.rb</filename>
    </modified>
    <modified>
      <diff>@@ -197,6 +197,23 @@ class SquirrelTest &lt; Test::Unit::TestCase
 	  assert_nil           posts.pages.previous
 	  assert_equal (1..4), posts.pages.current_range
   end
+
+  def test_will_paginator_works_like_squirrel_paginator
+	  assert posts = Post.find(:all) { id &lt;=&gt; (1..6); paginate :page =&gt; 2, :per_page =&gt; 4 }
+    [ :next_page,
+      :offset,
+      :out_of_bounds?,
+      :page_count,
+      :previous_page, 
+      :replace, 
+      :total_entries= ].each do |m|
+      assert posts.respond_to?(m)
+    end
+
+    assert_equal posts.pages.next,     posts.next_page
+    assert_equal posts.pages.previous, posts.previous_page
+    assert_equal posts.total_results,  posts.total_entries
+  end
   
   def test_passing_extra_conditions
     assert posts = Post.find(:all, :conditions =&gt; &quot;id = 3&quot;){ id &lt;=&gt; (1..6) }</diff>
      <filename>test/squirrel_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>437c20a1609acada75ac4e60aef18bd3a90b0556</id>
    </parent>
  </parents>
  <author>
    <name>jyurek</name>
    <email>jyurek@7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa</email>
  </author>
  <url>http://github.com/thoughtbot/squirrel/commit/b0f7ab674b237ff2c5b0935868299cbaccc9f569</url>
  <id>b0f7ab674b237ff2c5b0935868299cbaccc9f569</id>
  <committed-date>2008-03-24T18:44:42-07:00</committed-date>
  <authored-date>2008-03-24T18:44:42-07:00</authored-date>
  <message>Added first pass at a will_paginate compatability module.

git-svn-id: https://svn.thoughtbot.com/plugins/squirrel/trunk@408 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa</message>
  <tree>5708d7acb8e495116ed227483de64be52c080db7</tree>
  <committer>
    <name>jyurek</name>
    <email>jyurek@7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa</email>
  </committer>
</commit>
