<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
 $LOAD_PATH &lt;&lt; File.dirname(__FILE__) + '/terror'
 require 'rubygems'
-require 'activerecord'
+require 'dm-core'
+require 'dm-more'
 require 'sinatra'
 require 'yaml'
 require 'post'
@@ -23,27 +24,11 @@ module Terror
   
   def self.init_database    
     init_database_connection
-    init_database_tables
   end
   
   def self.init_database_connection
-    ActiveRecord::Base.establish_connection(self.config['database'][Sinatra::Application.environment.to_s])
+    DataMapper.setup(:default, self.config['database'][Sinatra::Application.environment.to_s])
+    DataMapper.auto_upgrade!
   end
-  
-  def self.init_database_tables
-    ActiveRecord::Schema.define do
-      create_table :posts do |t|
-        t.string    :title
-        t.string    :source
-        t.string    :url   
-        t.datetime  :date
-        t.datetime  :created_at
-      end
-      add_index :posts, :url
-      add_index :posts, :date
-    end
-  rescue ActiveRecord::StatementInvalid
-    # tables already exist
-  end
-  
+    
 end
\ No newline at end of file</diff>
      <filename>lib/terror.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,7 @@ module Terror
           :url =&gt; entry.url, 
           :source =&gt; feed.title, 
           :date =&gt; entry.date_published
-        ) unless Post.exists?(:url =&gt; entry.url)
+        )  unless self.get(:first, :url =&gt; entry.url)
       end
     end
     </diff>
      <filename>lib/terror/feed_fetcher.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,23 +1,31 @@
 require 'feed_fetcher'
 
 module Terror
-  class Post &lt; ActiveRecord::Base
+  class Post
+    include DataMapper::Resource
     include FeedFetcher
     
-    validates_presence_of :title, :url
-    validates_format_of   :url, :with =&gt; /^http|https:\/\//
+    property :id,     Integer,  :serial =&gt; true
+    property :title,  String,   :nullable =&gt; false
+    property :url,    String,   :nullable =&gt; false, :format =&gt; /^http|https:\/\//
+    property :source, String
+    property :date,   Date        
     
     def self.paginate(options = {})
       per_page     = options[:per_page]
       page         = options[:page].to_i &gt; 0 ? options[:page].to_i : 1
-      posts        = self.find(:all, :order =&gt; 'date DESC', :limit =&gt; per_page, :offset =&gt; per_page * (page - 1))            
+      posts        = self.all(:order =&gt; [:date.desc], :limit =&gt; per_page, :offset =&gt; per_page * (page - 1))            
       add_pagination_info(posts, per_page, page)
     end
   
     protected  
     
     def self.add_pagination_info(posts, per_page, page)
-      posts.class_eval { attr_accessor :current_page, :total_pages }      
+      posts.instance_eval do 
+        class &lt;&lt; self 
+          attr_accessor :current_page, :total_pages
+        end
+      end
       posts.total_pages   = (self.count.to_f / per_page).ceil
       posts.current_page  = page
       posts</diff>
      <filename>lib/terror/post.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,4 +3,10 @@ require 'sinatra'
 require 'sinatra/test'
 require 'spec'
 require 'spec/interop/test'
+
+disable           :run
+disable           :reload
+set :environment, :test
+set :root,        File.dirname(__FILE__) + '/../'
+
 require File.dirname(__FILE__) + '/../terror_aggregator'
\ No newline at end of file</diff>
      <filename>test/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ describe 'Test' do
   
   it 'should show posts' do
     get '/'
-    response.should be_ok    
+    response.should be_ok
   end
   
   it 'should show feed' do</diff>
      <filename>test/terror_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,14 +8,14 @@ builder do |xml|
               :rel  =&gt; 'alternate'
     xml.link  :type =&gt; 'application/atom+xml',
               :href =&gt; 'http://localhost:4567'    
-    xml.updated(rfc_3339(@posts.first ? @posts.first.created_at : Time.now))
+    xml.updated(rfc_3339(@posts.first ? @posts.first.date : Time.now))
     @posts.each do |post|
       xml.entry do |entry|
         entry.id post.url
         entry.link  :type =&gt; 'text/html',
                     :href =&gt; post.url,
                     :rel  =&gt; 'alternate'
-        entry.updated rfc_3339(post.created_at)
+        entry.updated rfc_3339(post.date)
         entry.title post.title
         entry.author do |author|
           author.name post.source</diff>
      <filename>views/feed.builder</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>37a35c8185a794f8904c21e58b9422a205439a04</id>
    </parent>
  </parents>
  <author>
    <name>Andrea Franz</name>
    <email>andrea@gravityblast.com</email>
  </author>
  <url>http://github.com/pilu/terror/commit/03391f0ccd8122db9b6f3d2111c3294b42427bac</url>
  <id>03391f0ccd8122db9b6f3d2111c3294b42427bac</id>
  <committed-date>2009-03-16T16:54:19-07:00</committed-date>
  <authored-date>2009-03-16T16:54:19-07:00</authored-date>
  <message>switched to datamapper</message>
  <tree>373214d2f3f852effb1f09ccae2bef21f73a65bb</tree>
  <committer>
    <name>Andrea Franz</name>
    <email>andrea@gravityblast.com</email>
  </committer>
</commit>
