<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>test/exception_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,34 +4,28 @@ This plugin provides exception reporting for &quot;Loom&quot;:http://loomapp.com.
 
 h2. Usage
 
-You must sign up to Loom to use this plugin.
+You must sign up to Loom to use this plugin.  Install as a gem or a plugin.
 
-Add this to a controller in your application:
+h3. Installation
 
-&lt;pre&gt;&lt;code&gt;
-  enable_loom :email =&gt; 'alex@helicoid.net',
-              :password =&gt; 'test',
-              :url =&gt; 'http://helicoid.localhost:3000',
-              :project_id =&gt; 18,
-              :user_id =&gt; Proc.new { self.session[:user_id] },
-              :before_action =&gt; :try_to_load_account,
-              :display =&gt; :error_page
-&lt;/code&gt;&lt;/pre&gt;
+As a gem:
 
-# Add a user account to Loom to use for exception reporting
-# Then set the project ID you'd like to send reports to
-# Finally, set the URL of your Loom account (loom uses subdomains for accounts)
+&lt;code&gt;gem install loom-exceptions-rails-plugin --source=http://gems.github.com/&lt;/code&gt;
 
-The &lt;code&gt;user_id&lt;/code&gt; parameter can be used to represent your application's user.  We sometimes use this to record the email address of the customer who encountered an exception to provide them with support.
+As a plugin:
 
-The &lt;code&gt;display&lt;/code&gt; parameter references a controller action.  It will be rendered after the exception has been handled.
+&lt;code&gt;script/plugin install git://github.com/alexyoung/loom-exceptions-rails-plugin.git&lt;/code&gt;
 
-Similarly, &lt;code&gt;before_action&lt;/code&gt; is an action that will be run before rendering the display action.  This can be used to check a visitor is logged in to display either an internal application or public template.
+Add this to &lt;code&gt;config/initializers/loom.rb&lt;/code&gt;
 
-h2. Todo
+&lt;pre&gt;&lt;code&gt;
+Helicoid::Loom.configure do |config|
+  config.api_key = 'xxx'
+  config.server = 'http://loomapp.com'
+end
+&lt;/code&gt;&lt;/pre&gt;
 
-* We need to correctly handle Loom being down or errors reporting to Loom
-* Error reporting API for easy reporting outside controllers
+The &lt;code&gt;server&lt;/code&gt; option can be used with the open source version of Loom.
 
 h2. Credits
 </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -1,27 +1,44 @@
 module Helicoid
   module Loom
-    def self.enable
-      ActionController::Base.class_eval do
-        include InstanceMethods
-        extend ClassMethods
+    class &lt;&lt; self
+      attr_accessor :api_key, :server, :before_action, :user_id
+
+      def enable
+        ActionController::Base.class_eval do
+          include Reporter
+        end
+      end
+
+      def configure
+        yield self
+
+        self.server ||= 'http://loomapp.com'
+
+        if defined?(ActionController::Base) &amp;&amp; !ActionController::Base.include?(Helicoid::Loom::Reporter)
+          enable
+        end
       end
     end
     
-    module InstanceMethods
-      def log_with_loom(exception)
+    module Reporter
+      def self.included(base)
+        base.send(:alias_method, :original_rescue_action_in_public, :rescue_action_in_public)
+        base.send(:alias_method, :rescue_action_in_public, :send_to_loom)
+      end
+
+      def send_to_loom(exception)
         raise if local_request?
         
-        send(loom_options[:before_action]) if loom_options.has_key? :before_action
+        send(Helicoid::Loom.before_action) if Helicoid::Loom.before_action
         
-        user_id = case loom_options[:user_id]
+        user_id = case Helicoid::Loom.user_id
         when Proc
-          loom_options[:user_id].bind(self).call
+          Helicoid::Loom.user_id.bind(self).call
         when Symbol, String
-          send loom_options[:user_id]
+          send Helicoid::Loom.user_id
         end
         
-        LoomException.log loom_options[:url], loom_options[:email], loom_options[:password] do |loom|
-          loom.project_id = loom_options[:project_id]
+        LoomException.log Helicoid::Loom.server, Helicoid::Loom.api_key do |loom|
           loom.session = session.data
           loom.remote_ip = request.remote_ip
           loom.exception = exception
@@ -30,26 +47,19 @@ module Helicoid
           loom.url = request.request_uri
           loom.user_id = user_id
         end
-        
-        if loom_options.has_key? :display
-          send(loom_options[:display])
-        else
-          raise
-        end
+
+        original_rescue_action_in_public exception
       end
     end
     
     module ClassMethods
-      def enable_loom(options = {})
-        write_inheritable_hash :loom_options, options
-        class_inheritable_reader :loom_options
+      def logger
+        ActiveRecord::Base.logger
+      end
 
