<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/activerecord/association_preload.rb</filename>
    </added>
    <added>
      <filename>lib/activerecord/base_ext.rb</filename>
    </added>
    <added>
      <filename>lib/activerecord/calculations_ext.rb</filename>
    </added>
    <added>
      <filename>lib/activerecord/connection_adapters/abstract/database_statements_ext.rb</filename>
    </added>
    <added>
      <filename>lib/activerecord/connection_adapters/mysql_adapter_ext.rb</filename>
    </added>
    <added>
      <filename>lib/activerecord/connection_adapters/sqlite3_adapter_ext.rb</filename>
    </added>
    <added>
      <filename>lib/activerecord/connection_adapters/sqlite_adapter_ext.rb</filename>
    </added>
    <added>
      <filename>spec/fixtures/schema.rb</filename>
    </added>
    <added>
      <filename>spec/sql_display_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,26 +1,23 @@
 # sql_display
 
-For when you want to display the SQL a query executes, but don't want to go into the model!
+For when you want to display the SQL a query executes, but don't want to go into the log!
 
-# Usage
+## Works with
 
-    ActiveRecord::Base.sql do
-      Post.all
-    end
-    =&gt; &quot;SELECT * FROM posts&quot;
-    
-which will display queries to all models, or
+Currently only works with mysql and sqlite adapters. More coming soon!
+
+## Usage
 
-    YourModel.sql do
-      Post.all
+    YourModel.sql
+      YourModel.all
     end
-    =&gt; &quot;SELECT * FROM posts&quot;
-    
 
+This will show you the output of the call inside the block, without actually running it. You are only able to do one call per block, as it will only display the query for the last call inside the block.
+
+## Broken Things
 
-which will display queries to YourModel only.
-    
-But I'm sure a smart cookie / muffin such as you already knew that.
+Currently doesn't work with :joins.
 
-These methods can be called in models, controllers, helpers, views and external libraries.
+## Contributors
 
+perplect</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
 test:
   adapter: sqlite3
-  database: tmp/sql_display.sqlite
\ No newline at end of file
+  database: ':memory:'
\ No newline at end of file</diff>
      <filename>config/database.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-ActiveRecord::Base.send :include, SqlDisplay
