<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,9 +1,255 @@
-# Can Touch This
+# by_*
 
-Can Touch This is a permissions system extracted from rboard.
 
-## How can I touch this?
+by_* (byStar) is a plugin that allows you to find ActiveRecord objects given certain date objects. This was originally crafted for only finding objects within a given month, but now has extended out to much more. It now supports finding objects for:
 
-You need to `include CanTouchThis` in the model you want to have permissions on (in rboard, this is the User model).
+* A given year
+* A given month
+* A given fortnight
+* A given week
+* A given weekend
+* A given day
+* Between certain times
+* As of a certain time
+* Up to a certain time
 
-You'll also need to create two tables: `groups` and `group_(your model's pluralized name)` (in rboard, group_users). Here's the schema until I can find a nicer way.
\ No newline at end of file
+
+It also allows you to do nested finds on the records returned which I personally think is the coolest feature of the whole plugin:
+   
+    Post.by_month(1) do
+      { :include =&gt; &quot;tags&quot;, :conditions =&gt; [&quot;tags.name = ?&quot;, 'ruby'] }
+    end
+    
+If you're not using the standard `created_at` field: don't worry! I've covered that scenario too.
+
+
+## By Year
+
+To find records based on a year you can pass it a two or four digit number:
+    
+    Post.by_year(09)
+    
+This will return all posts in 2009, whereas:
+
+    Post.by_year(99)
+
+will return all the posts in the year 1999.
+
+## By Month
+
+If you know the number of the month you want:
+ 
+    Post.by_month(1)
+    
+This will return all posts in the first month (January) of the current year.
+
+If you like being verbose:
+
+    Post.by_month(&quot;January&quot;)
+
+This will return all posts created in January of the current year. 
+
+If you want to find all posts in January of last year just do 
+    
+    Post.by_month(1, :year =&gt; 2007)
+    
+or
+    
+    Post.by_month(&quot;January&quot;, :year =&gt; 2007)
+  
+This will perform a find using the column you've specified.
+
+If you have a Time object you can use it to find the posts:
+
+     Post.by_month(Time.local(2008, 11, 24))
+     
+This will find all the posts in November 2008.
+
+## By Fortnight
+
+Fortnight numbering starts at 0.
+
+To find records from the current fortnight:
+    
+    Post.by_fortnight
+    
+To find records based on a fortnight, you can pass in a number (representing the fortnight number) or a time object:
+
+    Post.by_fortnight(18)
+   
+This will return all posts in the 18th fortnight of the current year.
+
+    Post.by_fortnight(18, :year =&gt; 2008)
+    
+This will return all posts in the 18th fortnight week of 2008.
+
+    Post.by_fortnight(Time.local(2008,1,1))
+    
+This will return all posts from the first fortnight of 2008.
+
+## By Week
+
+Week numbering starts at 0.
+
+To find records from the current week:
+
+    Post.by_week
+    
+To find records based on a week, you can pass in a number (representing the week number) or a time object:
+
+    Post.by_week(36)
+   
+This will return all posts in the 36th week of the current year.
+
+    Post.by_week(36, :year =&gt; 2008)
+    
+This will return all posts in the 36th week of 2008.
+
+    Post.by_week(Time.local(2008,1,1))
+    
+This will return all posts from the first week of 2008.
+
+## By Weekend
+
+If the time passed in (or the time now is a weekend) it will return posts from 12am Saturday to 11:59:59PM Sunday. If the time is a week day, it will show all posts for the coming weekend.
+
+    Post.by_weekend(Time.now)
+   
+## By Day
+
+To find records for today:
+    
+    Post.by_day
+    Post.today
+    
+To find records for a certain day:
+
+    Post.by_day(Time.local(2008, 1, 1))
+
+You can also pass a string:
+    
+    Post.by_day(&quot;next tuesday&quot;)
+   
+This will return all posts for the given day.
+
+
+## Tomorrow
+
+To find all posts from the day after the current date:
+
+    Post.tomorrow
+    
+To find all posts after a given Date or Time object:
+    
+    Post.tomorrow(Date.today + 2)
+    Post.tomorrow(Time.now + 5.days)
+    
+You can also pass a string:
+ 
+    Post.tomorrow(&quot;next tuesday&quot;)
+    
+## Yesterday
+
+To find all posts from the day before the current date:
+
+    Post.yesterday
+    
+To find all posts before a given Date or Time object:
+    
+    Post.yesterday(Date.today + 2)
+    Post.yesterday(Time.now + 5.days)
+    
+You can also pass a string:
+ 
+    Post.yesterday(&quot;next tuesday&quot;)
+    
+## Past
+
+To find all posts before the current time:
+
+    Post.past
+
+To find all posts before certain time or date:
+
+    Post.past(Date.today + 2)
+    Post.past(Time.now + 5.days)
+    
+You can also pass a string:
+
+    Post.past(&quot;next tuesday&quot;)
+
+## Future
+
+To find all posts after the current time:
+
+    Post.future
+
+To find all posts after certain time or date:
+
+    Post.future(Date.today + 2)
+    Post.future(Time.now + 5.days)
+    
+You can also pass a string:
+
+    Post.future(&quot;next tuesday&quot;)
+    
+## Between
+
+To find records between two times:
+
+    Post.between(time1, time2)
+    
+Also works with dates:
+    
+    Post.between(date1, date2)
+    
+And with strings:
+
+    Post.between(&quot;last tuesday&quot;, &quot;next wednesday&quot;)
+    
+## As of
+
+To find records as of a certain date up until the current time:
+    
+    Post.as_of_2_weeks_ago
+    
+This uses the Chronic &quot;human mind reading&quot; (read: it's really good at determining what time you mean using written English) library to work it out.
+
+## Up to
+
+To find records up to a certain time from the current time:
+
+    Post.up_to_6_weeks_from_now
+
+## Not using created_at? No worries!
+
+If your database uses something other than `created_at` for storing a timestamp, you can specify the field option like this:
+
+    Post.by_month(&quot;January&quot;, :field =&gt; :something_else)
+    
+All methods support this extra option.
+
+## Scoping the find
+
+All the `by_*` methods takes a block which will then scope the find based on the options passed into it. The supported options are the same options that are supported by `ActiveRecord::Base.find`:
+
+     Post.by_month(1) do
+       { :include =&gt; &quot;tags&quot;, :conditions =&gt; [&quot;tags.name = ?&quot;, 'ruby'] }
+     end
+## &quot;Chronicable string&quot;
+
+This means a string that can be parsed with the Chronic gem.
+     
+## Collaborators
+  
+Unfortunately I forget who exactly prompted me to write the plugin, but I would like to thank #rubyonrails for their support and the following people:
+
+* Mislav Marohnic
+* August Lilleas (leethal)
+* gte351s
+* Thomase Sinclair (anathematic)
+* The dude(s) &amp; gal(s) who created Chronic
+     
+## Suggestions?
+
+If you have suggestions, please contact me at radarlistener@gmail.com
\ No newline at end of file</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,10 @@
-# encoding: utf-8
 desc &quot;generates .gemspec file&quot;
 task :gemspec =&gt; &quot;version:read&quot; do
   spec = Gem::Specification.new do |gem|
-    gem.name = &quot;can_touch_this&quot;
+    gem.name = &quot;by_star&quot;
     gem.summary = &quot;ActiveRecord extension for easier date scopes and time ranges&quot;
     gem.email = &quot;mislav.marohnic@gmail.com&quot;
-    gem.homepage = &quot;http://github.com/mislav/can_touch_this&quot;
+    gem.homepage = &quot;http://github.com/mislav/by_star&quot;
     gem.authors = [&quot;Mislav Marohni&#263;&quot;, &quot;Ryan Bigg&quot;]
     gem.has_rdoc = true
     
@@ -47,10 +46,10 @@ Spec::Rake::SpecTask.new do |t|
   t.ruby_opts &lt;&lt; &quot;-rubygems&quot;
 end
 
-desc 'Generate documentation for the can_touch_this plugin.'
+desc 'Generate documentation for the by_star plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'rdoc'
-  rdoc.title    = 'Can Touch This'
+  rdoc.title    = 'ByStar'
   rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
   rdoc.rdoc_files.include('README')
   rdoc.rdoc_files.include('lib/**/*.rb')</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,2 @@
-require 'can_touch_this'
-# Thanks to those who have worked on nested_has_many_through
-# Without this, it wouldn't be possible!
-require 'nested_has_many_through'
-
-ActiveRecord::Associations::HasManyThroughAssociation.send :include, NestedHasManyThrough::Association
- 
-# BC
-if defined?(ActiveRecord::Reflection::ThroughReflection)
-  ActiveRecord::Reflection::ThroughReflection.send :include, NestedHasManyThrough::Reflection
-else
-  ActiveRecord::Reflection::AssociationReflection.send :include, NestedHasManyThrough::Reflection
-end
\ No newline at end of file
+require 'by_star'
+ActiveRecord::Base.send :include, ByStar
\ No newline at end of file</diff>
      <filename>rails/init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,58 +1,70 @@
+class Post &lt; ActiveRecord::Base
+  default_scope :order =&gt; &quot;#{quoted_table_name}.created_at ASC&quot;
+  has_and_belongs_to_many :tags
+  
+  def self.factory(text, created_at = nil)
+    create!(:text =&gt; text, :created_at =&gt; created_at)
+  end
+end
 
-require 'app/models/group'
+class Tag &lt; ActiveRecord::Base
+  has_and_belongs_to_many :posts
+end
 
-class GroupUser &lt; ActiveRecord::Base
-  belongs_to :group
-  belongs_to :user
+class Event &lt; ActiveRecord::Base
+  named_scope :private, :conditions =&gt; { :public =&gt; false }
 end
 
-require 'app/models/permission'
+## seed data:
 
-class Permission &lt; ActiveRecord::Base
-  belongs_to :thing
-  belongs_to :category
-end
+year = Time.zone.now.year
 
-class Thing &lt; ActiveRecord::Base
-  has_many :permissions
-  has_many :groups, :through =&gt; :permissions
-  has_many :users, :through =&gt; :groups
-  
-  belongs_to :category
-  
-  acts_as_tree
+1.upto(12) do |month|
+  month.times do |n|
+    Post.factory &quot;post #{n}&quot;, Time.local(year, month, 1)
+  end
 end
 
-class Category &lt; ActiveRecord::Base
-  has_many :things
-end
+Post.factory &quot;Today's post&quot;, Time.zone.now
+Post.factory &quot;Yesterday's post&quot;, Time.zone.now - 1.day
+Post.factory &quot;Tomorrow's post&quot;, Time.zone.now + 1.day
 
-class User &lt; ActiveRecord::Base
-  include CanTouchThis
-end
+Post.factory &quot;That's it!&quot;, Time.zone.now.end_of_year
+
+# For by_weekend scoped test
+post = Post.factory &quot;Weekend of May&quot;, &quot;16-05-2009&quot;.to_time
+post.tags.create(:name =&gt; &quot;weekend&quot;)
+
+# For by_day scoped test
+post = Post.factory &quot;Today&quot;, Time.zone.now
+post.tags.create(:name =&gt; &quot;today&quot;)
 
-thing = Thing.create!(:name =&gt; &quot;it&quot;)
-sub_thing = Thing.create!(:name =&gt; &quot;subby&quot;, :parent =&gt; thing)
+# For yesterday scoped test
+post = Post.factory &quot;Yesterday&quot;, Time.zone.now.yesterday
+post.tags.create(:name =&gt; &quot;yesterday&quot;)
 
-mc_hammer = Category.create!(:name =&gt; &quot;MC Hammer&quot;)
-the_song = mc_hammer.things.create!(:name =&gt; &quot;Can't Touch This&quot;)
+# For tomorrow scoped test
+post = Post.factory &quot;Tomorrow's Another Day&quot;, Time.zone.now.tomorrow
+post.tags.create(:name =&gt; &quot;tomorrow&quot;)
 
-user = User.create!(:login =&gt; &quot;radar&quot;, :password =&gt; &quot;sekret&quot;)
+post = Post.factory &quot;Last year&quot;, Time.local(year - 1, 1, 1)
+post.tags.create(:name =&gt; &quot;ruby&quot;)
 
-group = Group.create!(:name =&gt; &quot;Users&quot;)
-group.users &lt;&lt; user
-group.permissions.create!(:can_touch_this =&gt; true)
-group.permissions.create!(:can_touch_this =&gt; false, :thing =&gt; thing)
+post = Post.factory &quot;The 'Current' Fortnight&quot;, Time.local(year, 5, 15)
+post.tags.create(:name =&gt; &quot;may&quot;)
 
-user2 = User.create!(:login =&gt; &quot;you&quot;,  :password =&gt; &quot;people&quot;)
+post = Post.factory &quot;The 'Current' Week&quot;, Time.local(year, 5, 15)
+post.tags.create(:name =&gt; &quot;may2&quot;)
 
-other_group = Group.create!(:name =&gt; &quot;Others&quot;)
-other_group.users &lt;&lt; user2
-other_group.permissions.create!(:can_touch_this =&gt; true)
-other_group.permissions.create!(:can_touch_this =&gt; false, :thing =&gt; thing)
-other_group.permissions.create!(:can_touch_this =&gt; true, :thing =&gt; sub_thing)
-other_group.permissions.create!(:can_touch_this =&gt; false, :category =&gt; mc_hammer)
-other_group.permissions.create!(:can_touch_this =&gt; true, :thing =&gt; the_song)
 
+Event.create(:name =&gt; &quot;Ryan's birthday!&quot;, :start_time  =&gt; &quot;04-12-#{Time.zone.now.year}&quot;.to_time)
+Event.create(:name =&gt; &quot;Dad's birthday!&quot;,  :start_time  =&gt; &quot;05-07-#{Time.zone.now.year}&quot;.to_time)
+Event.create(:name =&gt; &quot;Mum's birthday!&quot;,  :start_time  =&gt; &quot;17-11-#{Time.zone.now.year}&quot;.to_time)
+Event.create(:name =&gt; &quot;Today&quot;,            :start_time  =&gt; Time.zone.now)
+Event.create(:name =&gt; &quot;Yesterday&quot;,        :start_time  =&gt; Time.zone.now - 1.day)
+Event.create(:name =&gt; &quot;Tomorrow&quot;,         :start_time  =&gt; Time.zone.now + 1.day)
 
+# For by_weekend test
+Event.create(:name =&gt; &quot;1st of August&quot;,    :start_time  =&gt; &quot;01-08-#{Time.zone.now.year}&quot;.to_time)
 
+Event.create(:name =&gt; &quot;FBI meeting&quot;,      :start_time  =&gt; &quot;02-03-#{Time.zone.now.year}&quot;.to_time, :public =&gt; false)
\ No newline at end of file</diff>
      <filename>spec/fixtures/models.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,38 +1,24 @@
 ActiveRecord::Schema.define do
   self.verbose = false
   
-  create_table &quot;categories&quot;, :force =&gt; true do |t|
-    t.string &quot;name&quot;
+  create_table :posts, :force =&gt; true do |t|
+    t.string :text
+    t.timestamps
   end
   
-  create_table &quot;groups&quot;, :force =&gt; true do |t|
-    t.string  &quot;name&quot;
-    t.integer &quot;owner_id&quot;
+  create_table :posts_tags, :force =&gt; true do |t|
+    t.integer :post_id, :tag_id
   end
   
-  create_table &quot;group_users&quot;, :force =&gt; true do |t|
-    t.integer &quot;group_id&quot;
-    t.integer &quot;user_id&quot;
+  create_table :tags, :force =&gt; true do |t|
+    t.string :name
+    t.timestamps
   end
   
-  create_table &quot;permissions&quot;, :force =&gt; true do |t|
-    t.boolean &quot;can_touch_this&quot;,                   :default =&gt; false
-    t.boolean &quot;can_stop_hammer_time&quot;,             :default =&gt; false
-    t.boolean &quot;can_has_back&quot;,                     :default =&gt; false
-    t.integer &quot;group_id&quot;
-    t.integer &quot;thing_id&quot;
-    t.integer &quot;category_id&quot;
+  create_table :events, :force =&gt; true do |t|
+    t.datetime :start_time, :end_time
+    t.string :name
+    t.boolean :public, :default =&gt; true
   end
   
-  create_table &quot;things&quot; do |t|
-    t.string &quot;name&quot;
-    t.integer &quot;parent_id&quot;
-    t.integer &quot;category_id&quot;
-  end
-  
-  create_table &quot;users&quot;, :force =&gt; true do |t|
-    t.string &quot;login&quot;
-    t.string &quot;password&quot;
-  end
-
 end
\ No newline at end of file</diff>
      <filename>spec/fixtures/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,5 @@
 require 'rubygems'
 require 'activerecord'
-require 'acts_as_tree'
-ActiveRecord::Base.send :include, ActsAsTree
 
 ActiveRecord::Base.establish_connection(
   :adapter  =&gt; &quot;sqlite3&quot;,
@@ -10,7 +8,7 @@ ActiveRecord::Base.establish_connection(
 $:.unshift(File.join(File.dirname(__FILE__), &quot;../lib&quot;))
 
 require 'activesupport'
-require 'can_touch_this'
+require 'by_star'
 require 'spec'
 
 # Define time zone before loading test_helper</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>app/models/group.rb</filename>
    </removed>
    <removed>
      <filename>app/models/permission.rb</filename>
    </removed>
    <removed>
      <filename>can_touch_this.gemspec</filename>
    </removed>
    <removed>
      <filename>lib/can_touch_this.rb</filename>
    </removed>
    <removed>
      <filename>lib/nested_has_many_through.rb</filename>
    </removed>
    <removed>
      <filename>spec/acts_as_tree.rb</filename>
    </removed>
    <removed>
      <filename>spec/can_touch_this_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f9e4513e0057056c5f21f887b003e46cf69d1898</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Bigg</name>
    <email>radarlistener@gmail.com</email>
  </author>
  <url>http://github.com/radar/by_star/commit/5b14da70a2d19260ffc6de03964c59662592aed3</url>
  <id>5b14da70a2d19260ffc6de03964c59662592aed3</id>
  <committed-date>2009-07-10T23:06:55-07:00</committed-date>
  <authored-date>2009-07-10T23:06:55-07:00</authored-date>
  <message>Whoops, forgot to rm the .git directory.

Revert &quot;first commit&quot;

This reverts commit f9e4513e0057056c5f21f887b003e46cf69d1898.</message>
  <tree>278212916476c23108a30e75f939dde774634d72</tree>
  <committer>
    <name>Ryan Bigg</name>
    <email>radarlistener@gmail.com</email>
  </committer>
</commit>
