<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>init.rb</filename>
    </added>
    <added>
      <filename>lib/hoptoad/catcher.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require 'net/http'
+
 module Hoptoad
   class Connection
     attr_reader :logger
@@ -19,7 +21,7 @@ module Hoptoad
         }
         http.read_timeout = 5 # seconds
         http.open_timeout = 2 # seconds
-        # http.use_ssl = HoptoadNotifier.secure
+        # http.use_ssl = Hoptoad.secure
         response = begin
                      http.post(@service_uri.path, stringify_keys(data).to_yaml, headers)
                    rescue TimeoutError =&gt; e</diff>
      <filename>lib/hoptoad/connection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,12 +9,12 @@ module Hoptoad
     #  :error_message (string)
     #  :backtrace (array)
     def initialize(params={})
-      @params = default_params.merge(params)
+      @params = default_params.merge(params.delete_if { |k,v| v.nil? })
     end
     
     def default_params
       {
-        :api_key       =&gt; HoptoadNotifier.api_key,
+        :api_key       =&gt; Hoptoad.api_key,
         :request       =&gt; {},
         :session       =&gt; {},
         :environment   =&gt; {},
@@ -25,7 +25,7 @@ module Hoptoad
     
     def environment_data
       environment_data = @params[:environment]
-      if @params[:request].is_a?(ActionController::CgiRequest)
+      if @params[:request].respond_to?(:env)
         environment_data.merge!(@params[:request].env.to_hash)
       end
       environment_data
@@ -64,7 +64,7 @@ module Hoptoad
     
     class &lt;&lt; self
       
-      def build(hash_or_exception, request = nil, session = nil, environment = {})
+      def build(hash_or_exception, request = {}, session = {}, environment = {})
         error_message = &quot;#{hash_or_exception.class.name}: #{hash_or_exception.message}&quot;
         new(
           :error_class    =&gt; hash_or_exception.class.name, 
@@ -90,7 +90,7 @@ module Hoptoad
         end
 
         backtrace.to_a.map do |line|
-          HoptoadNotifier.backtrace_filters.inject(line) do |line, proc|
+          Hoptoad.backtrace_filters.inject(line) do |line, proc|
             proc.call(line)
           end
         end
@@ -98,7 +98,7 @@ module Hoptoad
 
       def filtered_parameters(parameters)
         parameters.each do |k, v|
-          parameters[k] = &quot;&lt;filtered&gt;&quot; if HoptoadNotifier.params_filters.any? do |filter|
+          parameters[k] = &quot;&lt;filtered&gt;&quot; if Hoptoad.params_filters.any? do |filter|
             k.to_s.match(/#{filter}/)
           end
         end</diff>
      <filename>lib/hoptoad/notice.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,6 @@
+require 'hoptoad/connection'
+require 'hoptoad/notice'
+
 module Hoptoad
   class Notifier
     def initialize(connection)</diff>
      <filename>lib/hoptoad/notifier.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,2 @@
 require File.join(File.dirname(__FILE__), *%w[.. hoptoad_notifier])
-require File.join(File.dirname(__FILE__), *%w[connection])
-require File.join(File.dirname(__FILE__), *%w[notice])
 require File.join(File.dirname(__FILE__), *%w[notifier])</diff>
      <filename>lib/hoptoad/standalone.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,6 @@
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'hoptoad'))
-require 'net/http'
-require 'connection'
-require 'notice'
-require 'notifier'
-
-# Plugin for applications to automatically post errors to the Hoptoad of their choice.
-module HoptoadNotifier
+require 'hoptoad/catcher'
 
+module Hoptoad
   IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
                     'ActionController::RoutingError',
                     'ActionController::InvalidAuthenticityToken',
@@ -40,7 +34,7 @@ module HoptoadNotifier
     
     # Returns the list of errors that are being ignored. The array can be appended to.
     def ignore
-      @ignore ||= (HoptoadNotifier::IGNORE_DEFAULT.dup)
+      @ignore ||= (Hoptoad::IGNORE_DEFAULT.dup)
       @ignore.flatten!
       @ignore
     end
@@ -111,64 +105,11 @@ module HoptoadNotifier
     end
   end
 
-  # Include this module in Controllers in which you want to be notified of errors.
-  module Catcher
-
-    def self.included(base) #:nodoc:
-      if base.instance_methods.include? 'rescue_action_in_public' and !base.instance_methods.include? 'rescue_action_in_public_without_hoptoad'
-        base.alias_method_chain :rescue_action_in_public, :hoptoad
-      end
-    end
-    
-    # Overrides the rescue_action method in ActionController::Base, but does not inhibit
-    # any custom processing that is defined with Rails 2's exception helpers.
-    def rescue_action_in_public_with_hoptoad(exception)
-      notify_hoptoad(exception) unless ignore?(exception)
-      rescue_action_in_public_without_hoptoad(exception)
-    end 
-        
-    # This method should be used for sending manual notifications while you are still
-    # inside the controller. Otherwise it works like HoptoadNotifier.notify. 
-    def notify_hoptoad(hash_or_exception)
-      if public_environment?
-        hoptoad_notifier.notify(hash_or_exception, rails_request, rails_session, ENV.to_hash)
-      end
-    end
-    alias_method :inform_hoptoad, :notify_hoptoad
-    
-    def hoptoad_notifier
-      @hoptoad_notifier ||= Hoptoad::Notifier.new(hoptoad_connection)
-    end
-    
-    def hoptoad_connection
-      Hoptoad::Connection.from_config(HoptoadNotifier)
-    end
-    
-    def rails_request
-      respond_to?(:request) ? request : nil
-    end
-    
-    def rails_session
-      respond_to?(:session) ? session : nil
-    end
-
-    private
-    
-    def public_environment? #nodoc:
-      defined?(RAILS_ENV) and !['development', 'test'].include?(RAILS_ENV)
-    end
-    
-    def ignore?(exception) #:nodoc:
-      ignore_these = HoptoadNotifier.ignore.flatten
-      ignore_these.include?(exception.class) || ignore_these.include?(exception.class.name)
-    end
-  end
-
   # A dummy class for sending notifications manually outside of a controller.
   class Sender
     def rescue_action_in_public(exception)
     end
 
-    include HoptoadNotifier::Catcher
+    include Hoptoad::Catcher
   end
 end</diff>
      <filename>lib/hoptoad_notifier.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,8 +6,8 @@ class HoptoadConnectionFunctionalTest &lt; Test::Unit::TestCase
   context &quot;Sending data over the connection&quot; do
     setup do
       @logger = stub_everything('Logger')
-      HoptoadNotifier.stubs(:logger).returns(@logger)
-      @connection = Hoptoad::Connection.from_config(HoptoadNotifier)
+      Hoptoad.stubs(:logger).returns(@logger)
+      @connection = Hoptoad::Connection.from_config(Hoptoad)
     end
     
     should &quot;POST the data as YAML to Hoptoad's server&quot; do</diff>
      <filename>test/hoptoad_connection_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ end
 class HoptoadNoticeFunctionalTest &lt; Test::Unit::TestCase
   
   def setup
-    HoptoadNotifier.stubs(:api_key).returns(&quot;000011110000&quot;)
+    Hoptoad.stubs(:api_key).returns(&quot;000011110000&quot;)
   end
   
   def test_notice_with_all_available_data_returns_the_correct_payload
@@ -81,7 +81,7 @@ class HoptoadNoticeFunctionalTest &lt; Test::Unit::TestCase
   end
   
   def test_notice_should_censor_any_filtered_parameters_that_have_been_configured
-    HoptoadNotifier.params_filters &lt;&lt; &quot;top_secret_parameter&quot;
+    Hoptoad.params_filters &lt;&lt; &quot;top_secret_parameter&quot;
     
     request = ActionController::TestRequest.new({
       'action'     =&gt; 'my_action',
@@ -96,7 +96,7 @@ class HoptoadNoticeFunctionalTest &lt; Test::Unit::TestCase
   end
   
   def test_should_pass_backtrace_through_any_configured_filters
-    HoptoadNotifier.filter_backtrace do |line|
+    Hoptoad.filter_backtrace do |line|
       line.gsub(&quot;/my/private/server/folder&quot;, &quot;[PRIVATE_FOLDER]&quot;)
     end
     </diff>
      <filename>test/hoptoad_notice_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,7 +33,7 @@ class HoptoadController &lt; ActionController::Base
   end
 end
 
-class HoptoadNotifierTest &lt; Test::Unit::TestCase
+class HoptoadTest &lt; Test::Unit::TestCase
   def request(action = nil, method = :get)
     @request = ActionController::TestRequest.new({
       &quot;controller&quot; =&gt; &quot;hoptoad&quot;,
@@ -48,7 +48,7 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
     should &quot;be able to occur even outside Rails controllers&quot; do    
       assert_nothing_raised do
         class MyHoptoad
-          include HoptoadNotifier::Catcher
+          include Hoptoad::Catcher
         end
       end
       my = MyHoptoad.new
@@ -56,11 +56,11 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
     end
   end
   
-  context &quot;HoptoadNotifier configuration&quot; do
+  context &quot;Hoptoad configuration&quot; do
     setup do
       @controller = HoptoadController.new
       class ::HoptoadController
-        include HoptoadNotifier::Catcher
+        include Hoptoad::Catcher
         def rescue_action e
           rescue_action_in_public e
         end
@@ -69,7 +69,7 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
     end
 
     should &quot;be done with a block&quot; do
-      HoptoadNotifier.configure do |config|
+      Hoptoad.configure do |config|
         config.host = &quot;host&quot;
         config.port = 3333
         config.secure = true
@@ -77,21 +77,21 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
         config.ignore &lt;&lt; [ RuntimeError ]
       end
       
-      assert_equal &quot;host&quot;,              HoptoadNotifier.host
-      assert_equal 3333,                HoptoadNotifier.port
-      assert_equal true,                HoptoadNotifier.secure
-      assert_equal &quot;1234567890abcdef&quot;,  HoptoadNotifier.api_key
-      assert_equal (HoptoadNotifier::IGNORE_DEFAULT + [RuntimeError]), HoptoadNotifier.ignore
+      assert_equal &quot;host&quot;,              Hoptoad.host
+      assert_equal 3333,                Hoptoad.port
+      assert_equal true,                Hoptoad.secure
+      assert_equal &quot;1234567890abcdef&quot;,  Hoptoad.api_key
+      assert_equal (Hoptoad::IGNORE_DEFAULT + [RuntimeError]), Hoptoad.ignore
     end
 
     should &quot;set a default host&quot; do
-      HoptoadNotifier.instance_variable_set(&quot;@host&quot;,nil)
-      assert_equal &quot;hoptoadapp.com&quot;, HoptoadNotifier.host
+      Hoptoad.instance_variable_set(&quot;@host&quot;,nil)
+      assert_equal &quot;hoptoadapp.com&quot;, Hoptoad.host
     end
     
     should &quot;add filters to the backtrace_filters&quot; do
-      assert_difference &quot;HoptoadNotifier.backtrace_filters.length&quot; do
-        HoptoadNotifier.configure do |config|
+      assert_difference &quot;Hoptoad.backtrace_filters.length&quot; do
+        Hoptoad.configure do |config|
           config.filter_backtrace do |line|
             line = &quot;1234&quot;
           end
@@ -100,19 +100,19 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
     end
     
     should &quot;add filters to the params filters&quot; do
-      assert_difference &quot;HoptoadNotifier.params_filters.length&quot;, 2 do
-        HoptoadNotifier.configure do |config|
+      assert_difference &quot;Hoptoad.params_filters.length&quot;, 2 do
+        Hoptoad.configure do |config|
           config.params_filters &lt;&lt; &quot;abc&quot;
           config.params_filters &lt;&lt; &quot;def&quot;
         end
       end
 
-      assert HoptoadNotifier.params_filters.include?( &quot;abc&quot; )
-      assert HoptoadNotifier.params_filters.include?( &quot;def&quot; )
+      assert Hoptoad.params_filters.include?( &quot;abc&quot; )
+      assert Hoptoad.params_filters.include?( &quot;def&quot; )
     end
     
     should &quot;have at default ignored exceptions&quot; do
-      assert HoptoadNotifier::IGNORE_DEFAULT.any?
+      assert Hoptoad::IGNORE_DEFAULT.any?
     end
   end
 
@@ -143,12 +143,12 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
     context &quot;with the notifier installed&quot; do
       setup do
         class ::HoptoadController
-          include HoptoadNotifier::Catcher
+          include Hoptoad::Catcher
           def rescue_action e
             rescue_action_in_public e
           end
         end
-        HoptoadNotifier.ignore_only = HoptoadNotifier::IGNORE_DEFAULT
+        Hoptoad.ignore_only = Hoptoad::IGNORE_DEFAULT
         @controller.stubs(:public_environment?).returns(true)
         @connection = mock('Connection')
         Hoptoad::Connection.stubs(:new).returns(@connection)
@@ -218,7 +218,7 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
       
       context &quot;and configured to ignore additional exceptions&quot; do
         setup do
-          HoptoadNotifier.ignore &lt;&lt; ActiveRecord::StatementInvalid
+          Hoptoad.ignore &lt;&lt; ActiveRecord::StatementInvalid
         end
         
         should &quot;still ignore default exceptions&quot; do
@@ -248,7 +248,7 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
       
       context &quot;and configured to ignore only certain exceptions&quot; do
         setup do
-          HoptoadNotifier.ignore_only = [ActiveRecord::StatementInvalid]
+          Hoptoad.ignore_only = [ActiveRecord::StatementInvalid]
         end
         
         should &quot;no longer ignore default exceptions&quot; do
@@ -281,7 +281,7 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
   context &quot;Sending a notice&quot; do
     context &quot;with an exception&quot; do
       setup do
-        @sender    = HoptoadNotifier::Sender.new
+        @sender    = Hoptoad::Sender.new
         @backtrace = caller
         @exception = begin
           raise
@@ -290,29 +290,29 @@ class HoptoadNotifierTest &lt; Test::Unit::TestCase
         end
         @options   = {:error_message =&gt; &quot;123&quot;,
                       :backtrace =&gt; @backtrace}
-        HoptoadNotifier.instance_variable_set(&quot;@backtrace_filters&quot;, [])
-        HoptoadNotifier::Sender.expects(:new).returns(@sender)
+        Hoptoad.instance_variable_set(&quot;@backtrace_filters&quot;, [])
+        Hoptoad::Sender.expects(:new).returns(@sender)
         @sender.stubs(:public_environment?).returns(true)
       end
 
       should &quot;send as if it were a normally caught exception&quot; do
         @sender.expects(:notify_hoptoad).with(@exception)
-        HoptoadNotifier.notify(@exception)
+        Hoptoad.notify(@exception)
       end
     end
     
     context &quot;without an exception&quot; do
       setup do
-        @sender    = HoptoadNotifier::Sender.new
+        @sender    = Hoptoad::Sender.new
         @backtrace = caller
         @options   = {:error_message =&gt; &quot;123&quot;,
                       :backtrace =&gt; @backtrace}
-        HoptoadNotifier::Sender.expects(:new).returns(@sender)
+        Hoptoad::Sender.expects(:new).returns(@sender)
       end
 
       should &quot;send sensible defaults&quot; do
         @sender.expects(:notify_hoptoad).with(@options)
-        HoptoadNotifier.notify(:error_message =&gt; &quot;123&quot;, :backtrace =&gt; @backtrace)
+        Hoptoad.notify(:error_message =&gt; &quot;123&quot;, :backtrace =&gt; @backtrace)
       end
     end
     </diff>
      <filename>test/hoptoad_notifier_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d0692cfdd60ae2b3135122059a64a9e36b2f1a36</id>
    </parent>
  </parents>
  <author>
    <name>Luke Redpath</name>
    <email>contact@lukeredpath.co.uk</email>
  </author>
  <url>http://github.com/lukeredpath/hoptoad_notifier/commit/c25d170a51820c65451fdcae64b38b59deaeb46f</url>
  <id>c25d170a51820c65451fdcae64b38b59deaeb46f</id>
  <committed-date>2008-08-15T07:13:29-07:00</committed-date>
  <authored-date>2008-08-15T07:13:29-07:00</authored-date>
  <message>Having Hoptoad::Notifier and HoptoadNotifier is confusing; the base module can just be called Hoptoad. Also found a bug in Hoptoad::Notice where it would fail if it was passed nil for request/session</message>
  <tree>8ea02fa5ff903136fa731a7a45396fd70f83a0a1</tree>
  <committer>
    <name>Luke Redpath</name>
    <email>contact@lukeredpath.co.uk</email>
  </committer>
</commit>