\ No newline at end of file
+require 'sql_display'
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,10 @@
-module SqlDisplay    
-  def self.included(base)
-    base.extend ClassMethods
-  end
-  
-  module ClassMethods
-    def sql(&amp;block)
-      target = self.class == ActiveRecord::Base ? ActiveRecord::Base : self
-      old_logger = target.logger
-      target.logger = ActiveSupport::BufferedLogger.new(&quot;tmp/sql_display.log&quot;)
-      target.logger.level = Logger::DEBUG
-      target.establish_connection(YAML::load_file(&quot;#{RAILS_ROOT}/config/database.yml&quot;)[RAILS_ENV])
-      logger.info(&quot;\n&quot;)
-      yield
-      output = File.readlines(&quot;tmp/sql_display.log&quot;).map do |line|
-        # remove the crap
-        line.gsub(/\[.*?m/, &quot;&quot;).gsub(&quot;\e&quot;, &quot;&quot;).gsub(/^.*? \(.*?\)/, '').gsub(&quot;SET SQL_AUTO_IS_NULL=0\n&quot;, &quot;&quot;).strip
-      end
-      if /Logfile created/.match(output.first)
-        output -= [output.first] # Remove the standard logger header crap
-      end
-      FileUtils.rm(&quot;tmp/sql_display.log&quot;)
-      target.logger = old_logger
-      target.establish_connection(YAML::load_file(&quot;#{RAILS_ROOT}/config/database.yml&quot;)[RAILS_ENV])      
-      output.join(&quot;\n&quot;).strip
-    end
-  end
-end
+require 'activerecord/association_preload'
+require 'activerecord/base_ext'
+require 'activerecord/calculations_ext'
 
-ActiveRecord::Base.send :include, SqlDisplay
+require 'activerecord/connection_adapters/abstract/database_statements_ext'
+
+# TODO: Load the relevant adapter.
+require 'activerecord/connection_adapters/mysql_adapter_ext'
+require 'activerecord/connection_adapters/sqlite_adapter_ext'
+require 'activerecord/connection_adapters/sqlite3_adapter_ext'
\ No newline at end of file</diff>
      <filename>lib/sql_display.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,35 @@
 class Post &lt; ActiveRecord::Base
-  include SqlDisplay
-  belongs_to :user
-  has_and_belongs_to_many :tags
+  has_many :posts_tags
+  has_many :tags, :through =&gt; :posts_tags
+  
+  def self.factory(text, created_at = nil)
+    create!(:text =&gt; text, :created_at =&gt; created_at)
+  end
 end
 
 class Tag &lt; ActiveRecord::Base
-  has_and_belongs_to_many :posts
+  has_many :posts_tags
+  has_many :posts, :through =&gt; :posts_tags
 end
 
-class User &lt; ActiveRecord::Base
-  has_many :posts
-end
\ No newline at end of file
+class PostsTag &lt; ActiveRecord::Base
+  belongs_to :post
+  belongs_to :tag
+end
+
+## seed data:
+
+year = Time.now.year
+
+1.upto(12) do |month|
+  month.times do |n|
+    Post.factory &quot;post #{n}&quot;, Time.local(year, month, 1)
+  end
+end
+
+Post.factory &quot;Today's post&quot;
+Post.factory &quot;Yesterday's post&quot;, 1.day.ago.utc
+Post.factory &quot;Tomorrow's post&quot;, 1.day.from_now.utc
+
+post = Post.factory &quot;Last year&quot;, Time.local(year - 1, 1, 1)
+post.tags.create(:name =&gt; &quot;ruby&quot;)</diff>
      <filename>spec/fixtures/models.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,22 +1,20 @@
 # Inspiration gained from Thinking Sphinx's test suite.
 # Pat Allan is a genius.
-
-$:.unshift File.dirname(__FILE__) + '/../lib'
+this = File.dirname(__FILE__)
+$:.unshift this + '/../lib'
 RAILS_ENV = 'test'
 RAILS_ROOT = '.'
 require 'rubygems'
-require 'activerecord'
+require &quot;activerecord&quot;
+
+ActiveRecord::Base.establish_connection(
+  :adapter  =&gt; &quot;sqlite3&quot;,
+  :database =&gt; &quot;:memory:&quot;
+)
+
 require 'sql_display'
 require 'spec'
-require 'spec/fixtures/models'
-require 'spec/test_helper'
 
-FileUtils.mkdir_p &quot;#{Dir.pwd}/tmp&quot;
-ActiveRecord::Base.logger = Logger.new(&quot;tmp/#{RAILS_ENV}.log&quot;)
+load File.join(this, &quot;fixtures/schema.rb&quot;)
+load File.join(this, &quot;fixtures/models.rb&quot;)
 
-Spec::Runner.configure do |config|  
-  
-  test = TestHelper.new
-  test.setup_sqlite3
-  
-end</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8a3421a166ac5fe1ac44c5b89e49b131de74f929</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Bigg</name>
    <email>radarlistener@gmail.com</email>
  </author>
  <url>http://github.com/radar/sql_display/commit/2e3928652efdd7399b6ef44430e9f75a926d2de4</url>
  <id>2e3928652efdd7399b6ef44430e9f75a926d2de4</id>
  <committed-date>2009-06-14T01:36:42-07:00</committed-date>
  <authored-date>2009-06-14T01:36:42-07:00</authored-date>
  <message>Rewrite of the plugin. Better way to gather the information is to override the method calls with methods that return the query. At least, in my books it is.</message>
  <tree>055f08cb2588c4084441db180cf8d1ed2e280a5a</tree>
  <committer>
    <name>Ryan Bigg</name>
    <email>radarlistener@gmail.com</email>
  </committer>
</commit>