-        class_eval &lt;&lt;-RUBY
-          rescue_from Exception do |exception|
-            log_with_loom exception
-          end
-        RUBY
+      def enable_loom(options = {})
+        logger.warn &quot;enable_loom has been removed.  Please use config/initializers/loom.rb.&quot;
       end
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>lib/loom.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,13 +2,13 @@ require 'pp'
 require 'net/http'
 
 class LoomException
-  attr_accessor :session, :cookies, :request_parameters, :url, :user_id, :exception, :project_id, :remote_ip
+  attr_accessor :session, :cookies, :request_parameters, :url, :user_id, :exception, :remote_ip
   
   class LoomDown &lt; Exception ; end
   class LoomError &lt; Exception ; end
   
-  def initialize(url, email, password)
-    @loom_login = { :url =&gt; url, :email =&gt; email, :password =&gt; password }
+  def initialize(url, api_key)
+    @loom_login = { :url =&gt; url, :api_key =&gt; api_key }
   end
   
   def send_to_loom
@@ -22,8 +22,8 @@ class LoomException
     end
   end
   
-  def self.log(url, email, password, &amp;block)
-    loom = new url, email, password
+  def self.log(url, api_key, &amp;block)
+    loom = new url, api_key
     yield loom
     loom.send_to_loom
   rescue LoomDown # TODO
@@ -37,12 +37,11 @@ class LoomException
   
   private
     def post
-      url = URI.parse &quot;#{@loom_login[:url]}/projects/#{@project_id}/exceptions&quot;
+      url = URI.parse &quot;#{@loom_login[:url]}/report/#{@loom_login[:api_key]}&quot;
     
       req = Net::HTTP::Post.new url.path
       req.add_field 'Accept', 'application/xml'
       req.add_field 'Content-Type', 'application/xml'
-      req.basic_auth @loom_login[:email], @loom_login[:password]
       
       connection = Net::HTTP.new(url.host, url.port)
       connection.request req, loom_parameters_as_xml</diff>
      <filename>lib/loom_exception.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,3 +2,30 @@
 # task :loom do
 #   # Task goes here
 # end
+
+namespace :loom do
+  desc &quot;Sends a test exception so you can test your settings&quot;
+  task :test do
+    require 'action_controller/test_process'
+    require 'app/controllers/application_controller'
+
+    class ApplicationController
+      def test
+       puts &quot;Connecting to server: #{Helicoid::Loom.server} with API key: #{Helicoid::Loom.api_key}&quot;
+       raise &quot;This is a test error notification&quot;
+      end
+
+      def rescue_action(exception)
+        rescue_action_in_public exception
+      end
+    end
+
+    request = ActionController::TestRequest.new
+    response = ActionController::TestResponse.new
+
+    request.action = 'test'
+    request.request_uri = '/test'
+
+    ApplicationController.process request, response
+  end
+end</diff>
      <filename>tasks/loom_tasks.rake</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,15 @@ class LoomTest &lt; Test::Unit::TestCase
     assert exception.send_to_loom
   end
 
+  def test_configure
+    Helicoid::Loom.configure do |config|
+      config.api_key = 'xxx'
+    end
+
+    assert_equal 'xxx', Helicoid::Loom.api_key
+    assert_equal 'http://loomapp.com', Helicoid::Loom.server
+  end
+
   private
 
     def mocked_response(options = {})
@@ -47,14 +56,13 @@ class LoomTest &lt; Test::Unit::TestCase
     end
 
     def mock_loom_exception(options = {})
-      exception = LoomException.new 'helicoid', 'alex@example.com', 'test'
+      exception = LoomException.new 'helicoid', 'xxx'
       exception.session = OpenStruct.new :user_id =&gt; '1'
       exception.cookies = []
       exception.request_parameters = []
       exception.url = 'http://example.com'
       exception.user_id = '1'
       exception.exception = options[:exception] || ZeroDivisionError.new
-      exception.project_id = 1
       exception.remote_ip = '127.0.0.1'
       exception
     end</diff>
      <filename>test/loom_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>61f997e28d039e1321e13d4da34304890fce7720</id>
    </parent>
  </parents>
  <author>
    <name>Alex Young</name>
    <email>alex@helicoid.net</email>
  </author>
  <url>http://github.com/alexyoung/loom-exceptions-rails-plugin/commit/f2ae6507831b1582ad549e83343c0cbcfe1a5a02</url>
  <id>f2ae6507831b1582ad549e83343c0cbcfe1a5a02</id>
  <committed-date>2009-07-18T09:31:52-07:00</committed-date>
  <authored-date>2009-07-18T09:31:52-07:00</authored-date>
  <message>Authentication now works with a key so you don't need to specify email/password

Added exception test that can be run with rake loom:test</message>
  <tree>b32ebefa68b985c91cad8ec5d4f0271dab5bd1a4</tree>
  <committer>
    <name>Alex Young</name>
    <email>alex@helicoid.net</email>
  </committer>
</commit>
